From: Robert Roebling Date: Sun, 28 Nov 2004 22:54:13 +0000 (+0000) Subject: Dirty hack to prevent double destruction of file dialog. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c2740a5aab5ab5ea5305f272465e137f9ad02c3c?ds=sidebyside Dirty hack to prevent double destruction of file dialog. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30812 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/filedlg.h b/include/wx/gtk/filedlg.h index 70e26820cf..4aa8521e9b 100644 --- a/include/wx/gtk/filedlg.h +++ b/include/wx/gtk/filedlg.h @@ -43,9 +43,11 @@ public: virtual void SetFilename(const wxString& name); virtual void SetWildcard(const wxString& wildCard); virtual void SetFilterIndex(int filterIndex); - + +//private: + bool m_destroyed_by_delete; + void UpdateFromDialog(); -private: void UpdateDialog(); DECLARE_DYNAMIC_CLASS(wxFileDialog) diff --git a/include/wx/gtk1/filedlg.h b/include/wx/gtk1/filedlg.h index 70e26820cf..4aa8521e9b 100644 --- a/include/wx/gtk1/filedlg.h +++ b/include/wx/gtk1/filedlg.h @@ -43,9 +43,11 @@ public: virtual void SetFilename(const wxString& name); virtual void SetWildcard(const wxString& wildCard); virtual void SetFilterIndex(int filterIndex); - + +//private: + bool m_destroyed_by_delete; + void UpdateFromDialog(); -private: void UpdateDialog(); DECLARE_DYNAMIC_CLASS(wxFileDialog) diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index 20bc8b0558..adb8f61207 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -110,8 +110,13 @@ static void gtk_filedialog_response_callback(GtkWidget *w, if (response == GTK_RESPONSE_ACCEPT) gtk_filedialog_ok_callback(w, dialog); - else + else if (response == GTK_RESPONSE_CANCEL) + gtk_filedialog_cancel_callback(w, dialog); + else // "delete" + { gtk_filedialog_cancel_callback(w, dialog); + dialog->m_destroyed_by_delete = TRUE; + } } //----------------------------------------------------------------------------- @@ -129,6 +134,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, wildCard, style, pos) { m_needParent = FALSE; + m_destroyed_by_delete = FALSE; if (!PreCreation(parent, pos, wxDefaultSize) || !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, @@ -182,6 +188,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, wxFileDialog::~wxFileDialog() { + if (m_destroyed_by_delete) + m_widget = NULL; } void wxFileDialog::GetFilenames(wxArrayString& files) const diff --git a/src/gtk1/filedlg.cpp b/src/gtk1/filedlg.cpp index 20bc8b0558..adb8f61207 100644 --- a/src/gtk1/filedlg.cpp +++ b/src/gtk1/filedlg.cpp @@ -110,8 +110,13 @@ static void gtk_filedialog_response_callback(GtkWidget *w, if (response == GTK_RESPONSE_ACCEPT) gtk_filedialog_ok_callback(w, dialog); - else + else if (response == GTK_RESPONSE_CANCEL) + gtk_filedialog_cancel_callback(w, dialog); + else // "delete" + { gtk_filedialog_cancel_callback(w, dialog); + dialog->m_destroyed_by_delete = TRUE; + } } //----------------------------------------------------------------------------- @@ -129,6 +134,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, wildCard, style, pos) { m_needParent = FALSE; + m_destroyed_by_delete = FALSE; if (!PreCreation(parent, pos, wxDefaultSize) || !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, @@ -182,6 +188,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, wxFileDialog::~wxFileDialog() { + if (m_destroyed_by_delete) + m_widget = NULL; } void wxFileDialog::GetFilenames(wxArrayString& files) const