[libpeas] python: Rework refcounting to explicit extension ownership
- From: Steve Frécinaux <sfre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] python: Rework refcounting to explicit extension ownership
- Date: Tue, 22 Feb 2011 19:13:16 +0000 (UTC)
commit 92b255f9b76a8bed118d1901105e6a87e7014b9f
Author: Steve Frécinaux <code istique net>
Date: Tue Feb 22 13:56:45 2011 +0100
python: Rework refcounting to explicit extension ownership
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.
loaders/python/peas-extension-python.c | 1 +
loaders/python/peas-plugin-loader-python.c | 2 ++
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]