[calls] manager: Temporarily hold a reference to provider being unloaded



commit d5bf31bdaf850fe01b2c43ae14d85346b600a89d
Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
Date:   Wed Jul 7 16:12:23 2021 +0200

    manager: Temporarily hold a reference to provider being unloaded

 src/calls-manager.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/calls-manager.c b/src/calls-manager.c
index d5d7b3ee..2c1045ad 100644
--- a/src/calls-manager.c
+++ b/src/calls-manager.c
@@ -379,13 +379,16 @@ remove_provider (CallsManager *self,
 {
   GListModel *origins;
   guint n_items;
-  CallsProvider *provider;
+  g_autoptr (CallsProvider) provider;
 
   g_assert (CALLS_IS_MANAGER (self));
   g_assert (name);
 
   provider = g_hash_table_lookup (self->providers, name);
-  if (provider == NULL) {
+  if (provider) {
+    /* Hold a ref since g_hash_table_remove () might drop the last one */
+    g_object_ref (provider);
+  } else {
     g_warning ("Trying to remove provider %s which has not been found", name);
     return;
   }


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