[Vala] Gdk.EventKey member Gdk.Window gets destroyed when eventkey is freed-> widget crashes
- From: Julius Pfrommer <julius pfrommer student kit edu>
- To: <vala-list gnome org>
- Subject: [Vala] Gdk.EventKey member Gdk.Window gets destroyed when eventkey is freed-> widget crashes
- Date: Tue, 22 Jun 2010 22:02:44 +0200
Hey,
my aim is to simulate a keypress
public void send_eventkey(string keyname)
{
Gdk.Event event = new Gdk.Event(Gdk.EventType.KEY_PRESS);
uint keyval = Gdk.keyval_from_name(keyname);
Gdk.KeymapKey[] keys;
Gdk.Keymap.get_default().get_entries_for_keyval(keyval, out keys);
Gdk.Window* win = this.get_window();
event.key.window = win;
event.key.send_event = (char)true;
event.key.time = Gdk.CURRENT_TIME;
event.key.state = Gdk.ModifierType.CONTROL_MASK;
event.key.keyval = keyval;
event.key.hardware_keycode = (uint16)keys[0].keycode;
event.key.group = (uchar)keys[0].group;
event.put();
}
The above code results in
Gdk-WARNING **: losing last reference to undestroyed window
and a crashing widget. The problem seems to be the reference towards the
widgets Gdk-Window ( this.get_window() ) which is then deleted because
of no references in Vala-space (though it is still used within the lib).
I tried using pointers to work around the Vala reference counting, but
with no luck so far.
Do you have any ideas regarding this problem?
Best regards,
Julius
PS: The API in this area seems pretty nasty. Especially having to
convert between ints and uchars, etc. shouldn't be necessary within the
"official" gobject-style libs.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]