summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-04-26 04:02:58 +0200
committerRobin Gareus <robin@gareus.org>2016-04-26 04:02:58 +0200
commit7cbc6cf8a253efd3dc30f692c8b68c9c9269ead2 (patch)
tree5a5a45d7923a2820fe0085d8fb014c2357f7f7a4 /libs/ardour
parent2169de3975e8276233e2640391c8b526ec9e97fd (diff)
styleguide #10
sigc keeps a reference to the shared_ptr, AsyncMidiPorts were never unregistered, causing issues when loading a new session w/o Engine restart.
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/midi_ui.h2
-rw-r--r--libs/ardour/midi_ui.cc10
2 files changed, 9 insertions, 3 deletions
diff --git a/libs/ardour/ardour/midi_ui.h b/libs/ardour/ardour/midi_ui.h
index 2f0f7d3a45..88ea021361 100644
--- a/libs/ardour/ardour/midi_ui.h
+++ b/libs/ardour/ardour/midi_ui.h
@@ -62,7 +62,7 @@ class LIBARDOUR_API MidiControlUI : public AbstractUI<MidiUIRequest>
private:
ARDOUR::Session& _session;
- bool midi_input_handler (Glib::IOCondition, boost::shared_ptr<AsyncMIDIPort>);
+ bool midi_input_handler (Glib::IOCondition, boost::weak_ptr<AsyncMIDIPort>);
void reset_ports ();
void clear_ports ();
diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc
index 1d2fe7c7e1..c11f96c071 100644
--- a/libs/ardour/midi_ui.cc
+++ b/libs/ardour/midi_ui.cc
@@ -82,8 +82,13 @@ MidiControlUI::do_request (MidiUIRequest* req)
}
bool
-MidiControlUI::midi_input_handler (IOCondition ioc, boost::shared_ptr<AsyncMIDIPort> port)
+MidiControlUI::midi_input_handler (IOCondition ioc, boost::weak_ptr<AsyncMIDIPort> wport)
{
+ boost::shared_ptr<AsyncMIDIPort> port = wport.lock ();
+ if (!port) {
+ return false;
+ }
+
DEBUG_TRACE (DEBUG::MidiIO, string_compose ("something happend on %1\n", boost::shared_ptr<ARDOUR::Port> (port)->name()));
if (ioc & ~IO_IN) {
@@ -130,7 +135,8 @@ MidiControlUI::reset_ports ()
}
for (vector<boost::shared_ptr<AsyncMIDIPort> >::const_iterator pi = ports.begin(); pi != ports.end(); ++pi) {
- (*pi)->xthread().set_receive_handler (sigc::bind (sigc::mem_fun (this, &MidiControlUI::midi_input_handler), *pi));
+ (*pi)->xthread().set_receive_handler (sigc::bind (
+ sigc::mem_fun (this, &MidiControlUI::midi_input_handler), boost::weak_ptr<AsyncMIDIPort>(*pi)));
(*pi)->xthread().attach (_main_loop->get_context());
}
}