remove unnecessary and unused changes from grygorii
[ardour.git] / libs / ardour / midi_patch_manager.cc
index 591c0cae40909743725d10976dc00bc0508db9c3..e0638f035e510232d27e5701b5e216990451ac38 100644 (file)
@@ -50,6 +50,7 @@ void
 MidiPatchManager::set_session (Session* s)
 {
        SessionHandlePtr::set_session (s);
+       refresh ();
        add_session_patches ();
 }
 
@@ -86,6 +87,12 @@ MidiPatchManager::add_session_patches ()
                        // build a list of all master devices from all documents
                        _master_devices_by_model[device->first] = device->second;
                        _all_models.insert(device->first);
+                       const std::string& manufacturer = device->second->manufacturer();
+                       if (_devices_by_manufacturer.find(manufacturer) == _devices_by_manufacturer.end()) {
+                               MIDINameDocument::MasterDeviceNamesList empty;
+                               _devices_by_manufacturer.insert(std::make_pair(manufacturer, empty));
+                       }
+                       _devices_by_manufacturer[manufacturer].insert(std::make_pair(device->first, device->second));
 
                        // make sure there are no double model names
                        // TODO: handle this gracefully.
@@ -101,6 +108,7 @@ MidiPatchManager::refresh()
        _documents.clear();
        _master_devices_by_model.clear();
        _all_models.clear();
+       _devices_by_manufacturer.clear();
 
        Searchpath search_path = midi_patch_search_path ();
        vector<std::string> result;
@@ -132,6 +140,12 @@ MidiPatchManager::refresh()
                        _master_devices_by_model[device->first] = device->second;
 
                        _all_models.insert(device->first);
+                       const std::string& manufacturer = device->second->manufacturer();
+                       if (_devices_by_manufacturer.find(manufacturer) == _devices_by_manufacturer.end()) {
+                               MIDINameDocument::MasterDeviceNamesList empty;
+                               _devices_by_manufacturer.insert(std::make_pair(manufacturer, empty));
+                       }
+                       _devices_by_manufacturer[manufacturer].insert(std::make_pair(device->first, device->second));
                }
        }
 
@@ -144,5 +158,8 @@ void
 MidiPatchManager::session_going_away ()
 {
        SessionHandlePtr::session_going_away ();
-       refresh ();
+       _documents.clear();
+       _master_devices_by_model.clear();
+       _all_models.clear();
+       _devices_by_manufacturer.clear();
 }