resolve problem with static initialisation order

...uncovered by the better checks of the new DependencyFactory!
This commit is contained in:
Fischlurch 2013-10-20 03:21:24 +02:00
parent 0ea37402d2
commit d43a4c2c86
2 changed files with 11 additions and 5 deletions

View file

@ -56,6 +56,10 @@ namespace lumiera {
using util::isnil;
using lib::Literal;
/** storage and setup for the single system-wide config facade instance */
lib::Depend<Config> Config::instance;
namespace {
@ -72,10 +76,6 @@ namespace lumiera {
/** storage for the single system-wide config facade instance */
lib::Depend<Config> Config::instance;
Config::Config ()
{
string extendedConfigSearchPath = AppState::instance().fetchSetupValue (KEY_CONFIG_PATH);

View file

@ -91,7 +91,13 @@ namespace lib {
void*
buildInstance()
{
REQUIRE (ctorFunction_);
if (!ctorFunction_)
throw error::Fatal ("lib::Depend: attempt to retrieve a service object prior to initialisation "
"of the DependencyFactory. Typically, this happens due to a misconfiguration "
"regarding static initialisation order. When lib::Depend<TY> is placed into "
"a class static variable, then the definition and initialisation of that "
"variable must happen prior to the call which caused this exception."
,error::LUMIERA_ERROR_LIFECYCLE);
return ctorFunction_();
}