diff --git a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp index c5cc6f113..2f97d3161 100644 --- a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp @@ -32,6 +32,7 @@ #include #include "TaskFeatureParameters.h" +#include "TaskSketchBasedParameters.h" using namespace PartDesignGui; using namespace Gui; @@ -107,6 +108,15 @@ bool TaskDlgFeatureParameters::accept() { throw Base::Exception(vp->getObject()->getStatusString()); } + // detach the task panel from the selection to avoid to invoke + // eventually onAddSelection when the selection changes + std::vector subwidgets = getDialogContent(); + for (auto it : subwidgets) { + TaskSketchBasedParameters* param = qobject_cast(it); + if (param) + param->detachSelection(); + } + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); Gui::Command::commitCommand(); } catch (const Base::Exception& e) { @@ -128,6 +138,15 @@ bool TaskDlgFeatureParameters::reject() // (at least in the body case) App::DocumentObject* previous = feature->getBaseObject(/* silent = */ true ); + // detach the task panel from the selection to avoid to invoke + // eventually onAddSelection when the selection changes + std::vector subwidgets = getDialogContent(); + for (auto it : subwidgets) { + TaskSketchBasedParameters* param = qobject_cast(it); + if (param) + param->detachSelection(); + } + // roll back the done things Gui::Command::abortCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index 236149446..3f2607c21 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -71,7 +71,7 @@ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChan PartDesign::ProfileBased* pcSketchBased = static_cast(vp->getObject()); App::DocumentObject* selObj = pcSketchBased->getDocument()->getObject(msg.pObjectName); if (selObj == pcSketchBased) - return QString::fromLatin1(""); + return QString(); std::string subname = msg.pSubName; QString refStr; @@ -79,7 +79,7 @@ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChan if (PartDesign::Feature::isDatum(selObj)) { subname = ""; refStr = QString::fromLatin1(selObj->getNameInDocument()); - } else { + } else if (subname.size() > 4) { int faceId = std::atoi(&subname[4]); refStr = QString::fromLatin1(selObj->getNameInDocument()) + QString::fromLatin1(":") + QObject::tr("Face") + QString::number(faceId); } @@ -178,7 +178,7 @@ QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QS QString o = obj.left(obj.indexOf(QString::fromLatin1(":"))); if (o == tr("No face selected")) - return QString::fromLatin1(""); + return QString(); else return QString::fromLatin1("(App.activeDocument().") + o + QString::fromLatin1(", [\"") + sub + QString::fromLatin1("\"])"); diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 7783b1816..d6fa1302d 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -144,9 +144,9 @@ void ViewProvider::unsetEdit(int ModNum) if (ModNum == ViewProvider::Default) { // when pressing ESC make sure to close the dialog - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); + PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); Gui::Control().closeDialog(); - if ((activeBody != NULL) && (oldTip != NULL)) { + if ((activeBody != NULL) && (oldTip != NULL)) { Gui::Selection().clearSelection(); Gui::Selection().addSelection(oldTip->getDocument()->getName(), oldTip->getNameInDocument()); Gui::Command::doCommand(Gui::Command::Gui,"FreeCADGui.runCommand('PartDesign_MoveTip')");