Skip to content

Commit

Permalink
Handle deleted SIP objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Sep 28, 2018
1 parent a847759 commit 0216bc8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion gns3/modules/qemu/pages/qemu_vm_configuration_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _getQemuBinariesFromServerCallback(self, result, error=False, qemu_path=None
:param error: indicates an error (boolean)
"""

if sip_is_deleted(self.uiQemuListComboBox):
if sip_is_deleted(self.uiQemuListComboBox) or sip_is_deleted(self):
return

if error:
Expand Down
2 changes: 1 addition & 1 deletion gns3/packet_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _updatedLinkSlot(self, link_id):

if link:
if link.capturing():
if self._autostart[link] and link not in self._tail_process:
if self._autostart.get(link) and link not in self._tail_process:
self.startPacketCaptureReader(link)
log.debug("Has successfully started capturing packets on {} to {}".format(link.id(), link.capture_file_path()))
else:
Expand Down
53 changes: 29 additions & 24 deletions gns3/pages/gns3_vm_preferences_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,47 @@ def loadPreferences(self):

@qslot
def _getSettingsCallback(self, result, error=False, **kwargs):

if sip_is_deleted(self.uiRamSpinBox) or sip_is_deleted(self):
return
if error:
if "message" in result:
log.error("Error while getting settings : {}".format(result["message"]))
return
if not sip_is_deleted(self.uiRamSpinBox):
self._old_settings = copy.copy(result)
self._settings = result
self.uiRamSpinBox.setValue(self._settings["ram"])
self.uiCpuSpinBox.setValue(self._settings["vcpus"])
self.uiEnableVMCheckBox.setChecked(self._settings["enable"])
if self._settings["when_exit"] == "keep":
self.uiWhenExitKeepRadioButton.setChecked(True)
elif self._settings["when_exit"] == "suspend":
self.uiWhenExitSuspendRadioButton.setChecked(True)
else:
self.uiWhenExitStopRadioButton.setChecked(True)
self.uiHeadlessCheckBox.setChecked(self._settings["headless"])
Controller.instance().get("/gns3vm/engines", self._listEnginesCallback)
self._old_settings = copy.copy(result)
self._settings = result
self.uiRamSpinBox.setValue(self._settings["ram"])
self.uiCpuSpinBox.setValue(self._settings["vcpus"])
self.uiEnableVMCheckBox.setChecked(self._settings["enable"])
if self._settings["when_exit"] == "keep":
self.uiWhenExitKeepRadioButton.setChecked(True)
elif self._settings["when_exit"] == "suspend":
self.uiWhenExitSuspendRadioButton.setChecked(True)
else:
self.uiWhenExitStopRadioButton.setChecked(True)
self.uiHeadlessCheckBox.setChecked(self._settings["headless"])
Controller.instance().get("/gns3vm/engines", self._listEnginesCallback)

@qslot
def _listEnginesCallback(self, result, error=False, ignore_error=False, **kwargs):

if sip_is_deleted(self.uiGNS3VMEngineComboBox) or sip_is_deleted(self):
return

if error:
if "message" in result:
log.error("Error while getting the list of GNS3 VM engines : {}".format(result["message"]))
return

if not sip_is_deleted(self.uiGNS3VMEngineComboBox):
self.uiGNS3VMEngineComboBox.clear()
self._engines = result
# We insert first the current engine to avoid triggering unexpected signals
for engine in self._engines:
if self._settings["engine"] == engine["engine_id"]:
self.uiGNS3VMEngineComboBox.addItem(engine["name"], engine["engine_id"])
for engine in self._engines:
if self._settings["engine"] != engine["engine_id"]:
self.uiGNS3VMEngineComboBox.addItem(engine["name"], engine["engine_id"])
self.uiGNS3VMEngineComboBox.clear()
self._engines = result
# We insert first the current engine to avoid triggering unexpected signals
for engine in self._engines:
if self._settings["engine"] == engine["engine_id"]:
self.uiGNS3VMEngineComboBox.addItem(engine["name"], engine["engine_id"])
for engine in self._engines:
if self._settings["engine"] != engine["engine_id"]:
self.uiGNS3VMEngineComboBox.addItem(engine["name"], engine["engine_id"])

@qslot
def _refreshVMSlot(self, ignore_error=False):
Expand Down
8 changes: 4 additions & 4 deletions gns3/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def load(self, path=None):

def _projectOpenCallback(self, result, error=False, **kwargs):
if error:
self.project_creation_error_signal.emit(result["message"])
self.project_creation_error_signal.emit(result.get("message", "unknown"))
return

self._parseResponse(result)
Expand All @@ -523,7 +523,7 @@ def _projectOpenCallback(self, result, error=False, **kwargs):

def _listNodesCallback(self, result, error=False, **kwargs):
if error:
log.error("Error while listing project: {}".format(result["message"]))
log.error("Error while listing project: {}".format(result.get("message", "unknown")))
return
topo = Topology.instance()
for node in result:
Expand All @@ -532,7 +532,7 @@ def _listNodesCallback(self, result, error=False, **kwargs):

def _listLinksCallback(self, result, error=False, **kwargs):
if error:
log.error("Error while listing links: {}".format(result["message"]))
log.error("Error while listing links: {}".format(result.get("message", "unknown")))
return
topo = Topology.instance()
for link in result:
Expand All @@ -541,7 +541,7 @@ def _listLinksCallback(self, result, error=False, **kwargs):

def _listDrawingsCallback(self, result, error=False, **kwargs):
if error:
log.error("Error while listing drawings: {}".format(result["message"]))
log.error("Error while listing drawings: {}".format(result.get("message", "unknown")))
return
topo = Topology.instance()
for drawing in result:
Expand Down

0 comments on commit 0216bc8

Please sign in to comment.