diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 54622bbab3..e52bf372f5 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -571,8 +571,13 @@ void CmdPartDesignNewSketch::activated(int iMsg) Gui::Command::doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); }; - // Called by dialog for "Cancel", or "OK" iff accepter returns false - auto quitter( Gui::Command::abortCommand ); + // Called by dialog for "Cancel", or "OK" if accepter returns false + std::string docname = doc->getName(); + auto quitter = [docname]() { + Gui::Document* document = Gui::Application::Instance->getDocument(docname.c_str()); + if (document) + document->abortCommand(); + }; if (validPlaneCount == 0) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid planes in this document"), diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index c2bddba260..e00eeafc73 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -449,6 +449,12 @@ void TaskFeaturePick::slotUndoDocument(const Gui::Document&) } } +void TaskFeaturePick::slotDeleteDocument(const Gui::Document&) +{ + origins.clear(); + QTimer::singleShot(100, &Gui::Control(), SLOT(closeDialog())); +} + void TaskFeaturePick::showExternal(bool val) { ui->checkOtherBody->setChecked(val); diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.h b/src/Mod/PartDesign/Gui/TaskFeaturePick.h index c1d981cedf..a8598cf762 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.h +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.h @@ -77,6 +77,8 @@ protected: virtual void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj); /** Notifies on undo */ virtual void slotUndoDocument(const Gui::Document& Doc); + /** Notifies on document deletion */ + virtual void slotDeleteDocument(const Gui::Document& Doc); private: Ui_TaskFeaturePick* ui;