fix midnam-related crash introduced around 13892
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 19 Jan 2013 13:15:10 +0000 (13:15 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 19 Jan 2013 13:15:10 +0000 (13:15 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13897 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/midi_time_axis.cc

index a0bd56e04a5a33fee0df061215b8aa6d2218bef4..ce073c6468e37b9ec00acad129b00ea55063bb5c 100644 (file)
@@ -782,9 +782,12 @@ MidiTimeAxisView::build_controller_menu ()
        const Glib::ustring model = _midnam_model_selector.get_active_text();
        boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance()
                .document_by_model(model);
-       boost::shared_ptr<MasterDeviceNames> device_names = midnam->master_device_names(
-               model);
+       boost::shared_ptr<MasterDeviceNames> 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<ControlNameList> 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());