GNOME Bugzilla – Bug 756524
Storm of "draw" callbacks when using gtk_style_context_get with GTK_STATE_FLAG_PRELIGHT
Last modified: 2015-10-17 08:35:28 UTC
Created attachment 313213 [details] Simple code to illustrate the bug If I use gtk_style_context_get on the widget style context with GTK_STATE_FLAG_PRELIGHT as flag inside the draw callback, I get a storm of callbacks which make the application. I have included a simple test-widget to illustrate the bug. The bug is present in gtk 3.18.*, but not in gtk 3.16.* or gtk 3.14.*
Indeed. If you query a state different than the current one (the one returned via gtk_style_context_get_state()) on an unsaved style context, you cause a style update to the one you queried and later on back to the style context's state. Both of which cause a style_upated signal to be emitted which probably causes a queue_draw()). The quick solution to that problem is to use gtk_style_context_save() before and gtk_style_context_restore() after querying the context. The proper solution is to gtk_widget_set_state_flags() the PRELIGHT state in the enter event and unset it in the leave event and then use gtk_style_context_get_state() in the draw() handler.
Thanks for the quich answer. Why this was not the default behaviour in gtk3.16.* and gtk3.14.*. I mean, one cannot expect that getting a widget style information can cause a style update.
*** Bug 756526 has been marked as a duplicate of this bug. ***
I don't think there's anything to fix here.
Maybe it is a good idea to document it somewhere in the API documentation. As it is difficult to expect that getting style information will lead to a redraw.