filechooser portal: Free portal proxy when bus connection closes
authorAlexander Larsson <alexl@redhat.com>
Tue, 4 Feb 2020 13:08:10 +0000 (14:08 +0100)
committerAlexander Larsson <alexl@redhat.com>
Tue, 4 Feb 2020 13:08:10 +0000 (14:08 +0100)
This was blocking the clean exit from the testdbus shutdown in
the defaultvalues test. The proxy was keeping the connection alive
which blocks g_test_dbus_down().

gdk/filetransferportal.c

index 541fd85a2411936d13601ae53e4dda2cdaec2fd4..a658d086a89dc26ff1a71e6f2d8e02884da6fc87 100644 (file)
@@ -471,6 +471,14 @@ portal_file_deserializer (GdkContentDeserializer *deserializer)
   g_object_unref (output);
 }
 
+static void
+connection_closed (GDBusConnection *connection,
+                   gboolean         remote_peer_vanished,
+                   GError          *error)
+{
+  g_clear_object (&file_transfer_proxy);
+}
+
 static void
 got_proxy (GObject *source,
            GAsyncResult *result,
@@ -509,6 +517,10 @@ got_proxy (GObject *source,
                                      portal_file_deserializer,
                                      NULL,
                                      NULL);
+
+  /* Free the singleton when the connection closes, important for test */
+  g_signal_connect (g_dbus_proxy_get_connection (G_DBUS_PROXY (file_transfer_proxy)),
+                    "closed", G_CALLBACK (connection_closed), NULL);
 }
 
 void