[gnome-network-displays/benzea/keep-reference-during-removal] meta-provider: Keep a reference during removal




commit a4a6b61d5ecb50cc8dd491c1caf6057d32d0be02
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Jun 20 10:29:19 2022 +0200

    meta-provider: Keep a reference during removal
    
    We might drop the last reference to a sink before emitting the signal
    that it has been removed. Fix this by explicitly keeping a reference
    within provider_sink_removed_cb.
    
    See: #243

 src/nd-meta-provider.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/nd-meta-provider.c b/src/nd-meta-provider.c
index a74673a..2128c6b 100644
--- a/src/nd-meta-provider.c
+++ b/src/nd-meta-provider.c
@@ -101,7 +101,7 @@ static void
 provider_sink_removed_cb (NdMetaProvider *meta_provider, NdSink *sink, NdProvider *provider)
 {
   g_autoptr(GPtrArray) sink_matches = NULL;
-  NdMetaSink *meta_sink = NULL;
+  g_autoptr(NdMetaSink) meta_sink = NULL;
   guint idx = 0;
 
   g_object_get (sink, "matches", &sink_matches, NULL);
@@ -116,7 +116,7 @@ provider_sink_removed_cb (NdMetaProvider *meta_provider, NdSink *sink, NdProvide
                                               (GEqualFunc) nd_meta_sink_has_sink,
                                               &idx));
 
-  meta_sink = g_ptr_array_index (meta_provider->sinks, idx);
+  meta_sink = g_object_ref (g_ptr_array_index (meta_provider->sinks, idx));
   g_assert (meta_sink != NULL);
   if (nd_meta_sink_remove_sink (meta_sink, sink))
     {


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