[mutter] wayland/client: Free GSubprocessLauncher after spawning



commit 5afdbc669d9931404605ba6b6486f1a08ffdd70a
Author: Sergio Costas <raster rastersoft com>
Date:   Wed Sep 30 23:52:12 2020 +0200

    wayland/client: Free GSubprocessLauncher after spawning
    
    A Meta.WaylandClient() object has a GSubprocessLauncher object
    passed externally. Currently this object is kept while the
    WaylandClient object exists, but is is only needed until the call
    to spawn is made.
    
    This patch frees that GSubprocessLauncher just after that call,
    thus freeing those resources.
    
    Fix https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1462

 src/wayland/meta-wayland-client.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/wayland/meta-wayland-client.c b/src/wayland/meta-wayland-client.c
index 01aa4c3282..dfae1eda6d 100644
--- a/src/wayland/meta-wayland-client.c
+++ b/src/wayland/meta-wayland-client.c
@@ -50,6 +50,7 @@ struct _MetaWaylandClient
   GSubprocess *subprocess;
   GCancellable *died_cancellable;
   gboolean process_running;
+  gboolean process_launched;
   struct wl_client *wayland_client;
 };
 
@@ -165,21 +166,21 @@ meta_wayland_client_spawnv (MetaWaylandClient   *client,
                         argv[0][0] != '\0',
                         NULL);
 
-  if (client->launcher == NULL)
+  if (client->process_launched)
     {
       g_set_error (error,
                    G_IO_ERROR,
-                   G_IO_ERROR_NOT_INITIALIZED,
-                   "MetaWaylandClient must be created using meta_wayland_client_new().");
+                   G_IO_ERROR_FAILED,
+                   "This object already has spawned a subprocess.");
       return NULL;
     }
 
-  if (client->subprocess != NULL)
+  if (client->launcher == NULL)
     {
       g_set_error (error,
                    G_IO_ERROR,
-                   G_IO_ERROR_FAILED,
-                   "This object already has a process running.");
+                   G_IO_ERROR_NOT_INITIALIZED,
+                   "MetaWaylandClient must be created using meta_wayland_client_new().");
       return NULL;
     }
 
@@ -197,6 +198,8 @@ meta_wayland_client_spawnv (MetaWaylandClient   *client,
   g_subprocess_launcher_setenv (client->launcher, "WAYLAND_SOCKET", "3", TRUE);
   wayland_client = wl_client_create (compositor->wayland_display, client_fd[0]);
   subprocess = g_subprocess_launcher_spawnv (client->launcher, argv, error);
+  g_clear_object (&client->launcher);
+  client->process_launched = TRUE;
 
   if (subprocess == NULL)
     return NULL;


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