]> git.saurik.com Git - wxWidgets.git/commitdiff
prevent crash if panel/kicker is killed, bug 1872724
authorPaul Cornett <paulcor@bullseye.com>
Sun, 11 May 2008 22:45:36 +0000 (22:45 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Sun, 11 May 2008 22:45:36 +0000 (22:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/unix/taskbarx11.h
src/unix/taskbarx11.cpp

index d37c6c712e4895f24cf946290d8be4a408f2ec9d..f7d8589a136e0e65dbf4577e2ec49ae9ee2ae286 100644 (file)
@@ -36,6 +36,9 @@ public:
 protected:
     wxTaskBarIconArea *m_iconWnd;
 
+private:
+    void OnDestroy(wxWindowDestroyEvent&);
+
     DECLARE_DYNAMIC_CLASS(wxTaskBarIcon)
 };
 
index 06118f3109a40061e0ecac2c0fa58eed18fe5232..55e11e8bdfb5c23cf308e97a2caf406da3aedc4a 100644 (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