[libpeas] Free the registered extension impls when the object module is unloaded



commit 5751032b551aa19e6d75dde4332b0dfaeaa2f708
Author: Garrett Regier <garrettregier gmail com>
Date:   Wed Sep 10 01:58:06 2014 -0700

    Free the registered extension impls when the object module is unloaded
    
    When the object module is reloaded they will all be added again as
    peas_register_types() will be called.
    
    This caused problems when checking if the interface was already
    registered as it was always already registered when reloading the
    module.

 libpeas/peas-object-module.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/libpeas/peas-object-module.c b/libpeas/peas-object-module.c
index 1f36ec7..474a173 100644
--- a/libpeas/peas-object-module.c
+++ b/libpeas/peas-object-module.c
@@ -147,11 +147,23 @@ static void
 peas_object_module_unload (GTypeModule *gmodule)
 {
   PeasObjectModule *module = PEAS_OBJECT_MODULE (gmodule);
+  InterfaceImplementation *impls;
+  guint i;
 
   g_module_close (module->priv->library);
 
   module->priv->library = NULL;
   module->priv->register_func = NULL;
+
+  impls = (InterfaceImplementation *) module->priv->implementations->data;
+  for (i = 0; i < module->priv->implementations->len; ++i)
+    {
+      if (impls[i].destroy_func != NULL)
+        impls[i].destroy_func (impls[i].user_data);
+    }
+
+  g_array_remove_range (module->priv->implementations, 0,
+                        module->priv->implementations->len);
 }
 
 static void
@@ -168,17 +180,9 @@ static void
 peas_object_module_finalize (GObject *object)
 {
   PeasObjectModule *module = PEAS_OBJECT_MODULE (object);
-  InterfaceImplementation *impls;
-  unsigned i;
 
   g_free (module->priv->path);
   g_free (module->priv->module_name);
-
-  impls = (InterfaceImplementation *) module->priv->implementations->data;
-  for (i = 0; i < module->priv->implementations->len; ++i)
-    if (impls[i].destroy_func != NULL)
-      impls[i].destroy_func (impls[i].user_data);
-
   g_array_unref (module->priv->implementations);
 
   G_OBJECT_CLASS (peas_object_module_parent_class)->finalize (object);


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