add method to check if an open transaction is empty
This is needed to avoid to incorrectly abort a transaction if a recompute was done between opening and closing an editor in the property view
This commit is contained in:
@@ -1029,6 +1029,15 @@ bool Document::hasPendingTransaction() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Document::isTransactionEmpty() const
|
||||
{
|
||||
if (d->activeUndoTransaction) {
|
||||
return d->activeUndoTransaction->isEmpty();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Document::clearUndos()
|
||||
{
|
||||
if (d->activeUndoTransaction)
|
||||
|
||||
@@ -303,6 +303,9 @@ public:
|
||||
void abortTransaction();
|
||||
/// Check if a transaction is open
|
||||
bool hasPendingTransaction() const;
|
||||
/// Check if a transaction is open and its list is empty.
|
||||
/// If no transaction is open true is returned.
|
||||
bool isTransactionEmpty() const;
|
||||
/// Set the Undo limit in Byte!
|
||||
void setUndoLimit(unsigned int UndoMemSize=0);
|
||||
/// Returns the actual memory consumption of the Undo redo stuff.
|
||||
|
||||
@@ -110,6 +110,11 @@ void Transaction::Restore(Base::XMLReader &/*reader*/)
|
||||
assert(0);
|
||||
}
|
||||
|
||||
bool Transaction::isEmpty() const
|
||||
{
|
||||
return _Objects.empty();
|
||||
}
|
||||
|
||||
int Transaction::getPos(void) const
|
||||
{
|
||||
return iPos;
|
||||
|
||||
@@ -62,6 +62,8 @@ public:
|
||||
/// This method is used to restore properties from an XML document.
|
||||
virtual void Restore(Base::XMLReader &reader);
|
||||
|
||||
/// Returns true if the transaction list is empty; otherwise returns false.
|
||||
bool isEmpty() const;
|
||||
/// get the position in the transaction history
|
||||
int getPos(void) const;
|
||||
/// check if this object is used in a transaction
|
||||
|
||||
@@ -104,9 +104,12 @@ void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEd
|
||||
if (autoupdate) {
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
if (doc) {
|
||||
if (doc->isTouched()) {
|
||||
if (!doc->isTransactionEmpty()) {
|
||||
doc->commitTransaction();
|
||||
doc->recompute();
|
||||
// Between opening and committing a transaction a recompute
|
||||
// could already have been done
|
||||
if (doc->isTouched())
|
||||
doc->recompute();
|
||||
}
|
||||
else {
|
||||
doc->abortTransaction();
|
||||
|
||||
Reference in New Issue
Block a user