Gui: fix missing property editor transaction closing

The problem happens when refreshing property editor while editing.
This commit is contained in:
Zheng, Lei
2020-01-22 17:11:50 +08:00
committed by WandererFan
parent 3364911d6d
commit 24d935096d
2 changed files with 13 additions and 13 deletions

View File

@@ -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())

View File

@@ -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;