[gnome-builder] foundry: take a reference to runtime manager



commit 458d04f8c45dfdf22e016261cdceebcea8b2b3bf
Author: Christian Hergert <chergert redhat com>
Date:   Thu Mar 28 12:39:57 2019 -0700

    foundry: take a reference to runtime manager
    
    We might be called from a thread, so we need to take a full reference to
    the context and the runtime manager.
    
    The access to runtime_id should be fine, since that is construct-only.
    
    Related #863

 src/libide/foundry/ide-config.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/foundry/ide-config.c b/src/libide/foundry/ide-config.c
index 6df4cd0dd..bfef341cc 100644
--- a/src/libide/foundry/ide-config.c
+++ b/src/libide/foundry/ide-config.c
@@ -171,8 +171,13 @@ ide_config_real_get_runtime (IdeConfig *self)
 
   if (priv->runtime_id != NULL)
     {
-      IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
-      IdeRuntimeManager *runtime_manager = ide_runtime_manager_from_context (context);
+      g_autoptr(IdeContext) context = NULL;
+      g_autoptr(IdeRuntimeManager) runtime_manager = NULL;
+
+      /* We might be in a thread, ref objects */
+      context = ide_object_ref_context (IDE_OBJECT (self));
+      runtime_manager = ide_object_get_child_typed (IDE_OBJECT (context), IDE_TYPE_RUNTIME_MANAGER);
+
       return ide_runtime_manager_get_runtime (runtime_manager, priv->runtime_id);;
     }
 


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