Add wxModule::AreInitialized()
This internal function will be useful to check if the modules are already initialized, i.e. if the library is in the "steady state" between the end of the initialization and the beginning of the cleanup phases.
This commit is contained in:
@@ -47,7 +47,8 @@ public:
|
||||
static void RegisterModule(wxModule *module);
|
||||
static void RegisterModules();
|
||||
static bool InitializeModules();
|
||||
static void CleanUpModules() { DoCleanUpModules(ms_modules); }
|
||||
static void CleanUpModules();
|
||||
static bool AreInitialized() { return ms_areInitialized; }
|
||||
|
||||
// used by wxObjectLoader when unloading shared libs's
|
||||
|
||||
@@ -56,6 +57,8 @@ public:
|
||||
protected:
|
||||
static wxModuleList ms_modules;
|
||||
|
||||
static bool ms_areInitialized;
|
||||
|
||||
// the function to call from constructor of a deriving class add module
|
||||
// dependency which will be initialized before the module and unloaded
|
||||
// after that
|
||||
|
@@ -25,6 +25,7 @@
|
||||
wxIMPLEMENT_ABSTRACT_CLASS(wxModule, wxObject)
|
||||
|
||||
wxModuleList wxModule::ms_modules;
|
||||
bool wxModule::ms_areInitialized = false;
|
||||
|
||||
void wxModule::RegisterModule(wxModule* module)
|
||||
{
|
||||
@@ -178,9 +179,18 @@ bool wxModule::InitializeModules()
|
||||
// remember the real initialisation order
|
||||
ms_modules = initializedModules;
|
||||
|
||||
ms_areInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxModule::CleanUpModules()
|
||||
{
|
||||
DoCleanUpModules(ms_modules);
|
||||
|
||||
ms_areInitialized = false;
|
||||
}
|
||||
|
||||
// Clean up all currently initialized modules
|
||||
void wxModule::DoCleanUpModules(const wxModuleList& modules)
|
||||
{
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include "wx/module.h"
|
||||
#include "wx/wxcrt.h" // for wxStrcat()
|
||||
|
||||
static bool gs_wasInitialized = wxModule::AreInitialized();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test classes derived from wxModule
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -89,6 +91,12 @@ ModuleD::ModuleD()
|
||||
// tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("wxModule::Initialized", "[module]")
|
||||
{
|
||||
CHECK( !gs_wasInitialized );
|
||||
CHECK( wxModule::AreInitialized() );
|
||||
}
|
||||
|
||||
TEST_CASE("wxModule::LoadOrder", "[module]")
|
||||
{
|
||||
// module D is the only one with no dependencies and so should load as first (and so on):
|
||||
|
Reference in New Issue
Block a user