[Webkit-unassigned] [Bug 77835] [GObject bindings] Missing scope annotations for add/remove_event_listener

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Feb 11 08:07:40 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=77835





--- Comment #15 from Zan Dobersek <zandobersek at gmail.com>  2012-02-11 08:07:40 PST ---
(In reply to comment #14)
> but first, one thought. here is a diff of the generated GIRs:
> 
> http://dpaste.com/hold/701377/
> 
> ... as suspected prior, the GIR contains no information about what args the GCallback will receive (generic?), and in the sources GCallback itself is defined as `typedef void (*GCallback) (void)` ...
> 
> so, while i'm not sure why introspection doesn't pick up the cast to `GObjectEventListenerCallback`, maybe we can try:
> 
> @handler: (type GObjectEventListenerCallback) [...]
> 
> ... or, does this make sense:
> 
> typedef GCallback GObjectEventListenerCallback ([...]);
> 
> .. but maybe that's redundant/ridiculous.  like i said, i'm a n00b :-) but i think i have a bunch if good ideas to try, and hopefully get something landed ASAP.

With the changes I'm recommending the GCallback-typed function is no longer used.  Rather than that, I've typedefed the WebKitDOMEventListenerFunc (the DOMEventListenerFunc callback in the .gir). It is basically the GObjectEventListenerCallback typedef, but moved into the header so it is available in the API. Because of that it can be then used in add_ and remove_event_listener instead of GCallback. This fixes the problem of missing arguments as it seems that pygobject doesn't care about GCallbacks that are actually different callbacks but typecasted into a GCallback, which results in those callbacks being called with no arguments at all. Again, that's at least what I think is going on, so I may very well be wrong.

About the remove_event_listener - True, the 'call' scope is more appropriate. This still doesn't fix the issue of the function not working at all.
The conditions under which the listener is removed require that the pointers to the callbacks that are passed through in add_event_listener and remove_event_listener are the same. I've put a 'print hex(id(self.on_close))' line into the test case, printing the location of the self.on_close function. With some output in add_ and remove_event_listener it becomes evident that handlers passed through those two functions never equal the output of the line added in the test case, thus it is impossible to remove an event listener after it's added. Again, I'm thinking this might be pygobject's fault. I'll look into that when possible.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list