[gnome-remote-desktop] rdp-event-queue: Correctly clean up resources



commit 932cc43231340581ee2a697e397ee41939bd0557
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Sat Mar 5 11:49:19 2022 +0100

    rdp-event-queue: Correctly clean up resources
    
    The dispose() method can run multiple times. So, add additional NULL
    checks and run some cleanup functions in finalize, if need be.

 src/grd-rdp-event-queue.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/grd-rdp-event-queue.c b/src/grd-rdp-event-queue.c
index 90ea969b..d6972ab4 100644
--- a/src/grd-rdp-event-queue.c
+++ b/src/grd-rdp-event-queue.c
@@ -385,10 +385,12 @@ grd_rdp_event_queue_dispose (GObject *object)
   process_rdp_events (rdp_event_queue);
 
   g_clear_pointer (&rdp_event_queue->rdp_sync_event, g_free);
-  g_queue_free_full (rdp_event_queue->queue, free_rdp_event);
 
-  g_source_destroy (rdp_event_queue->flush_source);
-  g_clear_pointer (&rdp_event_queue->flush_source, g_source_unref);
+  if (rdp_event_queue->flush_source)
+    {
+      g_source_destroy (rdp_event_queue->flush_source);
+      g_clear_pointer (&rdp_event_queue->flush_source, g_source_unref);
+    }
 
   G_OBJECT_CLASS (grd_rdp_event_queue_parent_class)->dispose (object);
 }
@@ -400,6 +402,8 @@ grd_rdp_event_queue_finalize (GObject *object)
 
   g_mutex_clear (&rdp_event_queue->event_mutex);
 
+  g_queue_free_full (rdp_event_queue->queue, free_rdp_event);
+
   G_OBJECT_CLASS (grd_rdp_event_queue_parent_class)->finalize (object);
 }
 


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