in a CrossThread object, ensure destruction of the channel and source used on Posix
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 9 Oct 2015 01:21:44 +0000 (21:21 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 9 Oct 2015 01:55:37 +0000 (21:55 -0400)
The source holds a reference to the channel; both must be unref'ed/destroyed in order to
fully clean up resources

libs/pbd/crossthread.posix.cc

index e3f6df5a311e357b2df20f12b822c9e12a740779..72a4fad810dcf221548f00526a6502f96e43513a 100644 (file)
@@ -2,6 +2,7 @@
 
 CrossThreadChannel::CrossThreadChannel (bool non_blocking)
         : receive_channel (0)
+        , receive_source (0)
 {
        fds[0] = -1;
        fds[1] = -1;
@@ -28,8 +29,14 @@ CrossThreadChannel::CrossThreadChannel (bool non_blocking)
 
 CrossThreadChannel::~CrossThreadChannel ()
 {
-        if (receive_channel) {
+       if (receive_source) {
+               g_source_destroy (receive_source);
+               receive_source = 0;
+       }
+
+       if (receive_channel) {
                 g_io_channel_unref (receive_channel);
+                receive_channel = 0;
         }
 
        if (fds[0] >= 0) {