From b79c07f827f487e380392ae70bf23f50805236d4 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 2 Jan 2014 00:57:00 +0000 Subject: Fixed major issues with wrong Python refcounting. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@364 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 7 ++++ plugins/pychrysa/gui/panels/panel.c | 1 + plugins/pychrysa/plugin.c | 73 +------------------------------------ plugins/pychrysa/pychrysa.c | 2 +- 4 files changed, 11 insertions(+), 72 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68bc8bf..c9c6f9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +14-01-02 Cyrille Bagard + + * plugins/pychrysa/gui/panels/panel.c: + * plugins/pychrysa/plugin.c: + * plugins/pychrysa/pychrysa.c: + Fix major issues with wrong Python refcounting. + 13-12-29 Cyrille Bagard * src/main.c: diff --git a/plugins/pychrysa/gui/panels/panel.c b/plugins/pychrysa/gui/panels/panel.c index fc261b5..7aa5fa7 100644 --- a/plugins/pychrysa/gui/panels/panel.c +++ b/plugins/pychrysa/gui/panels/panel.c @@ -101,6 +101,7 @@ PyObject *_py_panel_item_from_c(GPanelItem *item, PyTypeObject *type) module = PyImport_ImportModule("pychrysalide.gui.panels"); type = (PyTypeObject *)PyObject_GetAttrString(module, "PanelItem"); Py_DECREF(module); + /* FIXME : type refcount ? */ } else Py_INCREF(type); diff --git a/plugins/pychrysa/plugin.c b/plugins/pychrysa/plugin.c index dd2517b..05d56d0 100644 --- a/plugins/pychrysa/plugin.c +++ b/plugins/pychrysa/plugin.c @@ -134,70 +134,6 @@ static PyObject *pychrysa_plugin_handle_debugger(PyObject *, PyObject *); -#if 0 - - - -int -main2(const char *filename, const char *method) -{ - PyObject *pName, *pModule, *pDict, *pFunc; - PyObject *pArgs, *pValue; - int i; - return 0; - pName = PyString_FromString/*PyUnicode_FromString*/(filename); - /* Error checking of pName left out */ - - pModule = PyImport_Import(pName); - Py_DECREF(pName); - - if (pModule != NULL) { - pFunc = PyObject_GetAttrString(pModule, method); - /* pFunc is a new reference */ - - if (pFunc && PyCallable_Check(pFunc)) { - pArgs = PyTuple_New(0/*argc - 3*/); - - pValue = PyObject_CallObject(pFunc, pArgs); - Py_DECREF(pArgs); - if (pValue != NULL) { - printf("Result of call: %ld\n", PyLong_AsLong(pValue)); - Py_DECREF(pValue); - } - else { - Py_DECREF(pFunc); - Py_DECREF(pModule); - PyErr_Print(); - fprintf(stderr,"Call failed\n"); - return 1; - } - } - else { - if (PyErr_Occurred()) - PyErr_Print(); - fprintf(stderr, "Cannot find function \"%s\"\n", method); - } - Py_XDECREF(pFunc); - Py_DECREF(pModule); - } - else { - PyErr_Print(); - fprintf(stderr, "Failed to load \"%s\"\n", filename); - return 1; - } - return 0; -} - - -#endif - - - - - - - - @@ -296,7 +232,6 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename) dict = PyModule_GetDict(module); class = PyDict_GetItemString(dict, modname); - Py_DECREF(dict); if (class == NULL) goto gppn_no_class; if (!PyType_Check(class->ob_type)) goto gppn_no_class; @@ -304,8 +239,6 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename) instance = PyObject_CallFunction(class, NULL); if (instance == NULL) goto gppn_no_instance; - Py_DECREF(class); - result = g_object_new(G_TYPE_PYTHON_PLUGIN, NULL); G_PLUGIN_MODULE(result)->name = strdup(modname); @@ -324,8 +257,6 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename) gppn_no_instance: - Py_DECREF(class); - gppn_no_class: Py_DECREF(module); @@ -762,9 +693,9 @@ static PyObject *pychrysa_plugin_is_matching(PyObject *self, PyObject *args) result = PyTuple_New(3); PyTuple_SetItem(result, 0, PyInt_FromLong(MFA_NONE)); - Py_DECREF(Py_None); + //Py_DECREF(Py_None); PyTuple_SetItem(result, 1, Py_None); - Py_DECREF(Py_None); + //Py_DECREF(Py_None); PyTuple_SetItem(result, 2, Py_None); return result; diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c index e7491ce..ee94f31 100644 --- a/plugins/pychrysa/pychrysa.c +++ b/plugins/pychrysa/pychrysa.c @@ -129,7 +129,7 @@ bool init_plugin(GPluginModule *plugin, GObject *ref) Py_Initialize(); - pychrysalide_set_gc_threshold(INT_MAX, INT_MAX, INT_MAX); + //pychrysalide_set_gc_threshold(INT_MAX, INT_MAX, INT_MAX); //pychrysalide_set_gc_threshold(1, 1, 1); initpychrysa(); -- cgit v0.11.2-87-g4458