App::TransactionLocker Class Reference

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
lockwhether 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
enablewhether 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().

◆ isActive()

bool App::TransactionLocker::isActive ( ) const

Check if the locker is active.

◆ isLocked()

bool TransactionLocker::isLocked ( )
static

Check if transaction is being locked.

Friends And Related Function Documentation

◆ Application

friend class Application
friend

The documentation for this class was generated from the following files: