From d43a4c2c861aaec1b6e34aa5021e6dc894c1b94b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 20 Oct 2013 03:21:24 +0200 Subject: [PATCH] resolve problem with static initialisation order ...uncovered by the better checks of the new DependencyFactory! --- src/common/configfacade.cpp | 8 ++++---- src/lib/dependency-factory.hpp | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/common/configfacade.cpp b/src/common/configfacade.cpp index 1130fe78e..8c8d7b941 100644 --- a/src/common/configfacade.cpp +++ b/src/common/configfacade.cpp @@ -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::instance; + namespace { @@ -72,10 +76,6 @@ namespace lumiera { - /** storage for the single system-wide config facade instance */ - lib::Depend Config::instance; - - Config::Config () { string extendedConfigSearchPath = AppState::instance().fetchSetupValue (KEY_CONFIG_PATH); diff --git a/src/lib/dependency-factory.hpp b/src/lib/dependency-factory.hpp index 26ef30178..d97c9de9f 100644 --- a/src/lib/dependency-factory.hpp +++ b/src/lib/dependency-factory.hpp @@ -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 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_(); }