Skip to content

Commit

Permalink
Gui: [skip ci] fix crash when using a dialog instance twice for a tas…
Browse files Browse the repository at this point in the history
…k panel
  • Loading branch information
wwmayer committed Dec 18, 2020
1 parent 97e3947 commit def9e29
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Gui/TaskView/TaskDialogPython.cpp
Expand Up @@ -337,8 +337,20 @@ TaskDialogPython::~TaskDialogPython()
std::vector< QPointer<QWidget> > guarded;
guarded.insert(guarded.begin(), Content.begin(), Content.end());
Content.clear();

Base::PyGILStateLocker lock;

// The widgets stored in the 'form' attribute will be deleted.
// Thus, set this attribute to None to make sure that when using
// the same dialog instance for a task panel won't segfault.
if (this->dlg.hasAttr(std::string("form"))) {
this->dlg.setAttr(std::string("form"), Py::None());
}
this->dlg = Py::None();

// Assigning None to 'dlg' may destroy some of the stored widgets.
// By guarding them with QPointer their pointers will be set to null
// so that the destructor of the base class can reliably call 'delete'.
Content.insert(Content.begin(), guarded.begin(), guarded.end());
}

Expand Down

0 comments on commit def9e29

Please sign in to comment.