[gnome-remote-desktop] session: Only handle Selection* signals when clipboard is enabled



commit 3dfb2d15ff75ea1983b1d1b1d3f3da3fe02710be
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Thu Oct 28 10:54:43 2021 +0200

    session: Only handle Selection* signals when clipboard is enabled
    
    When the RDP or VNC backend disable the clipboard, since the session is
    about to be destroyed, then gnome-remote-desktop could still receive
    SelectionOwnerChanged- and SelectionTransfer-signals.
    Currently, these signals are handled unconditionally.
    
    To ensure that this won't be the case any more, ignore these signals,
    when the clipboard instance is unavailable.

 src/grd-clipboard.c | 2 ++
 src/grd-session.c   | 7 +++++++
 2 files changed, 9 insertions(+)
---
diff --git a/src/grd-clipboard.c b/src/grd-clipboard.c
index bea5481..1b1e40e 100644
--- a/src/grd-clipboard.c
+++ b/src/grd-clipboard.c
@@ -383,6 +383,8 @@ grd_clipboard_update_client_mime_type_list (GrdClipboard *clipboard,
    */
   abort_current_read_operation (clipboard);
 
+  g_assert (priv->enabled);
+
   if (!klass->update_client_mime_type_list)
     return;
 
diff --git a/src/grd-session.c b/src/grd-session.c
index 71f0518..0bcc9bf 100644
--- a/src/grd-session.c
+++ b/src/grd-session.c
@@ -266,6 +266,7 @@ grd_session_disable_clipboard (GrdSession *session)
 {
   GrdSessionPrivate *priv = grd_session_get_instance_private (session);
 
+  priv->clipboard = NULL;
   if (!priv->remote_desktop_session)
     return;
 
@@ -574,6 +575,9 @@ on_remote_desktop_session_selection_owner_changed (GrdDBusRemoteDesktopSession *
   GrdMimeType mime_type;
   GList *mime_type_list = NULL;
 
+  if (!priv->clipboard)
+    return;
+
   is_owner_variant = g_variant_lookup_value (options_variant, "session-is-owner",
                                              G_VARIANT_TYPE ("b"));
   if (is_owner_variant && g_variant_get_boolean (is_owner_variant))
@@ -622,6 +626,9 @@ on_remote_desktop_session_selection_transfer (GrdDBusRemoteDesktopSession *sessi
   int fd;
   GrdMimeType mime_type;
 
+  if (!priv->clipboard)
+    return;
+
   mime_type = grd_mime_type_from_string (mime_type_string);
   if (mime_type == GRD_MIME_TYPE_NONE)
     {


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