From 01921f4f2552e3b2ef65e6c7b8b2b557a5d2922f Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 9 Oct 2013 12:28:25 +0200 Subject: [PATCH] + Fix transaction issues --- src/Gui/Tree.cpp | 9 +++++++++ src/Mod/Raytracing/Gui/ViewProvider.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 63e57a34a..8eaf7b502 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -259,12 +259,21 @@ void TreeWidget::onStartEditing() Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument()); MDIView *view = doc->getActiveView(); if (view) getMainWindow()->setActiveWindow(view); + + // Always open a transaction here doesn't make much sense because: + // - many objects open transactions when really changing some properties + // - this leads to certain inconsistencies with the doubleClicked() method + // So, only the view provider class should decide what to do +#if 0 // 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(); +#else + doc->setEdit(objitem->object(), edit); +#endif } } } diff --git a/src/Mod/Raytracing/Gui/ViewProvider.cpp b/src/Mod/Raytracing/Gui/ViewProvider.cpp index c903e63fe..998174a17 100644 --- a/src/Mod/Raytracing/Gui/ViewProvider.cpp +++ b/src/Mod/Raytracing/Gui/ViewProvider.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -90,8 +91,12 @@ bool ViewProviderLux::setEdit(int ModNum) bool ok; QString file = QInputDialog::getItem(Gui::getMainWindow(), tr("Template"), tr("Select a template"), items, current, false, &ok); if (ok) { + App::Document* doc = getObject()->getDocument(); + doc->openTransaction("Edit Lux project"); QString fn = QString::fromAscii("%1%2.lxs").arg(dataDir).arg(file); static_cast(getObject())->Template.setValue((const char*)fn.toUtf8()); + doc->commitTransaction(); + doc->recompute(); } return false; } @@ -158,8 +163,12 @@ bool ViewProviderPovray::setEdit(int ModNum) bool ok; QString file = QInputDialog::getItem(Gui::getMainWindow(), tr("Template"), tr("Select a template"), items, current, false, &ok); if (ok) { + App::Document* doc = getObject()->getDocument(); + doc->openTransaction("Edit Povray project"); QString fn = QString::fromAscii("%1%2.pov").arg(dataDir).arg(file); static_cast(getObject())->Template.setValue((const char*)fn.toUtf8()); + doc->commitTransaction(); + doc->recompute(); } return false; }