diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 8b10e2ad2f..49b653a684 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2556,6 +2556,10 @@ Session::midi_output_change_handler (IOChange change, void * /*src*/, boost::wea { boost::shared_ptr midi_route (wr.lock()); + if (!midi_route) { + return; + } + if ((change.type & IOChange::ConfigurationChanged) && Config->get_output_auto_connect() != ManualConnect) { if (change.after.n_audio() <= change.before.n_audio()) { @@ -3266,7 +3270,6 @@ Session::load_and_connect_instruments (RouteList& new_routes, bool strict_io, bo for (RouteList::iterator r = new_routes.begin(); r != new_routes.end(); ++r) { (*r)->output()->changed.connect_same_thread (*this, boost::bind (&Session::midi_output_change_handler, this, _1, _2, boost::weak_ptr(*r))); } - } void diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index ab18b904fc..0a46da2e4e 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1846,6 +1846,16 @@ Session::load_routes (const XMLNode& node, int version) add_routes (new_routes, false, false, PresentationInfo::max_order); + /* re-subscribe to MIDI connection handler */ + for (RouteList::iterator r = new_routes.begin(); r != new_routes.end(); ++r) { + boost::shared_ptr mt = boost::dynamic_pointer_cast (*r); + bool is_midi_route = (*r)->n_inputs().n_midi() > 0 && (*r)->n_inputs().n_midi() > 0; + if (mt || is_midi_route) { + (*r)->output()->changed.connect_same_thread (*this, boost::bind (&Session::midi_output_change_handler, this, _1, _2, boost::weak_ptr(*r))); + } + } + + BootMessage (_("Finished adding tracks/busses")); return 0;