fix: only attempt to rename threads on Qt6 versions (#5544)

This commit is contained in:
pajlada 2024-08-12 22:56:40 +02:00 committed by GitHub
parent 832e70e314
commit e840328de7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 17 deletions

View file

@ -61,7 +61,7 @@
- Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532) - Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532)
- Dev: Refactored code that's responsible for deleting old update files. (#5535) - Dev: Refactored code that's responsible for deleting old update files. (#5535)
- Dev: Cleanly exit on shutdown. (#5537) - Dev: Cleanly exit on shutdown. (#5537)
- Dev: Renamed threads created by Chatterino on Linux and Windows. (#5538, #5539) - Dev: Renamed threads created by Chatterino on Linux and Windows. (#5538, #5539, #5544)
- Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527) - Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
- Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529) - Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529)

View file

@ -2,8 +2,6 @@
#include "common/QLogging.hpp" #include "common/QLogging.hpp"
#include <QOperatingSystemVersion>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
# include <Windows.h> # include <Windows.h>
@ -12,20 +10,9 @@ namespace chatterino::windows::detail {
void renameThread(HANDLE hThread, const QString &threadName) void renameThread(HANDLE hThread, const QString &threadName)
{ {
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // Qt 6 requires Windows 10 1809 # if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// Windows 10, version 1607 // SetThreadDescription requires Windows 10, version 1607
constexpr QOperatingSystemVersion minVersion{ // Qt 6 requires Windows 10 1809
QOperatingSystemVersion::Windows,
10,
0,
14393,
};
// minVersion is excluded, because it has some additional requirements
if (QOperatingSystemVersion::current() <= minVersion)
{
return;
}
# endif
auto hr = SetThreadDescription(hThread, threadName.toStdWString().c_str()); auto hr = SetThreadDescription(hThread, threadName.toStdWString().c_str());
if (!SUCCEEDED(hr)) if (!SUCCEEDED(hr))
@ -34,6 +21,7 @@ void renameThread(HANDLE hThread, const QString &threadName)
<< "Failed to set thread description, hresult=0x" << "Failed to set thread description, hresult=0x"
<< QString::number(hr, 16); << QString::number(hr, 16);
} }
# endif
} }
} // namespace chatterino::windows::detail } // namespace chatterino::windows::detail