Browse Source

Uninitialize logger before exiting

_Might_ fix some issues with PMP crashing in the logger on exit.

One observed problem was that the logger thread was still doing
something while parts of the stdlib were being destroyed (?), so it
would be good to terminate the logger's thread pool.
Vincent Lang 8 năm trước cách đây
mục cha
commit
cf0433c908
4 tập tin đã thay đổi với 11 bổ sung0 xóa
  1. 2 0
      src/main.cpp
  2. 1 0
      src/tools/helper/HelperMain.cpp
  3. 7 0
      src/utils/Log.cpp
  4. 1 0
      src/utils/Log.h

+ 2 - 0
src/main.cpp

@@ -210,6 +210,7 @@ int main(int argc, char *argv[])
     delete uniqueApp;
     Globals::EngineDestroy();
 
+    Log::Uninit();
     return ret;
   }
   catch (FatalException& e)
@@ -222,6 +223,7 @@ int main(int argc, char *argv[])
 
     errApp.exec();
 
+    Log::Uninit();
     return 1;
   }
 }

+ 1 - 0
src/tools/helper/HelperMain.cpp

@@ -67,5 +67,6 @@ int main(int argc, char** argv)
 
   delete helperObject;
 
+  Logger::destroyInstance();
   return EXIT_SUCCESS;
 }

+ 7 - 0
src/utils/Log.cpp

@@ -116,3 +116,10 @@ void Log::Init()
   QLOG_INFO() << qPrintable(QString("  Running on: %1 [%2] arch %3").arg(QSysInfo::prettyProductName()).arg(QSysInfo::kernelVersion()).arg(QSysInfo::currentCpuArchitecture()));
   QLOG_INFO() << "  Qt Version:" << QT_VERSION_STR << qPrintable(QString("[%1]").arg(QSysInfo::buildAbi()));
 }
+
+/////////////////////////////////////////////////////////////////////////////////////////
+void Log::Uninit()
+{
+  qInstallMessageHandler(0);
+  Logger::destroyInstance();
+}

+ 1 - 0
src/utils/Log.h

@@ -10,6 +10,7 @@
 namespace Log
 {
   void Init();
+  void Uninit();
   void UpdateLogLevel();
   void CensorAuthTokens(QString& msg);
 }