]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't leave orphan taskbar icon window alive if setting it up fails.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Nov 2012 23:57:06 +0000 (23:57 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Nov 2012 23:57:06 +0000 (23:57 +0000)
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

index 0b43293b4f87e2bb554e8b548858726375139379..b1a91d86d6f333e50e6530b7aed0c87b16857502 100644 (file)
@@ -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);