Fix inconsistencies if currently edited object is not in active document
This commit is contained in:
parent
715f98d1f3
commit
b5505d00cf
|
@ -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<DocumentObjectItem*>(item)->object())->doubleClicked())
|
||||
DocumentObjectItem* objitem = static_cast<DocumentObjectItem*>(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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
|
||||
protected:
|
||||
ViewProviderSketch *sketchView;
|
||||
std::string documentName;
|
||||
|
||||
TaskSketcherConstrains *Constraints;
|
||||
TaskSketcherGeneral *General;
|
||||
|
|
Loading…
Reference in New Issue
Block a user