[gnome-remote-desktop] stream: Add method to disconnect proxy signals



commit 2c968f5d2d308d0690ee3fb5b6b949338eaeb86f
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Thu Nov 25 18:26:17 2021 +0100

    stream: Add method to disconnect proxy signals
    
    This method will be called in the next commit, when the session is
    stopped to prevent calling the connected callback, when the actual
    session is already stopped or destroyed.

 src/grd-stream.c | 17 ++++++++++++++---
 src/grd-stream.h |  2 ++
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/grd-stream.c b/src/grd-stream.c
index 9ac72868..f75ca22e 100644
--- a/src/grd-stream.c
+++ b/src/grd-stream.c
@@ -41,6 +41,8 @@ typedef struct _GrdStreamPrivate
   uint32_t pipewire_node_id;
 
   GrdDBusScreenCastStream *proxy;
+
+  unsigned long pipewire_stream_added_id;
 } GrdStreamPrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (GrdStream, grd_stream, G_TYPE_OBJECT)
@@ -61,6 +63,14 @@ grd_stream_get_object_path (GrdStream *stream)
   return g_dbus_proxy_get_object_path (G_DBUS_PROXY (priv->proxy));
 }
 
+void
+grd_stream_disconnect_proxy_signals (GrdStream *stream)
+{
+  GrdStreamPrivate *priv = grd_stream_get_instance_private (stream);
+
+  g_clear_signal_handler (&priv->pipewire_stream_added_id, priv->proxy);
+}
+
 static void
 on_pipewire_stream_added (GrdDBusScreenCastStream *proxy,
                           unsigned int             node_id,
@@ -85,9 +95,10 @@ grd_stream_new (GrdContext              *context,
 
   priv->context = context;
   priv->proxy = proxy;
-  g_signal_connect (proxy, "pipewire-stream-added",
-                    G_CALLBACK (on_pipewire_stream_added),
-                    stream);
+  priv->pipewire_stream_added_id =
+    g_signal_connect (proxy, "pipewire-stream-added",
+                      G_CALLBACK (on_pipewire_stream_added),
+                      stream);
 
   return stream;
 }
diff --git a/src/grd-stream.h b/src/grd-stream.h
index ee8a10dc..d79668c8 100644
--- a/src/grd-stream.h
+++ b/src/grd-stream.h
@@ -39,6 +39,8 @@ uint32_t grd_stream_get_pipewire_node_id (GrdStream *stream);
 
 const char * grd_stream_get_object_path (GrdStream *stream);
 
+void grd_stream_disconnect_proxy_signals (GrdStream *stream);
+
 GrdStream * grd_stream_new (GrdContext              *context,
                             GrdDBusScreenCastStream *proxy);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]