Engine Dialog: Don't save duplicate states (and remove old dups)
authorRobin Gareus <robin@gareus.org>
Fri, 13 Jun 2014 15:18:30 +0000 (17:18 +0200)
committerRobin Gareus <robin@gareus.org>
Fri, 13 Jun 2014 15:18:30 +0000 (17:18 +0200)
gtk2_ardour/engine_dialog.cc

index a5accc6e9bb64958cc2c0fc2baa7114eec8eeffb..b2a60dca910b5dd12b7858e07c69a534ad7c7da8 100644 (file)
@@ -1068,21 +1068,21 @@ EngineControl::save_state ()
        if (!_have_control) {
                return 0;
        }
-
-       bool existing = true;
-       State* state = get_saved_state_for_currently_displayed_backend_and_device ();
-
-       if (!state) {
-               existing = false;
-               state = new State;
-       }
-
+       State* state = new State;
        store_state (*state);
 
-       if (!existing) {
-               states.push_back (*state);
+       for (StateList::iterator i = states.begin(); i != states.end();) {
+               if ((*i).backend == state->backend &&
+                               (*i).driver == state->driver &&
+                               (*i).device == state->device) {
+                       i =  states.erase(i);
+               } else {
+                       ++i;
+               }
        }
 
+       states.push_back (*state);
+
        return state;
 }
 
@@ -1291,6 +1291,21 @@ EngineControl::set_state (const XMLNode& root)
                                }
                        }
 
+#if 1
+                       /* remove accumulated duplicates (due to bug in ealier version)
+                        * this can be removed again before release
+                        */
+                       for (StateList::iterator i = states.begin(); i != states.end();) {
+                               if ((*i).backend == state.backend &&
+                                               (*i).driver == state.driver &&
+                                               (*i).device == state.device) {
+                                       i =  states.erase(i);
+                               } else {
+                                       ++i;
+                               }
+                       }
+#endif
+
                        states.push_back (state);
                }
        }
@@ -1667,7 +1682,11 @@ EngineControl::get_backend () const
 string
 EngineControl::get_driver () const
 {
-       return driver_combo.get_active_text ();
+       if (driver_combo.get_sensitive() && driver_combo.get_parent()) {
+               return driver_combo.get_active_text ();
+       } else {
+               return "";
+       }
 }
 
 string