[gnome-builder] threading: steal source pointer before destroying



commit 8e93e11cdcaa509f0c4180dcf214a9f321a28d1a
Author: Christian Hergert <chergert redhat com>
Date:   Thu Feb 18 14:24:41 2021 -0800

    threading: steal source pointer before destroying
    
    Probably doesn't fix #1400 but might have a small effect. Honestly, I wish
    we could get rid of GCancellable altogether because of racing in designs
    beneath us.

 src/libide/threading/ide-flatpak-subprocess.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/threading/ide-flatpak-subprocess.c b/src/libide/threading/ide-flatpak-subprocess.c
index 619e52107..f0ce144a8 100644
--- a/src/libide/threading/ide-flatpak-subprocess.c
+++ b/src/libide/threading/ide-flatpak-subprocess.c
@@ -633,11 +633,13 @@ ide_subprocess_communicate_state_free (gpointer data)
   g_clear_object (&state->stdout_buf);
   g_clear_object (&state->stderr_buf);
 
-  if (state->cancellable_source)
+  if (state->cancellable_source != NULL)
     {
-      if (!g_source_is_destroyed (state->cancellable_source))
-        g_source_destroy (state->cancellable_source);
-      g_source_unref (state->cancellable_source);
+      GSource *source = g_steal_pointer (&state->cancellable_source);
+
+      if (!g_source_is_destroyed (source))
+        g_source_destroy (source);
+      g_source_unref (source);
     }
 
   g_slice_free (CommunicateState, state);


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