From 7761a2604a013659ae62044d7aa3c89bc66a266d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 10 Mar 2016 02:00:26 +0800 Subject: [PATCH] Use QAtomicInt to guarantee cleanup() is only executed once --- src/app/application.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index aeee2c7cd..3b1ff7b1a 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #ifndef DISABLE_GUI #include "gui/guiiconprovider.h" @@ -547,11 +548,9 @@ void Application::cleanup() #ifndef DISABLE_GUI #ifdef Q_OS_WIN // cleanup() can be called multiple times during shutdown. We only need it once. - static bool alreadyDone = false; - - if (alreadyDone) + static QAtomicInt alreadyDone; + if (!alreadyDone.testAndSetAcquire(0, 1)) return; - alreadyDone = true; #endif // Q_OS_WIN // Hide the window and not leave it on screen as