From 63d81d2419e08b357af2e9d94d077eb1556a72a6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 4 Jul 2014 15:50:34 +0200 Subject: [PATCH] purge states of Audio-backends that are N/A fixes crashes/assert() when using different builds while sharing ardour.rc with n/a engine backends marked active. --- gtk2_ardour/engine_dialog.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 27cf9b7719..437aea7d39 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -1337,6 +1337,21 @@ EngineControl::set_state (const XMLNode& root) /* now see if there was an active state and switch the setup to it */ + // purge states of backend that are not available in this built + vector backends = ARDOUR::AudioEngine::instance()->available_backends(); + vector backend_names; + + for (vector::const_iterator i = backends.begin(); i != backends.end(); ++i) { + backend_names.push_back((*i)->name); + } + for (StateList::iterator i = states.begin(); i != states.end();) { + if (std::find(backend_names.begin(), backend_names.end(), (*i)->backend) == backend_names.end()) { + i = states.erase(i); + } else { + ++i; + } + } + for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) { if ((*i)->active) {