]> git.saurik.com Git - wxWidgets.git/commitdiff
treat NULL extension properly in wxLoad/SaveFileSelector; don't crash if NULL ext...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 12 Jul 2002 18:17:24 +0000 (18:17 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 12 Jul 2002 18:17:24 +0000 (18:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/filedlgg.cpp

index 3d7e58d701e8360f2c3e720f6a611c1761a9e340..19570dec8832c0588a68e9d34d6d5df5c04646aa 100644 (file)
@@ -1540,39 +1540,53 @@ wxString wxFileSelector( const wxChar *title,
     }
 }
 
-wxString wxLoadFileSelector( const wxChar *what, const wxChar *ext, const wxChar *default_name, wxWindow *parent )
+static wxString GetWildcardString(const wxChar *ext)
 {
-    wxString prompt = wxString::Format(_("Load %s file"), what);
-
-    if (*ext == wxT('.'))
-        ext++;
+    wxString wild;
+    if ( ext )
+    {
+        if ( *ext == wxT('.') )
+            ext++;
 
-    wxString wild = wxString::Format(_T("*.%s"), ext);
+        wild << _T("*.") << ext;
+    }
+    else // no extension specified
+    {
+        wild = wxFileSelectorDefaultWildcardStr;
+    }
 
-    return wxFileSelector(prompt, (const wxChar *) NULL, default_name,
-                          ext, wild, 0, parent);
+    return wild;
 }
 
-wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name,
-         wxWindow *parent )
+wxString wxLoadFileSelector(const wxChar *what,
+                            const wxChar *ext,
+                            const wxChar *nameDef,
+                            wxWindow *parent)
 {
-    wxChar *ext = (wxChar *)extension;
-
-    wxString prompt = wxString::Format(_("Save %s file"), what);
-
-    if (*ext == wxT('.'))
-        ext++;
-
-    wxString wild = wxString::Format(_T("*.%s"), ext);
+    wxString prompt;
+    if ( what && *what )
+        prompt = wxString::Format(_("Load %s file"), what);
+    else
+        prompt = _("Load file");
 
-    return wxFileSelector(prompt, (const wxChar *) NULL, default_name,
-                          ext, wild, 0, parent);
+    return wxFileSelector(prompt, NULL, nameDef, ext,
+                          GetWildcardString(ext), 0, parent);
 }
 
+wxString wxSaveFileSelector(const wxChar *what,
+                            const wxChar *ext,
+                            const wxChar *nameDef,
+                            wxWindow *parent)
+{
+    wxString prompt;
+    if ( what && *what )
+        prompt = wxString::Format(_("Save %s file"), what);
+    else
+        prompt = _("Save file");
 
-
-
-
+    return wxFileSelector(prompt, NULL, nameDef, ext,
+                          GetWildcardString(ext), 0, parent);
+}
 
 // A module to allow icons table cleanup