for an ipMIDI surface, make the GSource used for input hold the only reference on the GUIChannel.

This commit is contained in:
Paul Davis 2015-10-08 21:53:05 -04:00
parent 7e10c21468
commit bda0ba173c
3 changed files with 9 additions and 12 deletions

View file

@ -713,7 +713,7 @@ MackieControlProtocol::set_device (const string& device_name)
switch_banks (0, true);
// DeviceChanged ();
DeviceChanged ();
return 0;
}
@ -819,8 +819,13 @@ MackieControlProtocol::create_surfaces ()
if ((fd = input_port.selectable ()) >= 0) {
surface->input_channel = g_io_channel_unix_new (fd);
surface->input_source = g_io_create_watch (surface->input_channel, GIOCondition (G_IO_IN|G_IO_HUP|G_IO_ERR));
GIOChannel* ioc = g_io_channel_unix_new (fd);
surface->input_source = g_io_create_watch (ioc, GIOCondition (G_IO_IN|G_IO_HUP|G_IO_ERR));
/* make surface's input source now hold the
* only reference on the IO channel
*/
g_io_channel_unref (ioc);
/* hack up an object so that in the callback from the event loop
we have both the MackieControlProtocol and the input port.

View file

@ -92,7 +92,6 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
, _master_fader (0)
, _last_master_gain_written (-0.0f)
, connection_state (0)
, input_channel (0)
, input_source (0)
{
DEBUG_TRACE (DEBUG::MackieControl, "Surface::Surface init\n");
@ -169,11 +168,6 @@ Surface::~Surface ()
input_source = 0;
}
if (input_channel) {
g_io_channel_unref (input_channel);
input_channel = 0;
}
delete _jog_wheel;
delete _port;

View file

@ -204,9 +204,7 @@ public:
MidiByteArray display_line (std::string const& msg, int line_num);
public:
/* IP MIDI devices need to keep a handle on these */
GIOChannel* input_channel;
/* IP MIDI devices need to keep a handle on this and destroy it */
GSource* input_source;
};