]> vaikene.ee Git - evaf/blobdiff - src/libs/Common/globals.cpp
Mac OS changes and switched to c++11.
[evaf] / src / libs / Common / globals.cpp
index 02aedd84d37a26a93ee8683b85213c1e8da2fe3a..6814648532b70058db4362d241713e14a629c8a7 100644 (file)
@@ -3,7 +3,7 @@
  * @brief Global constants and macros for eVaf
  * @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.
  *
@@ -24,6 +24,7 @@
 #include "logger.h"
 #include "version.h"
 #include "ilogger.h"
+#include "iregistry.h"
 
 #include <QCoreApplication>
 
@@ -32,7 +33,7 @@
 
 bool eVaf::Common::init()
 {
-    if (QCoreApplication::instance() == 0) {
+    if (QCoreApplication::instance() == nullptr) {
         EVAF_FATAL_ERROR("QApplication is not instantiated");
         return false;
     }
@@ -47,12 +48,6 @@ bool eVaf::Common::init()
         if (!app->init())
             return false;
     }
-    eVaf::Common::Internal::Logger * logger =
-            qobject_cast<eVaf::Common::Internal::Logger *>(eVaf::Common::iLogger::instance());
-    if (logger) {
-        if (!logger->init())
-            return false;
-    }
     eVaf::Common::Internal::Config * config =
             qobject_cast<eVaf::Common::Internal::Config *>(eVaf::Common::iConfig::instance());
     if (config) {
@@ -65,8 +60,26 @@ bool eVaf::Common::init()
         if (!prop->init())
             return false;
     }
+    eVaf::Common::Internal::Logger * logger =
+            qobject_cast<eVaf::Common::Internal::Logger *>(eVaf::Common::iLogger::instance());
+    if (logger) {
+        if (!logger->init())
+            return false;
+    }
 
     EVAF_INFO("%s-Globals initialized", VER_MODULE_NAME_STR);
 
     return true;
 }
+
+void eVaf::Common::done()
+{
+    EVAF_INFO("Finalizing %s-Globals", VER_MODULE_NAME_STR);
+
+    //eVaf::Common::Internal::Logger::destroyInstance();
+    eVaf::Common::Internal::Prop::destroyInstance();
+    eVaf::Common::Internal::Config::destroyInstance();
+    eVaf::Common::Internal::App::destroyInstance();
+
+    EVAF_INFO("%s-Globals finalized", VER_MODULE_NAME_STR);
+}