[libpeas] Check that the manager's view has the same engine



commit 83a724bea319a1caaaa36bb7fab596e9feb55ad7
Author: Garrett Regier <alias301 gmail com>
Date:   Fri Feb 11 03:11:49 2011 -0800

    Check that the manager's view has the same engine

 libpeas-gtk/peas-gtk-plugin-manager.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/libpeas-gtk/peas-gtk-plugin-manager.c b/libpeas-gtk/peas-gtk-plugin-manager.c
index 7e4ce8e..237c373 100644
--- a/libpeas-gtk/peas-gtk-plugin-manager.c
+++ b/libpeas-gtk/peas-gtk-plugin-manager.c
@@ -476,6 +476,28 @@ peas_gtk_plugin_manager_constructed (GObject *object)
    */
   peas_engine_rescan_plugins (pm->priv->engine);
 
+  /* For the view to behave as expected, we must ensure it uses the same
+   * engine as the manager itself.
+   */
+  if (pm->priv->view != NULL)
+    {
+      PeasEngine *engine;
+
+      g_object_get (pm->priv->view,
+                    "engine", &engine,
+                    NULL);
+
+      g_warn_if_fail (engine == pm->priv->engine);
+
+      if (engine != pm->priv->engine)
+        {
+          g_object_unref (pm->priv->view);
+          pm->priv->view = NULL;
+        }
+
+      g_object_unref (engine);
+    }
+
   if (pm->priv->view == NULL)
     pm->priv->view = peas_gtk_plugin_manager_view_new (pm->priv->engine);
 



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