From: Paul Cornett Date: Sun, 11 May 2008 22:45:36 +0000 (+0000) Subject: prevent crash if panel/kicker is killed, bug 1872724 X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3abc7566452fa210285254a2ea04c15fd5653afe prevent crash if panel/kicker is killed, bug 1872724 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/unix/taskbarx11.h b/include/wx/unix/taskbarx11.h index d37c6c712e..f7d8589a13 100644 --- a/include/wx/unix/taskbarx11.h +++ b/include/wx/unix/taskbarx11.h @@ -36,6 +36,9 @@ public: protected: wxTaskBarIconArea *m_iconWnd; +private: + void OnDestroy(wxWindowDestroyEvent&); + DECLARE_DYNAMIC_CLASS(wxTaskBarIcon) }; diff --git a/src/unix/taskbarx11.cpp b/src/unix/taskbarx11.cpp index 06118f3109..55e11e8bdf 100644 --- a/src/unix/taskbarx11.cpp +++ b/src/unix/taskbarx11.cpp @@ -276,6 +276,14 @@ bool wxTaskBarIcon::IsIconInstalled() const return m_iconWnd != NULL; } +// Destroy event from wxTaskBarIconArea +void wxTaskBarIcon::OnDestroy(wxWindowDestroyEvent&) +{ + // prevent crash if wxTaskBarIconArea is destroyed by something else, + // for example if panel/kicker is killed + m_iconWnd = NULL; +} + bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip) { wxBitmap bmp; @@ -286,6 +294,9 @@ bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip) m_iconWnd = new wxTaskBarIconArea(this, bmp); if (m_iconWnd->IsOk()) { + m_iconWnd->Connect(wxEVT_DESTROY, + wxWindowDestroyEventHandler(wxTaskBarIcon::OnDestroy), + NULL, this); m_iconWnd->Show(); } else