GtkTextView focus crash minor
So, I was obviously doing this the wrong way but, the correct way is gtk_window_set_focus
of course. But it still shouldn't crash. So here was my email to the users list about this, thanks:
I'm trying to get my application to focus on a `GtkTextView, to put the keyboard focus on it. Elsewhere I did
g_signal_emit_by_name(G_OBJECT(thetextview), "focus-in-event", apointer);
and this seemed to work fine, but now it's crashing when I call it from somewhere else, possibly because it's being called from within a signal "key-press-event"
callback for the window.
The crash is all this
(lulu:3300): Gtk-CRITICAL **: _gtk_widget_captured_event: assertion 'GTK_IS_WIDGET (widget)' failed
(lulu:3300): Gtk-CRITICAL **: gtk_widget_get_realized: assertion 'GTK_IS_WIDGET (widget)' failed
(lulu:3300): Gtk-CRITICAL **: gtk_container_get_border_width: assertion 'GTK_IS_CONTAINER (container)' failed
(lulu:3300): Gtk-CRITICAL **: gtk_widget_queue_resize_no_redraw: assertion 'GTK_IS_WIDGET (widget)' failed
(lulu:3300): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
(lulu:3300): GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(lulu:3300): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
(lulu:3300): Gtk-CRITICAL **: gtk_widget_queue_resize: assertion 'GTK_IS_WIDGET (widget)' failed
(lulu:3300): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
==3300== Invalid read of size 8
==3300== at 0x54206D3: gtk_widget_get_request_mode (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x52B3D38: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x526EDA6: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x52B8AD1: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x54206D8: gtk_widget_get_request_mode (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x52B3D38: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x526EDA6: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x52B8AD1: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x54206D8: gtk_widget_get_request_mode (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x542081A: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x5421287: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== at 0x54206D3: gtk_widget_get_request_mode (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x52B3D38: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x526EDA6: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x52B8AD1: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x54206D8: gtk_widget_get_request_mode (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x52B3D38: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x526EDA6: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x52B8AD1: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x54206D8: gtk_widget_get_request_mode (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x542081A: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x5421287: ??? (in /usr/lib64/libgtk-3.so.0.2200.16)
==3300== by 0x542156D: gtk_widget_get_preferred_height_and_baseline_for_width (in /usr/lib64/libgtk-3.so.0.2200.16
And I thought it might have to do with these warnings:
(lulu:3300): Gtk-WARNING **: Allocating size to GtkWindow 0xc854b20 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
But I looked around and I can't seem to find anything out about this.
Is there a preferred way to set keyboard focus on a particular GtkTextView
, and is it supposed to crash if that's done from within the key-press-event
callback on the window? In other words, why does my other emit_signal_by_name
not crash, and what's that warning about the size stuff, is that related?