]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't delete wxTaskBarIcon in wxMSW wxNotificationMessage if we don't own it.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 11 Oct 2011 17:08:02 +0000 (17:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 11 Oct 2011 17:08:02 +0000 (17:08 +0000)
wxNotificationMessage can be associated with an existing wxTaskBarIcon under
wxMSW instead of creating its own one internally and in this case the icon
must not be deleted when the notification is hidden but it was always
destroyed unconditionally by wxNotificationIconEvtHandler created by
wxAutoNotifMsgImpl.

Fix this by only creating this helper event handler if we do own the icon.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69379 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/notifmsg.cpp

index a864e76371331641f192218476d7c808ebe2834b..0b43293b4f87e2bb554e8b548858726375139379 100644 (file)
@@ -134,11 +134,6 @@ public:
 
     // can't close automatic notification [currently]
     virtual bool DoClose() { return false; }
-
-private:
-    // custom event handler connected to m_icon which will receive the icon
-    // close event and delete it and itself when it happens
-    wxEvtHandler * const m_iconEvtHandler;
 };
 
 // implementation for manually closed notifications
@@ -356,9 +351,14 @@ bool wxManualNotifMsgImpl::DoClose()
 // ----------------------------------------------------------------------------
 
 wxAutoNotifMsgImpl::wxAutoNotifMsgImpl(wxWindow *win)
-                  : wxBalloonNotifMsgImpl(win),
-                    m_iconEvtHandler(new wxNotificationIconEvtHandler(m_icon))
+                  : wxBalloonNotifMsgImpl(win)
 {
+    if ( m_ownsIcon )
+    {
+        // This object will self-destruct and also delete the icon when the
+        // notification is hidden.
+        new wxNotificationIconEvtHandler(m_icon);
+    }
 }
 
 bool