Windows: Avoid triggering QPlatformWindow creation when setting app badge

Calling QWindow::winId() will create the platform window if it hasn't
been created yet, which is not what we want.

Change-Id: I9d4ecb863f961fd3cef6d13e27bf175bf55eabcf
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Tor Arne Vestbø 2022-12-05 15:21:06 +01:00
parent 8eab4e4850
commit a62f49e736

View File

@ -773,6 +773,8 @@ void QWindowsIntegration::setApplicationBadge(const QImage &image)
// the other windows will take over in showing the badge. // the other windows will take over in showing the badge.
const auto topLevelWindows = QGuiApplication::topLevelWindows(); const auto topLevelWindows = QGuiApplication::topLevelWindows();
for (auto *topLevelWindow : topLevelWindows) { for (auto *topLevelWindow : topLevelWindows) {
if (!topLevelWindow->handle())
continue;
auto hwnd = reinterpret_cast<HWND>(topLevelWindow->winId()); auto hwnd = reinterpret_cast<HWND>(topLevelWindow->winId());
taskbarList->SetOverlayIcon(hwnd, hIcon, L""); taskbarList->SetOverlayIcon(hwnd, hIcon, L"");
} }