From b4c2082b9ef79b810692dba5752e72403d99a063 Mon Sep 17 00:00:00 2001 From: Eric Trombly Date: Fri, 10 Jul 2020 07:46:41 -0500 Subject: [PATCH 1/2] fix deleted object error --- src/Mod/Path/PathScripts/PathPocketShapeGui.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathPocketShapeGui.py b/src/Mod/Path/PathScripts/PathPocketShapeGui.py index f085d062c1..21fa3a0a13 100644 --- a/src/Mod/Path/PathScripts/PathPocketShapeGui.py +++ b/src/Mod/Path/PathScripts/PathPocketShapeGui.py @@ -178,11 +178,13 @@ class TaskPanelExtensionPage(PathOpGui.TaskPanelPage): # Unfortunately there's no direct way to determine the object's # livelihood without causing an error so we look for the object # in the document and clean up if it still exists. - for o in self.obj.Document.getObjectsByLabel(self.obj.Label): - if o == obj: - self.obj.ViewObject.RootNode.removeChild(self.switch) - return - PathLog.debug("%s already destroyed - no cleanup required" % (obj.Label)) + try: + for o in self.obj.Document.getObjectsByLabel(self.obj.Label): + if o == obj: + self.obj.ViewObject.RootNode.removeChild(self.switch) + return + except ReferenceError: + PathLog.debug("obj already destroyed - no cleanup required") def getForm(self): return FreeCADGui.PySideUic.loadUi(":/panels/PageOpPocketExtEdit.ui") From 2e251ee9670cfc3c798adf35451629c031843360 Mon Sep 17 00:00:00 2001 From: Eric Trombly Date: Fri, 10 Jul 2020 15:41:46 -0500 Subject: [PATCH 2/2] cleaner fix --- src/Mod/Path/PathScripts/PathPocketShapeGui.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathPocketShapeGui.py b/src/Mod/Path/PathScripts/PathPocketShapeGui.py index 21fa3a0a13..739808cad5 100644 --- a/src/Mod/Path/PathScripts/PathPocketShapeGui.py +++ b/src/Mod/Path/PathScripts/PathPocketShapeGui.py @@ -173,16 +173,8 @@ class TaskPanelExtensionPage(PathOpGui.TaskPanelPage): self.blockUpdateData = False # pylint: disable=attribute-defined-outside-init def cleanupPage(self, obj): - # If the object was already destroyed we can't access obj.Name. - # This is the case if this was a new op and the user hit Cancel. - # Unfortunately there's no direct way to determine the object's - # livelihood without causing an error so we look for the object - # in the document and clean up if it still exists. try: - for o in self.obj.Document.getObjectsByLabel(self.obj.Label): - if o == obj: - self.obj.ViewObject.RootNode.removeChild(self.switch) - return + self.obj.ViewObject.RootNode.removeChild(self.switch) except ReferenceError: PathLog.debug("obj already destroyed - no cleanup required")