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:
tetektoza
2025-08-20 00:47:36 +02:00
committed by Chris Hennes
parent 9647b8c637
commit a6e0b91758
6 changed files with 27 additions and 6 deletions

View File

@@ -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