gtk_widget_ensure_style() and gtk_widget_style_get()



Today I experienced an odd lockup in Nautilus (cf. attachment for the
full backtrace). The innermost frames are:

#1  0xb6e783ee in bsearch () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7c50047 in _gtk_style_peek_property_value ()
from /opt/gnome/lib/libgtk-x11-2.0.so.0
#3  0xb7d02dae in gtk_widget_style_get_valist ()
from /opt/gnome/lib/libgtk-x11-2.0.so.0
#4  0xb7d02fa2 in gtk_widget_style_get ()
from /opt/gnome/lib/libgtk-x11-2.0.so.0
#5  0xb7c0d1c6 in gtk_range_get_props ()
from /opt/gnome/lib/libgtk-x11-2.0.so.0

Investigating #5 gtk_range_get_props() revealed that it calls #4
gtk_widget_style_get() correctly.

However, does a widget always have a valid style associated? Reading
gtk_widget_init() suggests that. It also looks like before realizing or
calling gtk_widget_ensure_style(), that style is just the default style,
meaning that no user changes (i.e. to ~/.gtkrc-2.0) are applied.

On the other hand, reading the gtk_widget_ensure_style() docs suggests
that a widget is not guaranteed to have a style until it is realized.

I also discovered odd inconsistencies in the GTK+ source code, for
instance in gtktoolbar.c the get_button_relief() function calls
gtk_widget_ensure_style() before  gtk_widget_style_get(), but the
get_internal_padding() function does not.


Back to the Nautilus issue: I wonder how the crash can happen.

Maybe some widget is abusing the GTK+ API, and somehow messing
up/destroying the default style? For instance, EelEditableLabel (also
used by the canvas widget using the GtkRange) is derived from GtkMisc,
and does not chain up the GtkWidget::realize() its implementation,
consequently it does not call gtk_widget_ensure_style(). In its
realize() implementation. So it seems to call gtk_style_attach() on the
default style (also inside realize()). Reading through the GtkStyle docs
this seems to be OK, though.

Maybe anybody could shed some light on GtkStyles, and their possible
relation to the crasher? The docs seem to be a bit vague.

best regards,
 Christian


-- 
Christian Neumair <cneumair gnome org>
#0  0xb7c4ac1d in style_property_values_cmp () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#1  0xb6e783ee in bsearch () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7c50047 in _gtk_style_peek_property_value () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#3  0xb7d02dae in gtk_widget_style_get_valist () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#4  0xb7d02fa2 in gtk_widget_style_get () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#5  0xb7c0d1c6 in gtk_range_get_props () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#6  0xb7c0d415 in gtk_range_calc_layout () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#7  0xb7c0e394 in gtk_range_adjustment_changed () from /opt/gnome/lib/libgtk-x11-2.0.so.0
(...)
#12 0xb71ea592 in g_signal_emit_by_name () from /opt/gtk/lib/libgobject-2.0.so.0
#13 0xb77e265d in eel_canvas_size_allocate () from /opt/gnome/lib/libeel-2.so.2
#14 0x0811c54b in size_allocate (widget=0x819c248, allocation=0xbf93783c) at nautilus-icon-container.c:3388
(...)
#20 0xb71e7e89 in g_signal_emit () from /opt/gtk/lib/libgobject-2.0.so.0
#21 0xb7d085f7 in gtk_widget_size_allocate () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#22 0xb7c338fb in gtk_scrolled_window_size_allocate () from /opt/gnome/lib/libgtk-x11-2.0.so.0
(...)
#28 0xb71e7e89 in g_signal_emit () from /opt/gtk/lib/libgobject-2.0.so.0
#29 0xb7d085f7 in gtk_widget_size_allocate () from /opt/gnome/lib/libgtk-x11-2.0.so.0
(...)
#36 0xb71e7e89 in g_signal_emit () from /opt/gtk/lib/libgobject-2.0.so.0
#37 0xb7d085f7 in gtk_widget_size_allocate () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#38 0xb7cfc5d6 in gtk_vbox_size_allocate () from /opt/gnome/lib/libgtk-x11-2.0.so.0
(...)
#44 0xb71e7e89 in g_signal_emit () from /opt/gtk/lib/libgobject-2.0.so.0
#45 0xb7d085f7 in gtk_widget_size_allocate () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#46 0xb7b7d392 in gtk_hpaned_size_allocate () from /opt/gnome/lib/libgtk-x11-2.0.so.0
#47 0x08111d3f in nautilus_horizontal_splitter_size_allocate (widget=0x8294800, allocation=0xbf938f4c) at nautilus-horizontal-splitter.c:242


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]