Change PBD::PathScanner API to return results by value to avoid inadvertent memory...
[ardour.git] / libs / surfaces / generic_midi / generic_midi_control_protocol.cc
index e0b06a936984ead8f1c10da783f41bb77839ff32..7a9104cfdbc69f8ce148249e5b9642847a44e3ae 100644 (file)
@@ -80,16 +80,14 @@ GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
        Controllable::CreateBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::create_binding, this, _1, _2, _3));
        Controllable::DeleteBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::delete_binding, this, _1));
 
-       Session::SendFeedback.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::send_feedback, this), midi_ui_context());;
-#if 0
-       /* XXXX SOMETHING GOES WRONG HERE (april 2012) - STILL DEBUGGING */
        /* this signal is emitted by the process() callback, and if
         * send_feedback() is going to do anything, it should do it in the
         * context of the process() callback itself.
         */
 
        Session::SendFeedback.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::send_feedback, this));
-#endif
+       //Session::SendFeedback.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::send_feedback, this), midi_ui_context());;
+
        /* this one is cross-thread */
 
        Route::RemoteControlIDChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::reset_controllables, this), midi_ui_context());
@@ -138,20 +136,20 @@ midi_map_filter (const string &str, void* /*arg*/)
 void
 GenericMidiControlProtocol::reload_maps ()
 {
-       vector<string *> *midi_maps;
+       vector<stringmidi_maps;
        PathScanner scanner;
        Searchpath spath (system_midi_map_search_path());
        spath += user_midi_map_directory ();
 
        midi_maps = scanner (spath.to_string(), midi_map_filter, 0, false, true);
 
-       if (!midi_maps) {
+       if (midi_maps.empty()) {
                cerr << "No MIDI maps found using " << spath.to_string() << endl;
                return;
        }
 
-       for (vector<string*>::iterator i = midi_maps->begin(); i != midi_maps->end(); ++i) {
-               string fullpath = *(*i);
+       for (vector<string>::iterator i = midi_maps.begin(); i != midi_maps.end(); ++i) {
+               string fullpath = *i;
 
                XMLTree tree;
 
@@ -172,8 +170,6 @@ GenericMidiControlProtocol::reload_maps ()
                
                map_info.push_back (mi);
        }
-
-       delete midi_maps;
 }
        
 void
@@ -466,23 +462,22 @@ GenericMidiControlProtocol::create_binding (PBD::Controllable* control, int pos,
 XMLNode&
 GenericMidiControlProtocol::get_state () 
 {
-       XMLNode* node = new XMLNode ("Protocol"); 
+       XMLNode& node (ControlProtocol::get_state());
        char buf[32];
 
-       node->add_property (X_("name"), _name);
-       node->add_property (X_("feedback"), do_feedback ? "1" : "0");
+       node.add_property (X_("feedback"), do_feedback ? "1" : "0");
        snprintf (buf, sizeof (buf), "%" PRIu64, _feedback_interval);
-       node->add_property (X_("feedback_interval"), buf);
+       node.add_property (X_("feedback_interval"), buf);
        snprintf (buf, sizeof (buf), "%d", _threshold);
-       node->add_property (X_("threshold"), buf);
+       node.add_property (X_("threshold"), buf);
 
        if (!_current_binding.empty()) {
-               node->add_property ("binding", _current_binding);
+               node.add_property ("binding", _current_binding);
        }
 
        XMLNode* children = new XMLNode (X_("Controls"));
 
-       node->add_child_nocopy (*children);
+       node.add_child_nocopy (*children);
 
        Glib::Threads::Mutex::Lock lm2 (controllables_lock);
        for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
@@ -497,7 +492,7 @@ GenericMidiControlProtocol::get_state ()
                }
        }
 
-       return *node;
+       return node;
 }
 
 int