From 86f1a0559f678d471d374c69397e6b3fbadc5031 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 3 May 2017 14:56:52 +0200 Subject: [PATCH] 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. --- cura/PrintInformation.py | 2 +- cura/Settings/MachineManager.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index cdb558b77c..ab63e4034d 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -185,7 +185,7 @@ class PrintInformation(QObject): if self._active_material_container: try: 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 active_material_id = Application.getInstance().getMachineManager().activeMaterialId diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index e01c16849a..f94bffc643 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -236,9 +236,15 @@ class MachineManager(QObject): if self._global_container_stack: try: 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) + except TypeError: + pass + try: self._global_container_stack.propertyChanged.disconnect(self._onPropertyChanged) - except: + except TypeError: pass material = self._global_container_stack.material material.nameChanged.disconnect(self._onMaterialNameChanged)