Helper class to lock a transaction from being closed or aborted. More...
#include <AutoTransaction.h>
Public Member Functions | |
| void | activate (bool enable) |
| Activate or deactivate this locker. More... | |
| bool | isActive () const |
| Check if the locker is active. More... | |
| TransactionLocker (bool lock=true) | |
| Constructor. More... | |
| ~TransactionLocker () | |
| Destructor Unlock the transaction is this locker is active. More... | |
Static Public Member Functions | |
| static bool | isLocked () |
| Check if transaction is being locked. More... | |
Friends | |
| class | Application |
Helper class to lock a transaction from being closed or aborted.
The helper class is used to protect some critical transaction from being closed prematurely, e.g. when deleting some object.
| TransactionLocker::TransactionLocker | ( | bool | lock = true | ) |
Constructor.
| lock | whether to activate the lock |
| TransactionLocker::~TransactionLocker | ( | ) |
Destructor Unlock the transaction is this locker is active.
References activate().
| void TransactionLocker::activate | ( | bool | enable | ) |
Activate or deactivate this locker.
| enable | whether to activate the locker |
An internal counter is used to support recursive locker. When activated, the current active transaction cannot be closed or aborted. But the closing call (Application::closeActiveTransaction()) will be remembered, and performed when the internal lock counter reaches zero.
References App::Application::closeActiveTransaction(), and App::GetApplication().
Referenced by ArchBuildingPart.ViewProviderBuildingPart::doubleClicked(), draftviewproviders.view_layer.ViewProviderLayer::setupContextMenu(), and ~TransactionLocker().
| bool App::TransactionLocker::isActive | ( | ) | const |
Check if the locker is active.
|
static |
Check if transaction is being locked.
|
friend |