mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-10 13:54:23 +00:00
Use QAtomicInt to guarantee cleanup() is only executed once
This commit is contained in:
parent
e4c0da4ed4
commit
e2a090f03f
@ -33,6 +33,7 @@
|
|||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QAtomicInt>
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#include "gui/guiiconprovider.h"
|
#include "gui/guiiconprovider.h"
|
||||||
@ -548,11 +549,9 @@ void Application::cleanup()
|
|||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// cleanup() can be called multiple times during shutdown. We only need it once.
|
// cleanup() can be called multiple times during shutdown. We only need it once.
|
||||||
static bool alreadyDone = false;
|
static QAtomicInt alreadyDone;
|
||||||
|
if (!alreadyDone.testAndSetAcquire(0, 1))
|
||||||
if (alreadyDone)
|
|
||||||
return;
|
return;
|
||||||
alreadyDone = true;
|
|
||||||
#endif // Q_OS_WIN
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
// Hide the window and not leave it on screen as
|
// Hide the window and not leave it on screen as
|
||||||
@ -595,6 +594,7 @@ void Application::cleanup()
|
|||||||
delete m_fileLogger;
|
delete m_fileLogger;
|
||||||
Logger::freeInstance();
|
Logger::freeInstance();
|
||||||
IconProvider::freeInstance();
|
IconProvider::freeInstance();
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
typedef BOOL (WINAPI *PSHUTDOWNBRDESTROY)(HWND);
|
typedef BOOL (WINAPI *PSHUTDOWNBRDESTROY)(HWND);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user