[gtk/fix-file-transfer-portal: 3/4] Handle absence of portals




commit b291c392db4d8490ba009ca4ee35bd1b13921951
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 7 07:53:12 2022 -0400

    Handle absence of portals
    
    When the documents portal is not on the bus,
    we still get an (unowned) proxy, and we need
    to handle that situation.

 gdk/filetransferportal.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/gdk/filetransferportal.c b/gdk/filetransferportal.c
index d9934fbb43..07893a433b 100644
--- a/gdk/filetransferportal.c
+++ b/gdk/filetransferportal.c
@@ -512,6 +512,21 @@ finish_registration (void)
                     "closed", G_CALLBACK (connection_closed), NULL);
 }
 
+static gboolean
+proxy_has_owner (GDBusProxy *proxy)
+{
+  char *owner;
+
+  owner = g_dbus_proxy_get_name_owner (proxy);
+  if (owner)
+    {
+      g_free (owner);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 void
 file_transfer_portal_register (void)
 {
@@ -531,6 +546,10 @@ file_transfer_portal_register (void)
                                 "org.freedesktop.portal.FileTransfer",
                                 NULL,
                                 NULL);
+
+      if (!proxy_has_owner (file_transfer_proxy))
+        g_clear_object (&file_transfer_proxy);
+
       if (file_transfer_proxy)
         finish_registration ();
     }


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