From 60e018e6667954ae587884be1f1ebc386d39b228 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Tue, 24 Mar 2020 09:56:45 +0800 Subject: [PATCH] Gui: improve transaction handling in PropertyEditor --- src/Gui/propertyeditor/PropertyEditor.cpp | 10 ++++++---- src/Gui/propertyeditor/PropertyEditor.h | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index e839aedf4b..6423753446 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -225,7 +225,7 @@ void PropertyEditor::setupTransaction(const QModelIndex &index) { str << prop->getName(); if(items.size()>1) str << "..."; - app.setActiveTransaction(str.str().c_str()); + transactionID = app.setActiveTransaction(str.str().c_str()); FC_LOG("editor transaction " << app.getActiveTransaction()); } @@ -249,8 +249,11 @@ void PropertyEditor::closeTransaction() doc->recompute(); } } - App::GetApplication().closeActiveTransaction(); } + + int tid = 0; + if(App::GetApplication().getActiveTransaction(&tid) && tid == transactionID) + App::GetApplication().closeActiveTransaction(); } void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEditHint hint) @@ -325,8 +328,7 @@ void PropertyEditor::buildUp(PropertyModel::PropertyList &&props, bool checkDocu return; } - if(this->state() == EditingState) - closeTransaction(); + closeTransaction(); QModelIndex index = this->currentIndex(); QStringList propertyPath = propertyModel->propertyPathFromIndex(index); diff --git a/src/Gui/propertyeditor/PropertyEditor.h b/src/Gui/propertyeditor/PropertyEditor.h index a41087b0fe..70df5b2128 100644 --- a/src/Gui/propertyeditor/PropertyEditor.h +++ b/src/Gui/propertyeditor/PropertyEditor.h @@ -118,11 +118,13 @@ private: bool autoupdate; bool committing; bool delaybuild; + bool binding; + + int transactionID = 0; + QColor groupColor; QBrush background; - bool binding; - friend class Gui::PropertyView; };