Skip to content

Commit

Permalink
Windows QPA: Move the code installing the filter for WM_TASKBARCREATED
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
FriedemannKleint committed Jan 24, 2019
1 parent 4aa0bcf commit c154766
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c154766

Please sign in to comment.