Skip to content

Commit

Permalink
[Path] Make jobs delete cleanly.
Browse files Browse the repository at this point in the history
Deletion of tool controllers now works for toolbits as well
  • Loading branch information
sliptonic committed Jun 19, 2020
1 parent ffe957c commit 9b73191
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/Mod/Path/PathScripts/PathJob.py
Expand Up @@ -223,13 +223,17 @@ def onDelete(self, obj, arg2=None):
doc.removeObject(obj.Model.Name)
obj.Model = None

# Tool controllers don't depend on anything
# Tool controllers might refer to either legacy tool or toolbit
PathLog.debug('taking down tool controller')
for tc in obj.ToolController:
if hasattr(tc.Tool,"Proxy"):
PathUtil.clearExpressionEngine(tc.Tool)
doc.removeObject(tc.Tool.Name)
PathUtil.clearExpressionEngine(tc)
tc.Proxy.onDelete(tc)
doc.removeObject(tc.Name)
obj.ToolController = []

# SetupSheet
PathUtil.clearExpressionEngine(obj.SetupSheet)
doc.removeObject(obj.SetupSheet.Name)
Expand Down Expand Up @@ -351,8 +355,9 @@ def __setstate__(self, state):
return None

def execute(self, obj):
obj.Path = obj.Operations.Path
self.getCycleTime()
if hasattr(obj, 'Operations'):
obj.Path = obj.Operations.Path
self.getCycleTime()

def getCycleTime(self):
seconds = 0
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathToolController.py
Expand Up @@ -80,7 +80,7 @@ def onDocumentRestored(self, obj):
def onDelete(self, obj, arg2=None):
# pylint: disable=unused-argument
if not self.usesLegacyTool(obj):
if len(obj.Tool.InList) == 1:
if hasattr(obj.Tool, 'InList') and len(obj.Tool.InList) == 1:
if hasattr(obj.Tool.Proxy, 'onDelete'):
obj.Tool.Proxy.onDelete(obj.Tool)
obj.Document.removeObject(obj.Tool.Name)
Expand Down

0 comments on commit 9b73191

Please sign in to comment.