prevent crash if panel/kicker is killed, bug 1872724

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2008-05-11 22:45:36 +00:00
parent da6deee1f7
commit fada2f46e0
2 changed files with 14 additions and 0 deletions

View File

@@ -36,6 +36,9 @@ public:
protected:
wxTaskBarIconArea *m_iconWnd;
private:
void OnDestroy(wxWindowDestroyEvent&);
DECLARE_DYNAMIC_CLASS(wxTaskBarIcon)
};

View File

@@ -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