Assembly: Auto close on deleted doc for dialogs to avoid segfaults
Currently if we close document on Assembly WB while having dialog opened, it will throw segfault because it is not being auto closed automatically during document close. This in turn resulted in dialog having dangling references to document that was no longer existing, throwing segfaults in random places. So solution is simple - add `setAutoCloseOnDeletedDocument` for every dialog in Assembly to avoid this situation and close every dialog upon document close.
This commit is contained in:
@@ -92,7 +92,10 @@ class CommandCreateBom:
|
||||
|
||||
def Activated(self):
|
||||
self.panel = TaskAssemblyCreateBom()
|
||||
Gui.Control.showDialog(self.panel)
|
||||
dialog = Gui.Control.showDialog(self.panel)
|
||||
if dialog is not None:
|
||||
dialog.setAutoCloseOnDeletedDocument(True)
|
||||
dialog.setDocumentName(App.ActiveDocument.Name)
|
||||
|
||||
|
||||
######### Create Exploded View Task ###########
|
||||
|
||||
@@ -60,6 +60,7 @@ def activateJoint(index):
|
||||
dialog = Gui.doCommandEval("dialog")
|
||||
if dialog is not None:
|
||||
dialog.setAutoCloseOnTransactionChange(True)
|
||||
dialog.setAutoCloseOnDeletedDocument(True)
|
||||
dialog.setDocumentName(App.ActiveDocument.Name)
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,10 @@ class CommandCreateSimulation:
|
||||
return
|
||||
|
||||
self.panel = TaskAssemblyCreateSimulation()
|
||||
Gui.Control.showDialog(self.panel)
|
||||
dialog = Gui.Control.showDialog(self.panel)
|
||||
if dialog is not None:
|
||||
dialog.setAutoCloseOnDeletedDocument(True)
|
||||
dialog.setDocumentName(App.ActiveDocument.Name)
|
||||
|
||||
|
||||
######### Simulation Object ###########
|
||||
@@ -267,7 +270,10 @@ class ViewProviderSimulation:
|
||||
Gui.ActiveDocument.setEdit(assembly)
|
||||
|
||||
panel = TaskAssemblyCreateSimulation(vpDoc.Object)
|
||||
Gui.Control.showDialog(panel)
|
||||
dialog = Gui.Control.showDialog(panel)
|
||||
if dialog is not None:
|
||||
dialog.setAutoCloseOnDeletedDocument(True)
|
||||
dialog.setDocumentName(App.ActiveDocument.Name)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -76,7 +76,11 @@ class CommandCreateView:
|
||||
Gui.addModule("CommandCreateView") # NOLINT
|
||||
Gui.doCommand("panel = CommandCreateView.TaskAssemblyCreateView()")
|
||||
self.panel = Gui.doCommandEval("panel")
|
||||
Gui.doCommandGui("Gui.Control.showDialog(panel)")
|
||||
Gui.doCommandGui("dialog = Gui.Control.showDialog(panel)")
|
||||
dialog = Gui.doCommandEval("dialog")
|
||||
if dialog is not None:
|
||||
dialog.setAutoCloseOnDeletedDocument(True)
|
||||
dialog.setDocumentName(App.ActiveDocument.Name)
|
||||
|
||||
|
||||
######### Exploded View Object ###########
|
||||
@@ -214,7 +218,10 @@ class ViewProviderExplodedView:
|
||||
Gui.ActiveDocument.setEdit(assembly)
|
||||
|
||||
panel = TaskAssemblyCreateView(vobj.Object)
|
||||
Gui.Control.showDialog(panel)
|
||||
dialog = Gui.Control.showDialog(panel)
|
||||
if dialog is not None:
|
||||
dialog.setAutoCloseOnDeletedDocument(True)
|
||||
dialog.setDocumentName(App.ActiveDocument.Name)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -67,7 +67,10 @@ class CommandInsertNewPart:
|
||||
|
||||
def Activated(self):
|
||||
panel = TaskAssemblyNewPart()
|
||||
Gui.Control.showDialog(panel)
|
||||
dialog = Gui.Control.showDialog(panel)
|
||||
if dialog is not None:
|
||||
dialog.setAutoCloseOnDeletedDocument(True)
|
||||
dialog.setDocumentName(App.ActiveDocument.Name)
|
||||
|
||||
|
||||
class TaskAssemblyNewPart(JointObject.TaskAssemblyCreateJoint):
|
||||
|
||||
@@ -1004,6 +1004,7 @@ class ViewProviderJoint:
|
||||
dialog = Gui.Control.showDialog(panel)
|
||||
if dialog is not None:
|
||||
dialog.setAutoCloseOnTransactionChange(True)
|
||||
dialog.setAutoCloseOnDeletedDocument(True)
|
||||
dialog.setDocumentName(App.ActiveDocument.Name)
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user