Audacity 3.2.0
Public Member Functions | List of all members
SettingTransaction Class Referencefinal

Extend SettingScope with Commit() which flushes updates in a batch. More...

#include <Prefs.h>

Inheritance diagram for SettingTransaction:
Collaboration diagram for SettingTransaction:

Public Member Functions

bool Commit ()
- Public Member Functions inherited from SettingScope
 SettingScope ()
 ~SettingScope () noexcept
 SettingScope (const SettingScope &)=delete
SettingScopeoperator= (const SettingScope &)=delete

Additional Inherited Members

- Public Types inherited from SettingScope
enum  AddResult { NotAdded , Added , PreviouslyAdded }
- Static Public Member Functions inherited from SettingScope
static AddResult Add (TransactionalSettingBase &setting)
- Protected Attributes inherited from SettingScope
std::set< TransactionalSettingBase * > mPending
bool mCommitted = false

Detailed Description

Extend SettingScope with Commit() which flushes updates in a batch.

Construct one; then write to some Setting objects; then Commit() before destruction to keep the changes, or else the destructor rolls them back.

Flushes preferences on successful commit.

Nesting of SettingTransaction is not supported. No copy or move.

Definition at line 143 of file Prefs.h.

Member Function Documentation

◆ Commit()

bool SettingTransaction::Commit ( )
true if successful

It is unlikely to return false, but in that case an unflushed, partial write of changes to the config file may have happened

Definition at line 288 of file Prefs.cpp.

290 if (sScopes.empty() || sScopes.back() != this)
291 return false;
293 if ( !mCommitted ) {
294 for ( auto pSetting : mPending )
295 if ( !pSetting->Commit() )
296 return false;
298 if (sScopes.size() > 1 || gPrefs->Flush())
299 {
300 mPending.clear();
301 mCommitted = true;
302 return true;
303 }
304 }
306 return false;
FileConfig * gPrefs
Definition: Prefs.cpp:70
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
bool mCommitted
Definition: Prefs.h:133
std::set< TransactionalSettingBase * > mPending
Definition: Prefs.h:132
std::vector< SettingScope * > sScopes
Definition: Prefs.cpp:238

References FileConfig::Flush(), gPrefs, and anonymous_namespace{Prefs.cpp}::sScopes.

Referenced by FindFFmpegLibs().

Here is the call graph for this function:
Here is the caller graph for this function:

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