diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp
index 7e8d7b7eb..32c58a4df 100644
--- a/src/Gui/Tree.cpp
+++ b/src/Gui/Tree.cpp
@@ -255,7 +255,12 @@ void TreeWidget::onStartEditing()
Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument());
MDIView *view = doc->getActiveView();
if (view) getMainWindow()->setActiveWindow(view);
- doc->setEdit(objitem->object(), edit);
+ // open a transaction before starting edit mode
+ std::string cmd("Edit ");
+ cmd += obj->Label.getValue();
+ doc->openCommand(cmd.c_str());
+ bool ok = doc->setEdit(objitem->object(), edit);
+ if (!ok) doc->abortCommand();
}
}
}
@@ -268,6 +273,7 @@ void TreeWidget::onFinishEditing()
App::DocumentObject* obj = objitem->object()->getObject();
if (!obj) return;
Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument());
+ doc->commitCommand();
doc->resetEdit();
doc->getDocument()->recompute();
}
diff --git a/src/Mod/Part/Gui/TaskOffset.cpp b/src/Mod/Part/Gui/TaskOffset.cpp
index 5e70d76f1..d288453f3 100644
--- a/src/Mod/Part/Gui/TaskOffset.cpp
+++ b/src/Mod/Part/Gui/TaskOffset.cpp
@@ -67,8 +67,6 @@ public:
OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent)
: d(new Private())
{
- if (!Gui::Command::hasPendingCommand())
- Gui::Command::openCommand("Edit offset");
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
Gui::Application::Instance->runPythonCode("import Part");
diff --git a/src/Mod/Part/Gui/TaskThickness.cpp b/src/Mod/Part/Gui/TaskThickness.cpp
index 1dee783b1..58ae38c4c 100644
--- a/src/Mod/Part/Gui/TaskThickness.cpp
+++ b/src/Mod/Part/Gui/TaskThickness.cpp
@@ -58,8 +58,7 @@ public:
QString text;
std::string selection;
Part::Thickness* thickness;
- bool edit;
- Private() : edit(false)
+ Private()
{
}
~Private()
@@ -91,10 +90,6 @@ public:
ThicknessWidget::ThicknessWidget(Part::Thickness* thickness, QWidget* parent)
: d(new Private())
{
- if (!Gui::Command::hasPendingCommand()) {
- d->edit = true;
- Gui::Command::openCommand("Edit thickness");
- }
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
Gui::Application::Instance->runPythonCode("import Part");
@@ -244,19 +239,22 @@ bool ThicknessWidget::reject()
{
if (d->loop.isRunning())
return false;
- // object has been created right before opening this panel
- if (d->edit == false) {
- App::DocumentObject* source = d->thickness->Faces.getValue();
- if (source){
- Gui::Application::Instance->getViewProvider(source)->show();
- }
- }
+
+ // save this and check if the object is still there after the
+ // transaction is aborted
+ std::string objname = d->thickness->getNameInDocument();
+ App::DocumentObject* source = d->thickness->Faces.getValue();
// roll back the done things
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
Gui::Command::updateActive();
+ // Thickness object was deleted
+ if (source && !source->getDocument()->getObject(objname.c_str())) {
+ Gui::Application::Instance->getViewProvider(source)->show();
+ }
+
return true;
}
diff --git a/src/Mod/Part/Gui/ViewProvider.cpp b/src/Mod/Part/Gui/ViewProvider.cpp
index 609578dcf..60360c671 100644
--- a/src/Mod/Part/Gui/ViewProvider.cpp
+++ b/src/Mod/Part/Gui/ViewProvider.cpp
@@ -81,6 +81,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -107,6 +108,17 @@ ViewProviderPart::ViewProviderPart()
ViewProviderPart::~ViewProviderPart()
{
}
+
+bool ViewProviderPart::doubleClicked(void)
+{
+ std::string Msg("Edit ");
+ Msg += this->pcObject->Label.getValue();
+ Gui::Command::openCommand(Msg.c_str());
+ Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.setEdit('%s',0)",
+ this->pcObject->getNameInDocument());
+ return true;
+}
+
#else
PROPERTY_SOURCE(PartGui::ViewProviderPart, PartGui::ViewProviderPartBase)
diff --git a/src/Mod/Part/Gui/ViewProvider.h b/src/Mod/Part/Gui/ViewProvider.h
index 627ce87da..50b4b8642 100644
--- a/src/Mod/Part/Gui/ViewProvider.h
+++ b/src/Mod/Part/Gui/ViewProvider.h
@@ -156,6 +156,7 @@ public:
ViewProviderPart();
/// destructor
virtual ~ViewProviderPart();
+ virtual bool doubleClicked(void);
};
#else
class PartGuiExport ViewProviderPart : public ViewProviderPartBase
diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp
index 91ec62707..35981da52 100644
--- a/src/Mod/PartDesign/Gui/ViewProvider.cpp
+++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp
@@ -45,8 +45,8 @@ ViewProvider::~ViewProvider()
bool ViewProvider::doubleClicked(void)
{
- std::string Msg("Change ");
- Msg += this->pcObject->getNameInDocument();
+ std::string Msg("Edit ");
+ Msg += this->pcObject->Label.getValue();
Gui::Command::openCommand(Msg.c_str());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument());
return true;