The reason is that the rejection routine used by all dialogs is this:
Code: Select all
bool TaskDlgFemConstraint::reject()
{
// roll back the changes
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
return true;
}
In PartDesign they use therefore this routine:
Code: Select all
bool TaskDlgFeatureParameters::reject()
{
PartDesign::Feature* feature = static_cast<PartDesign::Feature*>(vp->getObject());
PartDesign::Body* body = PartDesign::Body::findBodyOf(feature);
// Find out previous feature we won't be able to do it after abort
// (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()");
// if abort command deleted the object make the previous feature visible again
if (!Gui::Application::Instance->getViewProvider(feature)) {
// Make the tip or the previous feature visible again with preference to the previous one
// TODO: ViewProvider::onDelete has the same code. May be this one is excess?
if (previous && Gui::Application::Instance->getViewProvider(previous)) {
Gui::Application::Instance->getViewProvider(previous)->show();
} else if (body != NULL) {
App::DocumentObject* tip = body->Tip.getValue();
if (tip && Gui::Application::Instance->getViewProvider(tip)) {
Gui::Application::Instance->getViewProvider(tip)->show();
}
}
}
return true;
}