tweak b7e645ec6, use session start/end position
[ardour.git] / libs / pbd / debug.cc
index a914cfd87126082ae1d8a500d8ce5da3cb766b0b..0940146aef756d7007026c7dad035fb20d49c6c0 100644 (file)
@@ -56,6 +56,7 @@ DebugBits PBD::DEBUG::Configuration = PBD::new_debug_bit ("configuration");
 DebugBits PBD::DEBUG::UndoHistory = PBD::new_debug_bit ("undohistory");
 DebugBits PBD::DEBUG::Timing = PBD::new_debug_bit ("timing");
 DebugBits PBD::DEBUG::Threads = PBD::new_debug_bit ("threads");
+DebugBits PBD::DEBUG::Locale = PBD::new_debug_bit ("locale");
 
 /* These are debug bits that are used by backends. Since these are loaded dynamically,
    after command-line parsing, defining them in code that is part of the backend
@@ -74,9 +75,21 @@ DebugBits PBD::debug_bits;
 DebugBits
 PBD::new_debug_bit (const char* name)
 {
-        DebugBits ret;
-        ret.set (_debug_bit++, 1);
-        _debug_bit_map().insert (make_pair (name, ret));
+       DebugBits ret;
+       DebugMap::iterator i =_debug_bit_map().find (name);
+
+       if (i != _debug_bit_map().end()) {
+               return i->second;
+       }
+
+       if (_debug_bit >= debug_bits.size()) {
+               cerr << "Too many debug bits defined, offender was " << name << endl;
+               abort ();
+               /*NOTREACHED*/
+       }
+
+       ret.set (_debug_bit++, 1);
+       _debug_bit_map().insert (make_pair (name, ret));
         return ret;
 }
 
@@ -115,9 +128,9 @@ PBD::parse_debug_options (const char* str)
                         }
                 }
        }
-       
+
        debug_bits = bits;
-       
+
        return 0;
 }
 
@@ -125,7 +138,7 @@ void
 PBD::list_debug_options ()
 {
        cout << _("The following debug options are available. Separate multiple options with commas.\nNames are case-insensitive and can be abbreviated.") << endl << endl;
-       cout << '\t' << X_("all") << endl; 
+       cout << '\t' << X_("all") << endl;
 
        vector<string> options;