]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fldlgcmn.cpp
Partially applied patch [ 763900 ] fix for vertical toolbar
[wxWidgets.git] / src / common / fldlgcmn.cpp
index 102c036b3a57f05dcc39a80d780b2b39e055264b..c6059ddb0f1b196be09df426cc786f2bb42a24c6 100644 (file)
@@ -244,34 +244,48 @@ int wxParseFileFilter(const wxString& filterStr,
                       wxArrayString& descriptions,
                       wxArrayString& filters)
 {
+    descriptions.Clear();
+    filters.Clear();
+
     wxString str(filterStr);
 
     wxString description, filter;
-    int pos = -1;
-    bool finished = FALSE;
-    do
+    for ( int pos = 0; pos != wxNOT_FOUND; )
     {
         pos = str.Find(wxT('|'));
-        if (pos == -1)
-            return 0; // Problem
+        if ( pos == wxNOT_FOUND )
+        {
+            // if there are no '|'s at all in the string just take the entire
+            // string as filter
+            if ( filters.IsEmpty() )
+            {
+                descriptions.Add(filterStr);
+                filters.Add(filterStr);
+            }
+            else
+            {
+                wxFAIL_MSG( _T("missing '|' in the wildcard string!") );
+            }
+
+            break;
+        }
+
         description = str.Left(pos);
-        str = str.Mid(pos+1);
+        str = str.Mid(pos + 1);
         pos = str.Find(wxT('|'));
-        if (pos == -1)
+        if ( pos == wxNOT_FOUND )
         {
             filter = str;
-            finished = TRUE;
         }
         else
         {
             filter = str.Left(pos);
-            str = str.Mid(pos+1);
+            str = str.Mid(pos + 1);
         }
 
         descriptions.Add(description);
         filters.Add(filter);
     }
-    while (!finished);
 
     return filters.GetCount();
 }