[gnome-builder/gnome-builder-3-26] workbench: handle GInitiallyUnowned addins properly



commit c96d4cc29380503a10283de81e2c99186f867e47
Author: Christian Hergert <chergert redhat com>
Date:   Mon Sep 25 23:48:21 2017 -0700

    workbench: handle GInitiallyUnowned addins properly
    
    If we have a plugin that is also a widget, we could get into a
    position where we lose the object reference. So ensure that we
    sink the reference automatically.

 libide/workbench/ide-workbench.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/libide/workbench/ide-workbench.c b/libide/workbench/ide-workbench.c
index 2ecd675..008d903 100644
--- a/libide/workbench/ide-workbench.c
+++ b/libide/workbench/ide-workbench.c
@@ -518,15 +518,20 @@ ide_workbench_addin_added (PeasExtensionSet *set,
                            gpointer          user_data)
 {
   IdeWorkbench *self = user_data;
+  IdeWorkbenchAddin *addin = (IdeWorkbenchAddin *)extension;
 
   g_assert (PEAS_IS_EXTENSION_SET (set));
   g_assert (plugin_info != NULL);
-  g_assert (IDE_IS_WORKBENCH_ADDIN (extension));
+  g_assert (IDE_IS_WORKBENCH_ADDIN (addin));
   g_assert (IDE_IS_WORKBENCH (self));
 
   IDE_TRACE_MSG ("Loading workbench addin for %s",
                  peas_plugin_info_get_module_name (plugin_info));
 
+  /* Handle extensions that are widgets */
+  if (g_object_is_floating (G_OBJECT (addin)))
+    g_object_ref_sink (addin);
+
   ide_workbench_addin_load (IDE_WORKBENCH_ADDIN (extension), self);
 }
 


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