| 586 | } |
| 587 | |
| 588 | bool Document::_commitTransaction(const bool notify) |
| 589 | { |
| 590 | if (isPerformingTransaction()) { |
| 591 | if (FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) { |
| 592 | FC_WARN("Cannot commit transaction while transacting"); |
| 593 | } |
| 594 | return false; |
| 595 | } |
| 596 | if (d->committing) { |
| 597 | // for a recursive call return without printing a warning |
| 598 | return false; |
| 599 | } |
| 600 | |
| 601 | d->bookedTransaction = 0; |
| 602 | bool committed = false; |
| 603 | if (d->activeUndoTransaction) { |
| 604 | { |
| 605 | Base::FlagToggler<> flag(d->committing); |
| 606 | Application::TransactionSignaller signaller(false, true); |
| 607 | const int id = d->activeUndoTransaction->getID(); |
| 608 | |
| 609 | mUndoTransactions.push_back(d->activeUndoTransaction); |
| 610 | d->activeUndoTransaction = nullptr; |
| 611 | |
| 612 | // check the stack for the limits |
| 613 | if (mUndoTransactions.size() > d->UndoMaxStackSize) { |
| 614 | mUndoMap.erase(mUndoTransactions.front()->getID()); |
| 615 | delete mUndoTransactions.front(); |
| 616 | mUndoTransactions.pop_front(); |
| 617 | } |
| 618 | signalCommitTransaction(*this); |
| 619 | |
| 620 | // commitTransaction() may call again _commitTransaction() |
| 621 | if (notify) { |
| 622 | GetApplication().commitTransaction(id); |
| 623 | } |
| 624 | } |
| 625 | committed = true; |
| 626 | } |
| 627 | if (committed) { |
| 628 | signalBecameStable(*this); |
| 629 | } |
| 630 | return true; |
| 631 | } |
| 632 | |
| 633 | void Document::abortTransaction() const |
| 634 | { |
no test coverage detected