diff options
author | Thierry Crozat | 2018-07-07 00:58:52 +0100 |
---|---|---|
committer | Thierry Crozat | 2018-10-14 21:25:02 +0100 |
commit | c39dcc57a0dd77e5764592c67881de879a435d42 (patch) | |
tree | b66492aa4952d5fba8b2cd117bb7e90ae7e8844c /common | |
parent | 53cd6616c958e4a50644254688aea222177f2ae2 (diff) | |
download | scummvm-rg350-c39dcc57a0dd77e5764592c67881de879a435d42.tar.gz scummvm-rg350-c39dcc57a0dd77e5764592c67881de879a435d42.tar.bz2 scummvm-rg350-c39dcc57a0dd77e5764592c67881de879a435d42.zip |
OSYSTEM: Add backendInitialized() function
Some feature, such as mutexes, are only available once the backend
has been initialized. This new function can be used to avoid using
those feature too early or too late.
Diffstat (limited to 'common')
-rw-r--r-- | common/system.cpp | 8 | ||||
-rw-r--r-- | common/system.h | 19 |
2 files changed, 27 insertions, 0 deletions
diff --git a/common/system.cpp b/common/system.cpp index 51f41ecf1d..97c8f8520b 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -49,6 +49,7 @@ OSystem::OSystem() { _updateManager = nullptr; #endif _fsFactory = nullptr; + _backendInitialized = false; } OSystem::~OSystem() { @@ -98,6 +99,13 @@ void OSystem::initBackend() { // set it. // if (!_fsFactory) // error("Backend failed to instantiate fs factory"); + + _backendInitialized = true; +} + +void OSystem::destroy() { + _backendInitialized = false; + delete this; } bool OSystem::setGraphicsMode(const char *name) { diff --git a/common/system.h b/common/system.h index 7caf73a8a2..405d6a90a8 100644 --- a/common/system.h +++ b/common/system.h @@ -190,11 +190,23 @@ protected: */ FilesystemFactory *_fsFactory; +private: + /** + * Indicate if initBackend() has been called. + */ + bool _backendInitialized; + //@} public: /** + * + * Destoy this OSystem instance. + */ + void destroy(); + + /** * The following method is called once, from main.cpp, after all * config data (including command line params etc.) are fully loaded. * @@ -205,6 +217,13 @@ public: virtual void initBackend(); /** + * Return false if initBackend() has not yet been called and true otherwise. + * Some functionalities such as mutexes cannot be used until the backend + * is initialized. + */ + bool backendInitialized() const { return _backendInitialized; } + + /** * Allows the backend to perform engine specific init. * Called just before the engine is run. */ |