GNOME Bugzilla – Bug 143537
Delayed formating when applying a tag on text thats being typed
Last modified: 2005-05-27 03:02:53 UTC
When gaim released 0.76 with the new WYSIWYG formatting, we've noticed that the background color doesn't always get applied to the last typed character. It happened rather rarely on 2.2.4, generall only when under heavy load, but in 2.4.1 it happens much more often. The background color is the only formatting we seem to be having a problem with, and thus are report it to you. We've only had this bug reported for users running linux but it may exist on others. Our initial report of it can be found here, http://sourceforge.net/tracker/index.php?func=detail&aid=942086&group_id=235&atid=100235 As mentioned earlier it only happens with background color formatting. We're using a g_signal_connect_after for the key press signal, and then appling the tag.
How exactly do you set the background color ? Could you please provide a small, selfcontained testcase which shows the problem ? (A patch against, e.g. testtext.c would be fine)
Will do, I'll have the patch uploaded tonight.
Created attachment 32311 [details] the proof of concept code..
I ended up creating a standalone. The signals being used were a bit off in my initial report, but the code is pretty easy to follow. The delayed formatting on the last character is more often than not noticed on puncuation, but does happen for other characters as well.
Is this the bug? _gtk_text_btree_tag calls queue_tag_redisplay before it modifies any tags. Surely this call should be at the end of the function? As it stands, the redisplay occurs before any tags are modified, and there is no redisplay afterwards. The new tags are only displayed when a redisplay is called from a timeout (it seems to happen after about 1 second on my system).
No, that just queues a redisplay. The actual redisplay will not happen until the next idle, ie after _gtk_text_btree_tag has finished.
Aha! That's how it is supposed to work. The problem is that the layout cache (one_display_cache) gets filled again (using the old tags) even before queue_tag_redisplay returns. My program is too large to post (even if I had the right to do so). However, the following stack dump shows where the cache gets refilled, after it has been invalidated but before any modification to the tags takes place. I find that placing another queue_tag_redisplay at the end of the _gtk_text_btree_tag does fix the problem for me. It also fixes the testcase previously filed against this bug, so I guess this is the same problem. This is using version gtk2-2.4.14-3.fc3 (Fedora Core 3). /* Free this if we aren't in a loop */ if (layout->wrap_loop_count == 0) invalidate_cached_style (layout); g_free (text); pango_attr_list_unref (attrs); layout->one_display_cache = display; /* <--- gtktextlayout.c:2123 */ if (saw_widget) allocate_child_widgets (layout, display); return display; } Currently logging to "out.dat". Logs will be appended to the log file. Output will be logged and displayed.
+ Trace 60183
Peter Wainwright
2005-05-26 Matthias Clasen <mclasen@redhat.com> * gtk/gtktextbtree.c (_gtk_text_btree_tag): Queue the redisplay after modifying the tag in the btree, otherwise we end up showing the old tags until the next redraw comes around. (#143537, Gary Kramlich)