summaryrefslogtreecommitdiffstats
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
parent2f0295c4790abbeb97f6106df68815a028513b7a (diff)
downloadpygobject-312a94f41a11802edcac19ecc44bf73ac1c7adba.tar.gz
pygobject-312a94f41a11802edcac19ecc44bf73ac1c7adba.tar.xz
pygobject-312a94f41a11802edcac19ecc44bf73ac1c7adba.zip
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.
-rw-r--r--gobject/pygobject.c7
-rw-r--r--gobject/pygtype.c23
2 files changed, 25 insertions, 5 deletions
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index 07a33a7..efa51b2 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -991,7 +991,10 @@ pygobject_chain_from_overridden(PyGObject *self, PyObject *args)
for (i = 0; i < query.n_params; i++) {
PyObject *item = PyTuple_GetItem(args, i);
- if (pyg_value_from_pyobject(&params[i+1], item) < 0) {
+ if (pyg_boxed_check(item, (query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE))) {
+ g_value_set_static_boxed(&params[i+1], pyg_boxed_get(item, void));
+ }
+ else if (pyg_value_from_pyobject(&params[i+1], item) < 0) {
gchar buf[128];
g_snprintf(buf, sizeof(buf),
@@ -1011,7 +1014,7 @@ pygobject_chain_from_overridden(PyGObject *self, PyObject *args)
for (i = 0; i < query.n_params + 1; i++)
g_value_unset(&params[i]);
g_free(params);
- if ((query.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE) != G_TYPE_NONE) {
+ if (query.return_type != G_TYPE_NONE) {
py_ret = pyg_value_as_pyobject(&ret, TRUE);
g_value_unset(&ret);
} else {
diff --git a/gobject/pygtype.c b/gobject/pygtype.c
index 56eca37..85bef4a 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);