From ac664feae6698eb6ce107ff87391160a48d5d460 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 6 Nov 2012 23:57:06 +0000 Subject: [PATCH] Don't leave orphan taskbar icon window alive if setting it up fails. This fixes a rare bug which happens when we fail to install the task bar icon under MSW for whatever reason (the only known way to reproduce it is to try to do it very quickly after resume from suspend but there might be other situations in which this happens). In this case we must delete the icon as we are not going to get any timeout expiration notifications for it and so if we don't delete it immediately, it would remain alive forever, preventing the application from exiting as it counts as a top level window. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/notifmsg.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/msw/notifmsg.cpp b/src/msw/notifmsg.cpp index 0b43293b4f..b1a91d86d6 100644 --- a/src/msw/notifmsg.cpp +++ b/src/msw/notifmsg.cpp @@ -288,6 +288,23 @@ wxBalloonNotifMsgImpl::DoShow(const wxString& title, int timeout, int flags) { + if ( !m_icon->IsIconInstalled() ) + { + // If we failed to install the icon (which does happen sometimes, + // although only in unusual circumstances, e.g. it happens regularly, + // albeit not constantly, if we're used soon after resume from suspend + // under Windows 7), we should not call ShowBalloon() because it would + // just assert and return and we must delete the icon ourselves because + // otherwise its associated wxTaskBarIconWindow would remain alive + // forever because we're not going to receive a notification about icon + // disappearance from the system if we failed to install it in the + // first place. + delete m_icon; + m_icon = NULL; + + return false; + } + timeout *= 1000; // Windows expresses timeout in milliseconds return m_icon->ShowBalloon(title, message, timeout, flags); -- 2.45.2