Skip to content

Commit

Permalink
Merge pull request #3688 from etrombly/deleted
Browse files Browse the repository at this point in the history
[PATH] fix Cannot access attribute 'Document' of deleted object when cancelling PathPocket operation
  • Loading branch information
sliptonic committed Jul 12, 2020
2 parents 7038cf8 + 2e251ee commit be1abcb
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/Mod/Path/PathScripts/PathPocketShapeGui.py
Expand Up @@ -173,16 +173,10 @@ def initPage(self, obj):
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.
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:
self.obj.ViewObject.RootNode.removeChild(self.switch)
except ReferenceError:
PathLog.debug("obj already destroyed - no cleanup required")

def getForm(self):
return FreeCADGui.PySideUic.loadUi(":/panels/PageOpPocketExtEdit.ui")
Expand Down

0 comments on commit be1abcb

Please sign in to comment.