diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-07-23 18:57:49 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-07-23 19:01:46 (GMT) |
commit | abefe01dd260cddbd253ba0c03d9c903138c71c1 (patch) | |
tree | 834f683e79893534324af94c537984542b7dc00a /plugins | |
parent | 50eb8c462e7ad2b4e5b82d27b1af6e86091ea272 (diff) |
Tracked the reference counter for plugins with more care.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/arm/core.c | 2 | ||||
-rw-r--r-- | plugins/dalvik/core.c | 2 | ||||
-rw-r--r-- | plugins/pychrysalide/plugin.c | 22 | ||||
-rw-r--r-- | plugins/pychrysalide/pychrysa.c | 13 |
4 files changed, 35 insertions, 4 deletions
diff --git a/plugins/arm/core.c b/plugins/arm/core.c index 6a512b2..d2dd805 100644 --- a/plugins/arm/core.c +++ b/plugins/arm/core.c @@ -33,7 +33,7 @@ DEFINE_CHRYSALIDE_PLUGIN("arm", "Add support for the ARM architecture", "0.1.0", - RL("PyChrysalide"), AL(PGA_PLUGIN_INIT)); + RL("PyChrysalide"), AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT)); diff --git a/plugins/dalvik/core.c b/plugins/dalvik/core.c index 524e3c9..2e936b9 100644 --- a/plugins/dalvik/core.c +++ b/plugins/dalvik/core.c @@ -36,7 +36,7 @@ DEFINE_CHRYSALIDE_PLUGIN("dalvik", "Add support for the Dalvik architecture", "0.1.0", - RL("PyChrysalide"), AL(PGA_PLUGIN_INIT)); + RL("PyChrysalide"), AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT)); diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c index b57794c..a916668 100644 --- a/plugins/pychrysalide/plugin.c +++ b/plugins/pychrysalide/plugin.c @@ -25,6 +25,8 @@ #include "plugin.h" +#include <assert.h> +#include <malloc.h> #include <pygobject.h> #include <string.h> @@ -166,6 +168,8 @@ static void g_python_plugin_init(GPythonPlugin *plugin) static void g_python_plugin_dispose(GPythonPlugin *plugin) { + Py_DECREF(plugin->instance); + G_OBJECT_CLASS(g_python_plugin_parent_class)->dispose(G_OBJECT(plugin)); } @@ -185,9 +189,21 @@ static void g_python_plugin_dispose(GPythonPlugin *plugin) static void g_python_plugin_finalize(GPythonPlugin *plugin) { - Py_DECREF(plugin->instance); + plugin_interface *final; /* Interface finale conservée */ + Py_DECREF(plugin->module); + final = (plugin_interface *)G_PLUGIN_MODULE(plugin)->interface; + + if (final != NULL) + { + assert(final->required_count == 1); + + free(final->required); + free(final); + + } + G_OBJECT_CLASS(g_python_plugin_parent_class)->finalize(G_OBJECT(plugin)); } @@ -519,6 +535,10 @@ static bool g_python_plugin_read_interface(GPythonPlugin *plugin) memcpy(final, &interface, sizeof(interface)); + final->required = (const char **)malloc(sizeof(char *)); + final->required[0] = "PyChrysalide"; + final->required_count = 1; + G_PLUGIN_MODULE(plugin)->interface = final; } diff --git a/plugins/pychrysalide/pychrysa.c b/plugins/pychrysalide/pychrysa.c index 4e522e5..c1fdd6f 100644 --- a/plugins/pychrysalide/pychrysa.c +++ b/plugins/pychrysalide/pychrysa.c @@ -59,7 +59,8 @@ -DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("PyChrysalide", "Provides bindings to Python", "0.1.0", PGA_PLUGIN_INIT); +DEFINE_CHRYSALIDE_CONTAINER_PLUGIN("PyChrysalide", "Provides bindings to Python", "0.1.0", + EMPTY_PG_LIST(.required), AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT)); /* Note la nature du chargement */ @@ -402,6 +403,8 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) load_remaning_plugins(); + g_object_unref(G_OBJECT(self)); + } return result; @@ -488,7 +491,15 @@ static bool load_python_plugins(GPluginModule *plugin) g_plugin_module_log_variadic_message(plugin, LMT_PROCESS, _("Loaded the Python plugin found in the '<b>%s</b>' directory"), filename); + + /** + * Comme le greffon n'est pas passé par la résolution des dépendances, + * on simule l'effet attendu. + */ + g_object_ref(G_OBJECT(plugin)); + _register_plugin(pyplugin); + } free(filename); |