// 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
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);
// ----------------------------------------------------------------------------
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