From 7d937886503da221d3a7a82b6c6671b029efa286 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 4 Dec 2014 21:45:15 +0100 Subject: [PATCH] Fix crash in the unit tests fixes #7769 --- lib/base/application.cpp | 21 ++++++++++++++------- lib/base/application.hpp | 1 + lib/base/timer.hpp | 8 +++++--- test/test.cpp | 3 +-- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/base/application.cpp b/lib/base/application.cpp index 3df75b5a5..21dce4503 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -108,7 +108,7 @@ void Application::Exit(int rc) logger->Flush(); } - Timer::Uninitialize(); + UninitializeBase(); #ifdef _DEBUG exit(rc); @@ -149,6 +149,18 @@ void Application::InitializeBase(void) #endif /* _WIN32 */ Utility::ExecuteDeferredInitializers(); + + /* make sure the thread pool gets initialized */ + GetTP(); + + Timer::Initialize(); +} + +void Application::UninitializeBase(void) +{ + Timer::Uninitialize(); + + GetTP().Stop(); } /** @@ -316,12 +328,7 @@ mainloop: DynamicObject::StopObjects(); Application::GetInstance()->OnShutdown(); -#ifdef _DEBUG - GetTP().Stop(); - m_ShuttingDown = false; - - Timer::Uninitialize(); -#endif /* _DEBUG */ + UninitializeBase(); } void Application::OnShutdown(void) diff --git a/lib/base/application.hpp b/lib/base/application.hpp index be662297e..8ae7cdd28 100644 --- a/lib/base/application.hpp +++ b/lib/base/application.hpp @@ -43,6 +43,7 @@ public: ~Application(void); static void InitializeBase(void); + static void UninitializeBase(void); static Application::Ptr GetInstance(void); diff --git a/lib/base/timer.hpp b/lib/base/timer.hpp index 8c8550715..34b5eca98 100644 --- a/lib/base/timer.hpp +++ b/lib/base/timer.hpp @@ -52,9 +52,6 @@ public: boost::signals2::signal OnTimerExpired; - static void Initialize(void); - static void Uninitialize(void); - class Holder { public: Holder(Timer *timer) @@ -88,6 +85,11 @@ private: void Call(); static void TimerThreadProc(void); + + static void Initialize(void); + static void Uninitialize(void); + + friend class Application; }; } diff --git a/test/test.cpp b/test/test.cpp index d4fc3d279..fbde0c80d 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -31,12 +31,11 @@ struct InitLibBase InitLibBase(void) { Application::InitializeBase(); - Timer::Initialize(); } ~InitLibBase(void) { - Timer::Uninitialize(); + Application::UninitializeBase(); } }; -- 2.40.0