From cd2de45af304ff8533b129556261f58b9c91305a Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sat, 29 Jun 2019 19:16:33 -0700 Subject: [PATCH] Properly deal with deleted objects when cleaning up the extension visualisation. --- src/Mod/Path/PathScripts/PathPocketShapeGui.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathPocketShapeGui.py b/src/Mod/Path/PathScripts/PathPocketShapeGui.py index 6a14c63d72..e883aaaf8a 100644 --- a/src/Mod/Path/PathScripts/PathPocketShapeGui.py +++ b/src/Mod/Path/PathScripts/PathPocketShapeGui.py @@ -178,7 +178,16 @@ class TaskPanelExtensionPage(PathOpGui.TaskPanelPage): Page = self def cleanupPage(self, obj): - self.obj.ViewObject.RootNode.removeChild(self.switch) + # 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. + 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)) def getForm(self): return FreeCADGui.PySideUic.loadUi(":/panels/PageOpPocketExtEdit.ui")