avoid to create a circular dependency when modifying an existing pad or pocket operation

This commit is contained in:
wmayer 2016-12-28 17:05:20 +01:00
parent cbf717f317
commit 7004081805
3 changed files with 24 additions and 5 deletions

View File

@ -32,6 +32,7 @@
#include <Mod/PartDesign/App/Body.h>
#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<QWidget*> subwidgets = getDialogContent();
for (auto it : subwidgets) {
TaskSketchBasedParameters* param = qobject_cast<TaskSketchBasedParameters*>(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<QWidget*> subwidgets = getDialogContent();
for (auto it : subwidgets) {
TaskSketchBasedParameters* param = qobject_cast<TaskSketchBasedParameters*>(it);
if (param)
param->detachSelection();
}
// roll back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");

View File

@ -71,7 +71,7 @@ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChan
PartDesign::ProfileBased* pcSketchBased = static_cast<PartDesign::ProfileBased*>(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("\"])");

View File

@ -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<PartDesign::Body*>(PDBODYKEY);
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(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')");