]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/filedlg.cpp
that was a memory leak
[wxWidgets.git] / src / gtk / filedlg.cpp
index e1082ea83eccef1268cb0967d18b0ee39193be5e..c2dc478759e39805a9ec3c3407a4e4ced82fc674 100644 (file)
@@ -21,6 +21,7 @@
 #include "wx/intl.h"
 #include "wx/filename.h"
 #include "wx/msgdlg.h"
+#include "wx/log.h"
 
 #include <gtk/gtk.h>
 
@@ -43,7 +44,13 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
 {
     int style = dialog->GetStyle();
     gchar* text = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
-    wxString filename(wxGTK_CONV_BACK(text));
+    wxString filename = wxConvFileName->cMB2WX( text );
+    if ( filename.empty() )
+    {
+        // this is totally lame but better than silent error
+        wxLogWarning(_("This filename can't be used by wxWidgets because it contains invalid UTF-8 characters, please rename the file."));
+        return;
+    }
 
     if ((style & wxSAVE) && (style & wxOVERWRITE_PROMPT))
     {
@@ -292,7 +299,8 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const
             if (gpaths)
                 g_slist_free(gpaths);
         }
-        else
+
+        if ( paths.IsEmpty() )
         {
             paths.Add(m_fileName);
         }