Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
- Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532)
- Dev: Refactored code that's responsible for deleting old update files. (#5535)
- 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: Prepared for Qt 6.8 by addressing some deprecations. (#5529)

Expand Down
20 changes: 4 additions & 16 deletions src/util/RenameThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "common/QLogging.hpp"

#include <QOperatingSystemVersion>

#ifdef Q_OS_WIN

# include <Windows.h>
Expand All @@ -12,20 +10,9 @@ namespace chatterino::windows::detail {

void renameThread(HANDLE hThread, const QString &threadName)
{
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // Qt 6 requires Windows 10 1809
// Windows 10, version 1607
constexpr QOperatingSystemVersion minVersion{
QOperatingSystemVersion::Windows,
10,
0,
14393,
};
// minVersion is excluded, because it has some additional requirements
if (QOperatingSystemVersion::current() <= minVersion)
{
return;
}
# endif
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// SetThreadDescription requires Windows 10, version 1607
// Qt 6 requires Windows 10 1809

auto hr = SetThreadDescription(hThread, threadName.toStdWString().c_str());
if (!SUCCEEDED(hr))
Expand All @@ -34,6 +21,7 @@ void renameThread(HANDLE hThread, const QString &threadName)
<< "Failed to set thread description, hresult=0x"
<< QString::number(hr, 16);
}
# endif
}

} // namespace chatterino::windows::detail
Expand Down
Loading