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 |
Detailed Description
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.
Constructor & Destructor Documentation
◆ TransactionLocker()
TransactionLocker::TransactionLocker | ( | bool | lock = true | ) |
Constructor.
- Parameters
-
lock whether to activate the lock
◆ ~TransactionLocker()
TransactionLocker::~TransactionLocker | ( | ) |
Destructor Unlock the transaction is this locker is active.
References activate().
Member Function Documentation
◆ activate()
void TransactionLocker::activate | ( | bool | enable | ) |
Activate or deactivate this locker.
- Parameters
-
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(), DraftLayer.ViewProviderLayer::setupContextMenu(), and ~TransactionLocker().
◆ isActive()
bool App::TransactionLocker::isActive | ( | ) | const |
Check if the locker is active.
◆ isLocked()
|
static |
Check if transaction is being locked.
Friends And Related Function Documentation
◆ Application
|
friend |
The documentation for this class was generated from the following files:
- src/App/AutoTransaction.h
- src/App/AutoTransaction.cpp