[gtk/fix-file-transfer-portal: 1/2] Handle absence of portals
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gtk/fix-file-transfer-portal: 1/2] Handle absence of portals
- Date: Wed,  7 Sep 2022 12:45:38 +0000 (UTC)
commit e16414b3ace5a3d3a26431fcb2fffb5032aae2dd
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..bf1e2e2be5 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 (file_transfer_proxy && !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]