summaryrefslogtreecommitdiff
path: root/gobject/pygtype.c
diff options
context:
space:
mode:
authorJohan Dahlin <zilch@src.gnome.org>2004-03-04 17:39:17 +0000
committerJohan Dahlin <zilch@src.gnome.org>2004-03-04 17:39:17 +0000
commit312a94f41a11802edcac19ecc44bf73ac1c7adba (patch)
tree27e9dcd5c9921382dc05a1aebc7a0bb65febedc7 /gobject/pygtype.c
parent2f0295c4790abbeb97f6106df68815a028513b7a (diff)
downloadpygobject-312a94f41a11802edcac19ecc44bf73ac1c7adba.tar.gz
Fixes for bug 132704, Patch by John Ehresman.
* pygobject.c (pygobject_chain_from_overridden): * pygtype.c (pyg_signal_class_closure_marshal): Fixes for bug 132704, Patch by John Ehresman.
Diffstat (limited to 'gobject/pygtype.c')
-rw-r--r--gobject/pygtype.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/gobject/pygtype.c b/gobject/pygtype.c
index 56eca377..85bef4a1 100644
--- a/gobject/pygtype.c
+++ b/gobject/pygtype.c
@@ -850,7 +850,7 @@ pyg_signal_class_closure_marshal(GClosure *closure,
gchar *method_name, *tmp;
PyObject *method;
PyObject *params, *ret;
- guint i;
+ guint i, len;
g_return_if_fail(invocation_hint != NULL);
@@ -883,10 +883,11 @@ pyg_signal_class_closure_marshal(GClosure *closure,
}
Py_DECREF(object_wrapper);
- /* construct Python tuple for the parameter values */
+ /* construct Python tuple for the parameter values; don't copy boxed values
+ initially because we'll check after the call to see if a copy is needed. */
params = PyTuple_New(n_param_values - 1);
for (i = 1; i < n_param_values; i++) {
- PyObject *item = pyg_value_as_pyobject(&param_values[i], TRUE);
+ PyObject *item = pyg_value_as_pyobject(&param_values[i], FALSE);
/* error condition */
if (!item) {
@@ -898,6 +899,22 @@ pyg_signal_class_closure_marshal(GClosure *closure,
}
ret = PyObject_CallObject(method, params);
+
+ /* Copy boxed values if others ref them, this needs to be done regardless of
+ exception status. */
+ len = PyTuple_Size(params);
+ for (i = 0; i < len; i++) {
+ PyObject *item = PyTuple_GetItem(params, i);
+ if (item != NULL && PyObject_TypeCheck(item, &PyGBoxed_Type)
+ && item->ob_refcnt != 1) {
+ PyGBoxed* boxed_item = (PyGBoxed*)item;
+ if (!boxed_item->free_on_dealloc) {
+ boxed_item->boxed = g_boxed_copy(boxed_item->gtype, boxed_item->boxed);
+ boxed_item->free_on_dealloc = TRUE;
+ }
+ }
+ }
+
if (ret == NULL) {
PyErr_Print();
Py_DECREF(method);