After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 661673 - gedit / External Tools - cannot change language of tools
gedit / External Tools - cannot change language of tools
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
3.0.x
Other Linux
: Normal critical
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-10-13 15:52 UTC by Michael Knap
Modified: 2011-10-25 14:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test.py (362 bytes, text/plain)
2011-10-16 17:04 UTC, Ignacio Casal Quinteiro (nacho)
  Details
Do union member checks for unions that are parameters (6.12 KB, patch)
2011-10-18 13:05 UTC, johnp
committed Details | Review
simple tree test case (527 bytes, text/x-python)
2011-10-20 14:17 UTC, Mike
  Details

Description Michael Knap 2011-10-13 15:52:34 UTC
A user cannot constrain a tool to a language. Upon attempting to select a language, the pop-up is shown, however none can be selected. 

Output to the terminal is

Traceback (most recent call last):
  • File "/usr/lib/gedit/plugins/externaltools/manager.py", line 255 in do_motion_notify_event
    return self.propagate_mouse_event(event)
  • File "/usr/lib/gedit/plugins/externaltools/manager.py", line 234 in propagate_mouse_event
    if widget.event(event):
  • File "/usr/lib/python2.7/dist-packages/gi/types.py", line 43 in function
    return info.invoke(*args, **kwargs)
TypeError: Expected Gdk.Event, but got StructMeta

Comment 1 Ignacio Casal Quinteiro (nacho) 2011-10-13 16:04:33 UTC
I think this is a pygobject problem as it was working with 2.28.
Comment 2 johnp 2011-10-14 21:41:26 UTC
I need a simple test case to debug this.
Comment 3 Ignacio Casal Quinteiro (nacho) 2011-10-16 17:04:28 UTC
Created attachment 199134 [details]
test.py

As commanded, the test case ;)
Comment 4 johnp 2011-10-18 13:05:39 UTC
Created attachment 199327 [details] [review]
Do union member checks for unions that are parameters

* before we were only doing checks if the union was an instance
Comment 5 johnp 2011-10-18 13:15:01 UTC
This is the fix.  I'm trying to get the event tests working again but the gtk test methods for simulating key presses and button clicks don't work for some reason which is why we missed this.

I spend a bit debugging what turned out to be a red herring in the test case that was posted here.  At some point all objects were returing NULL for their attribute dictionary.  Turns out it was just a recursion limit hit by the call to self.event(event) so I now propagate any exceptions encountered when calling _is_union_memeber.

enjoy
Comment 6 johnp 2011-10-18 17:38:18 UTC
tests don't work because we need to call gtk_test_init but that would require a static helper library since gtk_test_init takes varargs.  punting tests for now.  need to think of a better way of handling this.
Comment 7 Ignacio Casal Quinteiro (nacho) 2011-10-18 22:19:04 UTC
Works perfect in gedit.
Comment 8 Mike 2011-10-20 14:17:48 UTC
Created attachment 199531 [details]
simple tree test case

i think im seeing the same bug as this, ill attack a simple test case too, this is with the latest git compiled after commit
http://git.gnome.org/browse/pygobject/commit/?id=585222915dc98b0e375de3db4771466278a32e81

ill attach a simple test case
Comment 9 johnp 2011-10-24 17:33:44 UTC
> print event #prints <void at 0x22746a0> this should be Gdk.Event surely? under gtk2 was gtk.gdk.Event


void is correct, you are getting the structure Gdk.MotionEvent.  All structs are void typed because they don't have a type in the GObject type system.

In reality the union's pointer is the same as the actual stuct member but it is really complicated to represent this in pygobject since they don't really derive from each other.  Parent type information is lost when accessing event.motion_event.  At some point we may wish to keep a parent pointer back to the enum but that is dangerous in itself.  First we aren't even sure if the structure came from an enum as it could have been created explicitly and second if the user has access to the raw event they can easily deref a NULL pointer by accessing a structure that is larger than the intended event type.

If you are trying to check the type of the event please use event.type instead of trying to directly compare the event itself.  Personally I would have liked to special case Events but that is not easily done because it would add a dependency on Gdk/Gtk which we explicitly try to avoid.
Comment 10 johnp 2011-10-24 17:37:20 UTC
and by enum I of course meant union
Comment 11 Mike 2011-10-25 14:33:37 UTC
ah ok, i see, so its a GObject.TYPE_NONE now instead of a Gdk.Event, thanks for clearing that up