From c154766630db37dc7d6f8090609d2d1a5076a733 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 23 Jan 2019 08:38:08 +0100 Subject: Windows QPA: Move the code installing the filter for WM_TASKBARCREATED Previously, the code was in the constructor, where hwnd was 0 and ChangeWindowMessageFilterEx() failed. Move it into QWindowsSystemTrayIcon::ensureInstalled() after the creation of the message window. Change-Id: Iff4c6d6d6b11bdcace7514ad421c96c94e52bbba Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowssystemtrayicon.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index 2b728338ae..b738007f0e 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -183,12 +183,6 @@ static inline HWND createTrayIconMessageWindow() QWindowsSystemTrayIcon::QWindowsSystemTrayIcon() { - // For restoring the tray icon after explorer crashes - if (!MYWM_TASKBARCREATED) - MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated"); - // Allow the WM_TASKBARCREATED message through the UIPI filter - ChangeWindowMessageFilterEx(m_hwnd, MYWM_TASKBARCREATED, MSGFLT_ALLOW, 0); - qCDebug(lcQpaTrayIcon) << __FUNCTION__ << this << "MYWM_TASKBARCREATED=" << MYWM_TASKBARCREATED; } QWindowsSystemTrayIcon::~QWindowsSystemTrayIcon() @@ -320,6 +314,13 @@ bool QWindowsSystemTrayIcon::ensureInstalled() m_hwnd = createTrayIconMessageWindow(); if (Q_UNLIKELY(m_hwnd == nullptr)) return false; + // For restoring the tray icon after explorer crashes + if (!MYWM_TASKBARCREATED) + MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated"); + // Allow the WM_TASKBARCREATED message through the UIPI filter + ChangeWindowMessageFilterEx(m_hwnd, MYWM_TASKBARCREATED, MSGFLT_ALLOW, nullptr); + qCDebug(lcQpaTrayIcon) << __FUNCTION__ << this << "MYWM_TASKBARCREATED=" << MYWM_TASKBARCREATED; + QWindowsHwndSystemTrayIconEntry entry{m_hwnd, this}; hwndTrayIconEntries()->append(entry); sendTrayMessage(NIM_ADD); -- cgit v1.2.3