fix crash at session close/exit if a midi-control-surface is used
[ardour.git] / libs / pbd / enumwriter.cc
index 3ce296c664ccc695b0a774c65d82bc408079228d..f67d305080e62bad89e34ca748d7ae0e4ceaab1d 100644 (file)
@@ -127,7 +127,7 @@ EnumWriter::write (string type, int value)
 
        if (x == registry.end()) {
                error << string_compose (_("EnumWriter: unknown enumeration type \"%1\""), type) << endmsg;
-               throw unknown_enumeration();
+               throw unknown_enumeration (type);
        }
 
        if (x->second.bitwise) {
@@ -144,7 +144,7 @@ EnumWriter::read (string type, string value)
 
        if (x == registry.end()) {
                error << string_compose (_("EnumWriter: unknown enumeration type \"%1\""), type) << endmsg;
-               throw unknown_enumeration();
+               throw unknown_enumeration (type);
        }
 
        if (x->second.bitwise) {
@@ -267,7 +267,7 @@ EnumWriter::read_bits (EnumRegistration& er, string str)
        } while (true);
 
        if (!found) {
-               throw unknown_enumeration();
+               throw unknown_enumeration (str);
        }
 
        return result;
@@ -279,6 +279,23 @@ EnumWriter::read_distinct (EnumRegistration& er, string str)
        vector<int>::iterator i;
        vector<string>::iterator s;
 
+       /* first, check to see if there a hack for the name we're looking up */
+
+       map<string,string>::iterator x;
+
+       if ((x  = hack_table.find (str)) != hack_table.end()) {
+
+               cerr << "found hack for " << str << " = " << x->second << endl;
+
+               str = x->second;
+
+               for (i = er.values.begin(), s = er.names.begin(); i != er.values.end(); ++i, ++s) {
+                       if (str == (*s) || nocase_cmp (str, *s) == 0) {
+                               return (*i);
+                       }
+               }
+       }
+
        /* catch old-style hex numerics */
 
        if (str.length() > 2 && str[0] == '0' && str[1] == 'x') {
@@ -299,24 +316,7 @@ EnumWriter::read_distinct (EnumRegistration& er, string str)
                }
        }
 
-       /* failed to find it as-is. check to see if there a hack for the name we're looking up */
-
-       map<string,string>::iterator x;
-
-       if ((x  = hack_table.find (str)) != hack_table.end()) {
-
-               cerr << "found hack for " << str << " = " << x->second << endl;
-
-               str = x->second;
-
-               for (i = er.values.begin(), s = er.names.begin(); i != er.values.end(); ++i, ++s) {
-                       if (str == (*s) || nocase_cmp (str, *s) == 0) {
-                               return (*i);
-                       }
-               }
-       }
-
-       throw unknown_enumeration();
+       throw unknown_enumeration(str);
 }
 
 void