diff --git a/source/shared_lib/include/util/util.h b/source/shared_lib/include/util/util.h index c932c6de7..192fa1355 100644 --- a/source/shared_lib/include/util/util.h +++ b/source/shared_lib/include/util/util.h @@ -129,6 +129,8 @@ protected: static bool haveSpecialOutputCommandLineOption; static bool curl_global_init_called; + static SystemFlagsType * setupRequiredMembers(); + public: static CURL *curl_handle; @@ -141,7 +143,18 @@ public: ~SystemFlags(); static void init(bool haveSpecialOutputCommandLineOption); - static SystemFlagsType & getSystemSettingType(DebugType type); + //static SystemFlagsType & getSystemSettingType(DebugType type); + inline static SystemFlagsType & getSystemSettingType(DebugType type) { + if(SystemFlags::debugLogFileList == NULL) { + SystemFlagsType *result = setupRequiredMembers(); + if(result != NULL) { + return *result; + } + } + + return (*debugLogFileList)[type]; + } + static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data); static std::string getHTTP(std::string URL,CURL *handle=NULL, int timeOut=-1, CURLcode *savedResult=NULL); static std::string escapeURL(std::string URL, CURL *handle=NULL); diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index 9cefaf8a4..789efc92c 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -213,24 +213,21 @@ void SystemFlags::globalCleanupHTTP() { } } -SystemFlags::SystemFlagsType & SystemFlags::getSystemSettingType(DebugType type) { - if(SystemFlags::debugLogFileList == NULL) { - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); +SystemFlags::SystemFlagsType * SystemFlags::setupRequiredMembers() { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - if(threadLogger == NULL && SystemFlags::SHUTDOWN_PROGRAM_MODE == true) { - //throw megaglest_runtime_error("threadLogger == NULL && SystemFlags::SHUTDOWN_PROGRAM_MODE == true"); - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ERROR threadLogger == NULL && SystemFlags::SHUTDOWN_PROGRAM_MODE == true\n",__FILE__,__FUNCTION__,__LINE__); - //static SystemFlagsType *result = new SystemFlagsType(); - static SystemFlagsType result; - result.enabled = SystemFlags::VERBOSE_MODE_ENABLED; - return result; - } - else { - SystemFlags::init(false); - } + if(threadLogger == NULL && SystemFlags::SHUTDOWN_PROGRAM_MODE == true) { + //throw megaglest_runtime_error("threadLogger == NULL && SystemFlags::SHUTDOWN_PROGRAM_MODE == true"); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ERROR threadLogger == NULL && SystemFlags::SHUTDOWN_PROGRAM_MODE == true\n",__FILE__,__FUNCTION__,__LINE__); + //static SystemFlagsType *result = new SystemFlagsType(); + static SystemFlags::SystemFlagsType result; + result.enabled = SystemFlags::VERBOSE_MODE_ENABLED; + return &result; + } + else { + SystemFlags::init(false); + return NULL; } - - return (*debugLogFileList)[type]; } void SystemFlags::init(bool haveSpecialOutputCommandLineOption) {