Engine Dialog: Don't save duplicate states (and remove old dups)

This commit is contained in:
Robin Gareus 2014-06-13 17:18:30 +02:00
parent ff39a42581
commit f2404a522d

View file

@ -1068,21 +1068,21 @@ EngineControl::save_state ()
if (!_have_control) { if (!_have_control) {
return 0; return 0;
} }
State* state = new State;
bool existing = true;
State* state = get_saved_state_for_currently_displayed_backend_and_device ();
if (!state) {
existing = false;
state = new State;
}
store_state (*state); store_state (*state);
if (!existing) { for (StateList::iterator i = states.begin(); i != states.end();) {
states.push_back (*state); 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; 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); states.push_back (state);
} }
} }
@ -1667,7 +1682,11 @@ EngineControl::get_backend () const
string string
EngineControl::get_driver () const 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 string