X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1dd7badd1ff93e390d6020a0ab5a6c48eca8ebaa..65751a0ee7a4cfaef9f459c29bfd67f5be6d893b:/src/unix/taskbarx11.cpp diff --git a/src/unix/taskbarx11.cpp b/src/unix/taskbarx11.cpp index ab82f80a49..ced3b5e059 100644 --- a/src/unix/taskbarx11.cpp +++ b/src/unix/taskbarx11.cpp @@ -124,7 +124,7 @@ BEGIN_EVENT_TABLE(wxTaskBarIconArea, wxTaskBarIconAreaBase) END_EVENT_TABLE() wxTaskBarIconArea::wxTaskBarIconArea(wxTaskBarIcon *icon, const wxBitmap &bmp) - : wxTaskBarIconAreaBase(), m_icon(icon), m_pos(0,0) + : wxTaskBarIconAreaBase(), m_icon(icon), m_bmp(bmp) { #if defined(__WXGTK20__) && defined(TASKBAR_ICON_AREA_BASE_INCLUDED) m_invokingWindow = icon; @@ -263,7 +263,11 @@ wxTaskBarIcon::wxTaskBarIcon() : m_iconWnd(NULL) wxTaskBarIcon::~wxTaskBarIcon() { if (m_iconWnd) + { + m_iconWnd->Disconnect( + wxEVT_DESTROY, wxObjectEventFunction(NULL), NULL, this); RemoveIcon(); + } } bool wxTaskBarIcon::IsOk() const @@ -276,6 +280,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 +298,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