"We brake for nobody." oh wait. - fixes Rectified Waveform view.
[ardour.git] / gtk2_ardour / plugin_selector.cc
index e39efe49a0cfa78485da4734ad02632dc0d9a54b..fcf056307e7be2deaf81460a609df947fbdc46b0 100644 (file)
@@ -311,9 +311,17 @@ PluginSelector::refiller (const PluginInfoList& plugs, const::std::string& filte
                        string::size_type pos = 0;
 
                        /* stupid LADSPA creator strings */
-
+#ifdef PLATFORM_WINDOWS
+                       while (pos < creator.length() && creator[pos] > -2 && creator[pos] < 256 && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
+#else
                        while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
-                       creator = creator.substr (0, pos);
+#endif
+                       // If there were too few characters to create a
+                       // meaningful name, mark this creator as 'Unknown'
+                       if (creator.length()<2 || pos<3)
+                               creator = "Unknown";
+                       else
+                               creator = creator.substr (0, pos);
 
                        newrow[plugin_columns.creator] = creator;
 
@@ -681,8 +689,21 @@ PluginSelector::create_by_creator_menu (ARDOUR::PluginInfoList& all_plugs)
 
                /* stupid LADSPA creator strings */
                string::size_type pos = 0;
+#ifdef PLATFORM_WINDOWS
+               while (pos < creator.length() && creator[pos]>(-2) && creator[pos]<256 && (isprint (creator[pos]))) ++pos;
+#else
                while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
-               creator = creator.substr (0, pos);
+#endif
+
+               // Check to see if we found any invalid characters.
+               if (creator.length() != pos) {
+                       // If there were too few characters to create a
+                       // meaningful name, mark this creator as 'Unknown'
+                       if (pos<3)
+                               creator = "Unknown?";
+                       else
+                               creator = creator.substr (0, pos);
+               }
 
                SubmenuMap::iterator x;
                Gtk::Menu* submenu;