Orderly deletion of a job.
This commit is contained in:
@@ -429,8 +429,16 @@ class ViewProviderDressup:
|
||||
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
if self.Object and self.Object.Base:
|
||||
for i in self.Object.Base.InList:
|
||||
if hasattr(i, "Group"):
|
||||
group = i.Group
|
||||
for g in group:
|
||||
if g.Name == self.Object.Base.Name:
|
||||
group.remove(g)
|
||||
i.Group = group
|
||||
print(i.Group)
|
||||
#FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False
|
||||
|
||||
def unsetEdit(self, vobj, mode=0):
|
||||
return False
|
||||
@@ -439,15 +447,6 @@ class ViewProviderDressup:
|
||||
return True
|
||||
|
||||
def claimChildren(self):
|
||||
for i in self.Object.Base.InList:
|
||||
if hasattr(i, "Group"):
|
||||
group = i.Group
|
||||
for g in group:
|
||||
if g.Name == self.Object.Base.Name:
|
||||
group.remove(g)
|
||||
i.Group = group
|
||||
print(i.Group)
|
||||
#FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False
|
||||
return [self.Object.Base]
|
||||
|
||||
def __getstate__(self):
|
||||
@@ -458,7 +457,7 @@ class ViewProviderDressup:
|
||||
|
||||
def onDelete(self, arg1=None, arg2=None):
|
||||
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
|
||||
PathUtils.addToProject(arg1.Object.Base)
|
||||
PathUtils.addToJob(arg1.Object.Base)
|
||||
arg1.Object.Base = None
|
||||
return True
|
||||
|
||||
|
||||
@@ -124,20 +124,30 @@ class ObjectJob:
|
||||
'''Called by the view provider, there doesn't seem to be a callback on the obj itself.'''
|
||||
PathLog.track(obj.Label, arg2)
|
||||
doc = obj.Document
|
||||
for tc in obj.ToolController:
|
||||
doc.removeObject(tc.Name)
|
||||
obj.ToolController = []
|
||||
# the first to tear down are the ops, they depend on other resources
|
||||
PathLog.debug('taking down ops: %s' % [o.Name for o in self.allOperations()])
|
||||
while obj.Operations.Group:
|
||||
doc.removeObject(obj.Operations.Group[0].Name)
|
||||
op = obj.Operations.Group[0]
|
||||
if not op.ViewObject or not hasattr(op.ViewObject.Proxy, 'onDelete') or op.ViewObject.Proxy.onDelete(op.ViewObject, ()):
|
||||
doc.removeObject(op.Name)
|
||||
obj.Operations.Group = []
|
||||
doc.removeObject(obj.Operations.Name)
|
||||
obj.Operations = None
|
||||
if obj.Base:
|
||||
doc.removeObject(obj.Base.Name)
|
||||
obj.Base = None
|
||||
# stock could depend on Base
|
||||
if obj.Stock:
|
||||
PathLog.debug('taking down stock')
|
||||
doc.removeObject(obj.Stock.Name)
|
||||
obj.Stock = None
|
||||
# base doesn't depend on anything inside job
|
||||
if obj.Base:
|
||||
PathLog.debug('taking down base')
|
||||
doc.removeObject(obj.Base.Name)
|
||||
obj.Base = None
|
||||
# Tool controllers don't depend on anything
|
||||
PathLog.debug('taking down tool controller')
|
||||
for tc in obj.ToolController:
|
||||
doc.removeObject(tc.Name)
|
||||
obj.ToolController = []
|
||||
|
||||
def fixupResourceClone(self, obj, name, icon):
|
||||
if not isResourceClone(obj, name, name):
|
||||
|
||||
Reference in New Issue
Block a user