From c779251a3e0e9d3f6e7345251f245f1c3f057da2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 19 Jan 2013 13:15:10 +0000 Subject: [PATCH] fix midnam-related crash introduced around 13892 git-svn-id: svn://localhost/ardour2/branches/3.0@13897 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/midi_time_axis.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index a0bd56e04a..ce073c6468 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -782,9 +782,12 @@ MidiTimeAxisView::build_controller_menu () const Glib::ustring model = _midnam_model_selector.get_active_text(); boost::shared_ptr midnam = MidiPatchManager::instance() .document_by_model(model); - boost::shared_ptr device_names = midnam->master_device_names( - model); + boost::shared_ptr device_names; + if (midnam) { + device_names = midnam->master_device_names(model); + } + if (device_names && !device_names->controls().empty()) { /* Controllers names available in midnam file, generate fancy menu */ unsigned n_items = 0; @@ -793,7 +796,7 @@ MidiTimeAxisView::build_controller_menu () l != device_names->controls().end(); ++l) { boost::shared_ptr name_list = *l; Menu* ctl_menu = NULL; - + for (ControlNameList::Controls::const_iterator c = (*l)->controls().begin(); c != (*l)->controls().end(); ++c) { const int ctl = atoi((*c)->number().c_str()); @@ -801,12 +804,12 @@ MidiTimeAxisView::build_controller_menu () /* Skip bank select controllers since they're handled specially */ continue; } - + if (n_items == 0) { /* Create a new submenu */ ctl_menu = manage (new Menu); } - + MenuList& ctl_items (ctl_menu->items()); if (chn_cnt > 1) { add_multi_channel_controller_item(ctl_items, ctl, (*c)->name());