From 24d935096d96b1516c2746ed17cdd8cd21b9c81d Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 22 Jan 2020 17:11:50 +0800 Subject: [PATCH] Gui: fix missing property editor transaction closing The problem happens when refreshing property editor while editing. --- src/Gui/propertyeditor/PropertyEditor.cpp | 25 +++++++++++------------ src/Gui/propertyeditor/PropertyEditor.h | 1 + 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index 0167c3cf32..e839aedf4b 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -159,16 +159,7 @@ void PropertyEditor::editorDestroyed (QObject * editor) // When editing expression through context menu, the editor (ExpLineEditor) // deletes itself when finished, so it won't trigger closeEditor signal. We // must handle it here to perform auto update. - if (autoupdate) { - App::Document* doc = App::GetApplication().getActiveDocument(); - if (doc) { - if (!doc->isTransactionEmpty()) { - if (doc->isTouched()) - doc->recompute(); - } - } - App::GetApplication().closeActiveTransaction(); - } + closeTransaction(); } void PropertyEditor::currentChanged ( const QModelIndex & current, const QModelIndex & previous ) @@ -246,10 +237,8 @@ void PropertyEditor::onItemActivated ( const QModelIndex & index ) setupTransaction(index); } -void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEditHint hint) +void PropertyEditor::closeTransaction() { - QTreeView::closeEditor(editor, hint); - if (autoupdate) { App::Document* doc = App::GetApplication().getActiveDocument(); if (doc) { @@ -262,6 +251,13 @@ void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEd } App::GetApplication().closeActiveTransaction(); } +} + +void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEditHint hint) +{ + QTreeView::closeEditor(editor, hint); + + closeTransaction(); QModelIndex indexSaved = currentIndex(); FC_LOG("index saved " << indexSaved.row() << ", " << indexSaved.column()); @@ -329,6 +325,9 @@ void PropertyEditor::buildUp(PropertyModel::PropertyList &&props, bool checkDocu return; } + if(this->state() == EditingState) + closeTransaction(); + QModelIndex index = this->currentIndex(); QStringList propertyPath = propertyModel->propertyPathFromIndex(index); if (!propertyPath.isEmpty()) diff --git a/src/Gui/propertyeditor/PropertyEditor.h b/src/Gui/propertyeditor/PropertyEditor.h index 775a04b625..a41087b0fe 100644 --- a/src/Gui/propertyeditor/PropertyEditor.h +++ b/src/Gui/propertyeditor/PropertyEditor.h @@ -107,6 +107,7 @@ private: void setEditorMode(const QModelIndex & parent, int start, int end); void updateItemEditor(bool enable, int column, const QModelIndex& parent); void setupTransaction(const QModelIndex &); + void closeTransaction(); private: PropertyItemDelegate *delegate;