From 3ab296d9eb6d351eb1d2238f3e6ff2f5e6123861 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 17 Sep 2006 10:49:11 +0000 Subject: [PATCH] Commit patch [ 1559950 ] fix mem leaks in wx{Dir|File}Dialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/dirdlg.cpp | 8 +++++++- src/gtk/filedlg.cpp | 26 ++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/gtk/dirdlg.cpp b/src/gtk/dirdlg.cpp index de32c610db..84f672f95d 100644 --- a/src/gtk/dirdlg.cpp +++ b/src/gtk/dirdlg.cpp @@ -212,7 +212,13 @@ void wxDirDialog::SetPath(const wxString& dir) wxString wxDirDialog::GetPath() const { if (!gtk_check_version(2,4,0)) - return wxConvFileName->cMB2WX( gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(m_widget) ) ); + { + gchar *str = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(m_widget) ); + wxString ret = wxConvFileName->cMB2WX(str); + if (str) g_free(str); + + return ret; + } else return wxGenericDirDialog::GetPath(); } diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index 499fe0c07c..81e12219e4 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -113,7 +113,11 @@ static void gtk_filedialog_update_preview_callback(GtkFileChooser *chooser, { #if GTK_CHECK_VERSION(2,4,0) GtkWidget *preview = GTK_WIDGET(user_data); - wxGtkString filename(gtk_file_chooser_get_preview_filename(chooser)); + + gchar *str = gtk_file_chooser_get_preview_filename(chooser); + wxGtkString filename(str); + if (str) g_free(str); + if ( !filename ) return; @@ -305,7 +309,13 @@ void wxFileDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags wxString wxFileDialog::GetPath() const { if (!gtk_check_version(2,4,0)) - return wxConvFileName->cMB2WX(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget))); + { + gchar *str = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)); + wxString ret = wxConvFileName->cMB2WX(str); + if (str) g_free(str); + + return ret; + } else return wxGenericFileDialog::GetPath(); } @@ -390,8 +400,13 @@ void wxFileDialog::SetDirectory(const wxString& dir) wxString wxFileDialog::GetDirectory() const { if (!gtk_check_version(2,4,0)) - return wxConvFileName->cMB2WX( - gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(m_widget) ) ); + { + gchar *str = gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(m_widget) ); + wxString ret = wxConvFileName->cMB2WX(str); + if (str) g_free(str); + + return ret; + } else return wxGenericFileDialog::GetDirectory(); } @@ -412,8 +427,7 @@ void wxFileDialog::SetFilename(const wxString& name) wxString wxFileDialog::GetFilename() const { if (!gtk_check_version(2,4,0)) - return wxFileName( - wxConvFileName->cMB2WX(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget))) ).GetFullName(); + return wxFileName(GetPath()).GetFullName(); else return wxGenericFileDialog::GetFilename(); } -- 2.45.2