From: Vadim Zeitlin Date: Tue, 11 Oct 2011 17:08:02 +0000 (+0000) Subject: Don't delete wxTaskBarIcon in wxMSW wxNotificationMessage if we don't own it. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4dd8339b2a1a269284096e6bbaa9b6646774650e Don't delete wxTaskBarIcon in wxMSW wxNotificationMessage if we don't own it. 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 --- diff --git a/src/msw/notifmsg.cpp b/src/msw/notifmsg.cpp index a864e76371..0b43293b4f 100644 --- a/src/msw/notifmsg.cpp +++ b/src/msw/notifmsg.cpp @@ -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