Add documentation and further specify except around disconnecting signals

Catch just a TypeError instead of all exceptions. Added documentation to say why we catch a TypeError there. Also splitted up the try-except block for the 3 disconnects, just so that if the first fails we still try to disconnect from the other two.

Contributes to issue CURA-3497.
This commit is contained in:
Ghostkeeper 2017-05-03 14:56:52 +02:00
parent d95488a940
commit 86f1a0559f
No known key found for this signature in database
GPG Key ID: C5F96EE2BC0F7E75
2 changed files with 8 additions and 2 deletions

View File

@ -185,7 +185,7 @@ class PrintInformation(QObject):
if self._active_material_container: if self._active_material_container:
try: try:
self._active_material_container.metaDataChanged.disconnect(self._onMaterialMetaDataChanged) self._active_material_container.metaDataChanged.disconnect(self._onMaterialMetaDataChanged)
except TypeError: except TypeError: #pyQtSignal gives a TypeError when disconnecting from something that is already disconnected.
pass pass
active_material_id = Application.getInstance().getMachineManager().activeMaterialId active_material_id = Application.getInstance().getMachineManager().activeMaterialId

View File

@ -236,9 +236,15 @@ class MachineManager(QObject):
if self._global_container_stack: if self._global_container_stack:
try: try:
self._global_container_stack.nameChanged.disconnect(self._onMachineNameChanged) self._global_container_stack.nameChanged.disconnect(self._onMachineNameChanged)
except TypeError: #pyQtSignal gives a TypeError when disconnecting from something that was already disconnected.
pass
try:
self._global_container_stack.containersChanged.disconnect(self._onInstanceContainersChanged) self._global_container_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
except TypeError:
pass
try:
self._global_container_stack.propertyChanged.disconnect(self._onPropertyChanged) self._global_container_stack.propertyChanged.disconnect(self._onPropertyChanged)
except: except TypeError:
pass pass
material = self._global_container_stack.material material = self._global_container_stack.material
material.nameChanged.disconnect(self._onMaterialNameChanged) material.nameChanged.disconnect(self._onMaterialNameChanged)