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
This commit is contained in:
Robert Roebling 2004-11-28 22:54:13 +00:00
parent 5bef7b5828
commit c2740a5aab
4 changed files with 26 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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