X-Git-Url: https://vaikene.ee/gitweb/gitweb.cgi?p=evaf;a=blobdiff_plain;f=src%2Flibs%2FCommon%2Fconfig.cpp;fp=src%2Flibs%2FCommon%2Fconfig.cpp;h=7ddc61ea9829b4270203fabfba61d143b0505abb;hp=5303bb86e8747ea84b3e55fb21b0bea389b9e976;hb=de270ece1b764b19968e14420f538321f1c06b15;hpb=cf45ef016ce162419f74f9165c4267a184714956 diff --git a/src/libs/Common/config.cpp b/src/libs/Common/config.cpp index 5303bb8..7ddc61e 100644 --- a/src/libs/Common/config.cpp +++ b/src/libs/Common/config.cpp @@ -3,7 +3,7 @@ * @brief eVaf configuration interface implementation * @author Enar Vaikene * - * Copyright (c) 2011 Enar Vaikene + * Copyright (c) 2011-2019 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * @@ -30,10 +30,18 @@ using namespace eVaf::Common; +namespace +{ + static Internal::Config * singleton = nullptr; +} + iConfig * iConfig::instance() { - static Internal::Config singleton; - return singleton._interface(); + if (nullptr == singleton) + { + singleton = new Internal::Config; + } + return singleton->_interface(); } @@ -41,6 +49,15 @@ iConfig * iConfig::instance() using namespace eVaf::Common::Internal; +void Config::destroyInstance() +{ + if (nullptr != singleton) + { + delete singleton; + singleton = nullptr; + } +} + Config::Config() : iConfig() { @@ -48,11 +65,14 @@ Config::Config() // Register the iConfig interface iRegistry::instance()->registerInterface("iConfig", this); + + EVAF_INFO("%s-Config created", VER_MODULE_NAME_STR); } Config::~Config() { done(); + EVAF_INFO("%s-Config destroyed", VER_MODULE_NAME_STR); } iConfig * Config::_interface() const @@ -101,7 +121,7 @@ QVariant Config::getValue(QString const & paramName, QVariant const & defaultVal if (file.isEmpty() || file == "*") file = iApp::instance()->name(); - IniFile * ini = 0; + IniFile * ini = nullptr; // Is this INI file already opened? QHash::const_iterator it = mIniFiles.constFind(file); @@ -176,7 +196,7 @@ bool Config::writeValue(QString const & paramName, QVariant const & value) if (file.isEmpty() || file == "*") file = iApp::instance()->name(); - IniFile * ini = 0; + IniFile * ini = nullptr; // Is this INI file already opened? QHash::const_iterator it = mIniFiles.constFind(file);