summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Frécinaux <code@istique.net>2011-02-22 13:56:45 +0100
committerSteve Frécinaux <code@istique.net>2011-02-22 13:56:45 +0100
commit92b255f9b76a8bed118d1901105e6a87e7014b9f (patch)
tree581939d56eda69806e204919f5fecab2f13af691
parentf546844c03dc9f05c234c36638e2ccf3e4a645d3 (diff)
downloadlibpeas-0.7.3.tar.gz
python: Rework refcounting to explicit extension ownership0.7.3
Previously the python reference was transferred to the Python extension object. It is more correct to increment the refcount in the extension and decrement it in the loader, because it's more explicit and won't break in bizarre way if we create more than one Python extension wrapper around the same object.
-rw-r--r--loaders/python/peas-extension-python.c1
-rw-r--r--loaders/python/peas-plugin-loader-python.c2
2 files changed, 3 insertions, 0 deletions
diff --git a/loaders/python/peas-extension-python.c b/loaders/python/peas-extension-python.c
index 630b358..daa0097 100644
--- a/loaders/python/peas-extension-python.c
+++ b/loaders/python/peas-extension-python.c
@@ -95,6 +95,7 @@ peas_extension_python_new (GType gtype,
"extension-type", gtype,
NULL));
pyexten->instance = instance;
+ Py_INCREF (instance);
return PEAS_EXTENSION (pyexten);
}
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index 1cbdf28..f52c27f 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -219,6 +219,8 @@ peas_plugin_loader_python_create_extension (PeasPluginLoader *loader,
Py_DECREF (pyplinfo);
exten = peas_extension_python_new (exten_type, pyobject);
+ Py_DECREF (pyobject);
+
pyg_gil_state_release (state);
return exten;