Gui: improve transaction handling in PropertyEditor

This commit is contained in:
Zheng, Lei
2020-03-24 09:56:45 +08:00
committed by wwmayer
parent f67d960146
commit 60e018e666
2 changed files with 10 additions and 6 deletions

View File

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

View File

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