X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9f057af5efcd64383486a6d56b8a4703a0118abd..249803fbcd1f73040e4b5457e341d8db2e5cb66e:/src/gtk/filedlg.cpp diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index e407cae561..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; @@ -228,7 +232,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, wxConvFileName->cWX2MB(defaultDir)); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), - wxConvFileName->cWX2MB(defaultFileName)); + wxGTK_CONV(defaultFileName)); #if GTK_CHECK_VERSION(2,7,3) if ((style & wxFD_OVERWRITE_PROMPT) && !gtk_check_version(2,7,3)) @@ -273,7 +277,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, void wxFileDialog::OnFakeOk( wxCommandEvent &event ) { if (!gtk_check_version(2,4,0)) - wxDialog::OnOK( event ); + EndDialog(wxID_OK); else wxGenericFileDialog::OnListOk( event ); } @@ -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(); } @@ -401,7 +416,7 @@ void wxFileDialog::SetFilename(const wxString& name) if (!gtk_check_version(2,4,0)) { if (HasFlag(wxFD_SAVE)) - gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(name)); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), wxGTK_CONV(name)); else SetPath(wxFileName(GetDirectory(), name).GetFullPath()); } @@ -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(); }