Re: Too many args to GTK2.TextBuffer "mark_set" signal
Chris Angelico <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAPTjJmo3oB-jfkZJHKvg_Pm-vSUrjut22Bh+d_K6WarudOogvg@mail.gmail.com> |
On Sun, Jan 5, 2014 at 8:08 AM, Lance Dillon <[email protected]> wrote: > Sometimes I'm getting 0, sometimes 3600.0 (as shown in some of your > results), and sometimes Pike.Backend(0). Probably again something about the > stack. Trying to track it down. It has something to do with signal_connect > (gobject.pre), pgtk2_marshaller (support.c), and pgtk2_signal_func_wrapper > (support.c), and their interaction with gtk. I'll have to do some more > testing... Picking this up again, I've tracked down what's happening. In pgtk2_push_object_param(), there are a number of branches, most of which result in something being pushed; but one doesn't, and the TextIter hits that one. I've attached a simple patch that fixes the immediate issue by pushing the type name - so instead of getting a GTK2.TextIter object, you get the string "GtkTextIter". That fills in the spot on the stack, ensures that refcounts are correct, and so on, but it's not really ideal. More general solutions might include: 1) Having some other way to push an object - something else that goes into the same slot where my patch adds a PUSH_GCHAR 2) Having pgtk2_signal_func_wrapper snapshot the stack pointer and pass the difference between current stack and old stack to apply_svalue, instead of expecting 2+n_params to be right 3) Making use of the return values, and then making sure they're all correct (generally the callbacks return PUSHED_VALUE, and one returns NEED_RETURN, but nothing ever seems to look at that (???)). I'd be inclined to option 1; for callback signature compatibility with other GTK bindings, it's good to have some sort of shim in there rather than just closing up the gap. If it's not possible to push a GTK2.TextIter, I'd look at pushing either the integer 0 or some other constant - hence the patch pushing the class name - just so the order and number of args is correct. ChrisA
0001-Ensure-something-s-pushed-for-every-argument-to-a-GT.patch
(text/x-patch, 955 B)
From e30dc2cdcfe4d08a8eb37eaa1696539c746d3360 Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Sat, 15 Mar 2014 23:08:34 +1100 Subject: [PATCH] Ensure something's pushed for every argument to a GTK2 signal callback --- src/post_modules/GTK2/source/support.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/post_modules/GTK2/source/support.c b/src/post_modules/GTK2/source/support.c index 5aa8967..49d77e1 100644 --- a/src/post_modules/GTK2/source/support.c +++ b/src/post_modules/GTK2/source/support.c @@ -589,6 +589,9 @@ static int pgtk2_push_object_param(const GValue *a) { push_gdkobject(gp,rectangle,0); } else if (G_VALUE_HOLDS(a,g_type_from_name("GdkRegion"))) { push_gdkobject(gp,region,0); + } else { + /* Don't know how to push this sort of object, so push its name */ + PGTK_PUSH_GCHAR(G_VALUE_TYPE_NAME(a)); } } else { obj=g_value_get_object(a); -- 1.7.10.4