Prevent seg fault for older GTK+
authorJulian Smart <julian@anthemion.co.uk>
Fri, 29 Jun 2007 16:58:58 +0000 (16:58 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 29 Jun 2007 16:58:58 +0000 (16:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47023 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/filepicker.h
src/gtk/filepicker.cpp

index 5a72f6f8a402aefd0c96fb6f23e4f12c68b41a3e..bb91c6d55471e208fb95a249f7bbad00941707bd 100644 (file)
@@ -36,7 +36,8 @@
                                                                               \
     virtual bool Destroy()                                                    \
     {                                                                         \
-        m_dialog->Destroy();                                                  \
+        if (m_dialog)                                                         \
+            m_dialog->Destroy();                                              \
         return wxButton::Destroy();                                           \
     }                                                                         \
                                                                               \
index 8ce087ed5cead9871fa2df31158e5539343991f8..841d47c10617e3e91fbb6b1e0654e43fab9c18c1 100644 (file)
@@ -105,7 +105,8 @@ wxFileButton::~wxFileButton()
     // GtkFileChooserDialog associated with m_dialog.
     // Thus we have to set its m_widget to NULL to avoid
     // double destruction on same widget
-    m_dialog->m_widget = NULL;
+    if (m_dialog)
+        m_dialog->m_widget = NULL;
 }
 
 void wxFileButton::OnDialogOK(wxCommandEvent& ev)
@@ -126,7 +127,8 @@ void wxFileButton::OnDialogOK(wxCommandEvent& ev)
 void wxFileButton::SetPath(const wxString &str)
 {
     m_path = str;
-    UpdateDialogPath(m_dialog);
+    if (m_dialog)
+        UpdateDialogPath(m_dialog);
 }
 
 #endif      // wxUSE_FILEPICKERCTRL && defined(__WXGTK26__)
@@ -249,7 +251,8 @@ wxDirButton::~wxDirButton()
     // GtkFileChooserDialog associated with m_dialog.
     // Thus we have to set its m_widget to NULL to avoid
     // double destruction on same widget
-    m_dialog->m_widget = NULL;
+    if (m_dialog)
+        m_dialog->m_widget = NULL;
 }
 
 void wxDirButton::SetPath(const wxString &str)
@@ -263,7 +266,8 @@ void wxDirButton::SetPath(const wxString &str)
     // general with all wxWidgets control-manipulation functions which do not send events).
     m_bIgnoreNextChange = true;
 
-    UpdateDialogPath(m_dialog);
+    if (m_dialog)
+        UpdateDialogPath(m_dialog);
 }
 
 #endif      // wxUSE_DIRPICKERCTRL && defined(__WXGTK26__)