diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 9d19c5b63..03ca7cb2f 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -253,6 +253,8 @@ void TreeWidget::onStartEditing() App::DocumentObject* obj = objitem->object()->getObject(); if (!obj) return; Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument()); + MDIView *view = doc->getActiveView(); + if (view) getMainWindow()->setActiveWindow(view); doc->setEdit(objitem->object(), edit); } } @@ -306,7 +308,12 @@ void TreeWidget::mouseDoubleClickEvent (QMouseEvent * event) getMainWindow()->setActiveWindow(view); } else if (item->type() == TreeWidget::ObjectType) { - if (!(static_cast(item)->object())->doubleClicked()) + DocumentObjectItem* objitem = static_cast(item); + App::DocumentObject* obj = objitem->object()->getObject(); + Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument()); + MDIView *view = doc->getActiveView(); + if (view) getMainWindow()->setActiveWindow(view); + if (!objitem->object()->doubleClicked()) QTreeWidget::mouseDoubleClickEvent(event); } } diff --git a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp index eef1b6cf2..e8e2451d8 100644 --- a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp +++ b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp @@ -42,6 +42,7 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView) : TaskDialog(),sketchView(sketchView) { assert(sketchView); + documentName = sketchView->getObject()->getDocument()->getName(); Constraints = new TaskSketcherConstrains(sketchView); General = new TaskSketcherGeneral(sketchView); Messages = new TaskSketcherMessages(sketchView); @@ -76,10 +77,9 @@ bool TaskDlgEditSketch::accept() bool TaskDlgEditSketch::reject() { -// Gui::Command::openCommand("Sketch changed"); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); -// Gui::Command::commitCommand(); + std::string document = documentName; // needed because resetEdit() deletes this instance + Gui::Command::doCommand(Gui::Command::Gui,"Gui.getDocument('%s').resetEdit()", document.c_str()); + Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument('%s').recompute()", document.c_str()); return true; } diff --git a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h index 6dd199704..506bf98d2 100644 --- a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h +++ b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h @@ -65,6 +65,7 @@ public: protected: ViewProviderSketch *sketchView; + std::string documentName; TaskSketcherConstrains *Constraints; TaskSketcherGeneral *General;