From f35dbdfb8b71c321ae41fcdcf0bbfed9069a22f7 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Tue, 21 Jul 2020 13:56:07 +0300 Subject: [PATCH] Fix crash on exit when compiled using MinGW --- src/base/utils/string.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/base/utils/string.cpp b/src/base/utils/string.cpp index 907e66aff..29f6fa480 100644 --- a/src/base/utils/string.cpp +++ b/src/base/utils/string.cpp @@ -35,11 +35,13 @@ #include #include #include -#ifdef Q_OS_MACOS + +#if defined(Q_OS_MACOS) || defined(__MINGW32__) +#define QBT_USES_QTHREADSTORAGE #include #endif -#include "../tristatebool.h" +#include "base/tristatebool.h" namespace { @@ -139,7 +141,7 @@ int Utils::String::naturalCompare(const QString &left, const QString &right, con // provide a single `NaturalCompare` instance for easy use // https://doc.qt.io/qt-5/threads-reentrancy.html if (caseSensitivity == Qt::CaseSensitive) { -#ifdef Q_OS_MACOS // workaround for Apple xcode: https://stackoverflow.com/a/29929949 +#ifdef QBT_USES_QTHREADSTORAGE static QThreadStorage nCmp; if (!nCmp.hasLocalData()) nCmp.setLocalData(NaturalCompare(Qt::CaseSensitive)); @@ -150,7 +152,7 @@ int Utils::String::naturalCompare(const QString &left, const QString &right, con #endif } -#ifdef Q_OS_MACOS +#ifdef QBT_USES_QTHREADSTORAGE static QThreadStorage nCmp; if (!nCmp.hasLocalData()) nCmp.setLocalData(NaturalCompare(Qt::CaseInsensitive));