Permalink
Browse files

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.
  • Loading branch information...
criezy committed Jul 6, 2018
1 parent 53cd661 commit c39dcc57a0dd77e5764592c67881de879a435d42
Showing with 27 additions and 0 deletions.
  1. +8 −0 common/system.cpp
  2. +19 −0 common/system.h
@@ -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) {
@@ -190,10 +190,22 @@ class OSystem : Common::NonCopyable {
*/
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.
@@ -204,6 +216,13 @@ class OSystem : Common::NonCopyable {
*/
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.

0 comments on commit c39dcc5

Please sign in to comment.