diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 0396de23d0..f941f93df6 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -152,7 +152,6 @@ TaskFeaturePick::~TaskFeaturePick() { for(Gui::ViewProviderOrigin* vpo : origins) vpo->resetTemporaryVisibility(); - } void TaskFeaturePick::updateList() @@ -439,10 +438,11 @@ void TaskFeaturePick::showExternal(bool val) // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgFeaturePick::TaskDlgFeaturePick(std::vector &objects, +TaskDlgFeaturePick::TaskDlgFeaturePick( std::vector &objects, const std::vector &status, boost::function)> afunc, - boost::function)> wfunc) + boost::function)> wfunc, + boost::function abortfunc /* = NULL */ ) : TaskDialog(), accepted(false) { pick = new TaskFeaturePick(objects, status); @@ -450,14 +450,27 @@ TaskDlgFeaturePick::TaskDlgFeaturePick(std::vector &object acceptFunction = afunc; workFunction = wfunc; + abortFunction = abortfunc; } TaskDlgFeaturePick::~TaskDlgFeaturePick() { //do the work now as before in accept() the dialog is still open, hence the work //function could not open another dialog - if (accepted) + if (accepted) { workFunction(pick->buildFeatures()); + } else if (abortFunction) { + + // Get rid of the TaskFeaturePick before the TaskDialog dtor does. The + // TaskFeaturePick holds pointers to things (ie any implicitly created + // Body objects) that might be modified/removed by abortFunction. + for (auto it : Content) { + delete it; + } + Content.clear(); + + abortFunction(); + } } //==== calls from the TaskView =============================================================== diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.h b/src/Mod/PartDesign/Gui/TaskFeaturePick.h index d262b2efd0..83f55ba3fa 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.h +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.h @@ -90,10 +90,11 @@ class TaskDlgFeaturePick : public Gui::TaskView::TaskDialog Q_OBJECT public: - TaskDlgFeaturePick(std::vector &objects, + TaskDlgFeaturePick( std::vector &objects, const std::vector &status, boost::function)> acceptfunc, - boost::function)> workfunc); + boost::function)> workfunc, + boost::function abortfunc = NULL ); ~TaskDlgFeaturePick(); public: @@ -120,6 +121,7 @@ protected: bool accepted; boost::function)> acceptFunction; boost::function)> workFunction; + boost::function abortFunction; }; }