After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 755413 - Bug in _gtk_text_btree_get_iter_at_last_toggle()
Bug in _gtk_text_btree_get_iter_at_last_toggle()
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
3.18.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 755416
 
 
Reported: 2015-09-22 13:10 UTC by Sébastien Wilmet
Modified: 2015-10-07 15:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
textiter: fix bug in _gtk_text_btree_get_iter_at_last_toggle() (1.59 KB, patch)
2015-09-22 13:12 UTC, Sébastien Wilmet
committed Details | Review
test case (3.82 KB, text/plain)
2015-09-24 08:30 UTC, Sébastien Wilmet
  Details

Description Sébastien Wilmet 2015-09-22 13:10:26 UTC
There is a bug in _gtk_text_btree_get_iter_at_last_toggle() when the last tag toggle is the end iter.

A patch will be attached, it was easy to fix.

Due to this bug, there is some relayout/redrawing problems in GtkTextView when a tag property changes.
Comment 1 Sébastien Wilmet 2015-09-22 13:12:13 UTC
Created attachment 311857 [details] [review]
textiter: fix bug in _gtk_text_btree_get_iter_at_last_toggle()

If the last tag toggle is the end iter, the function returned the wrong
tag toggle.

This resulted in some bugs where the view wasn't relayout/redrawn
correctly.

The function also always returned TRUE, probably because the return
value is used nowhere. But for consistency with
_gtk_text_btree_get_iter_at_first_toggle(), it's better to keep the
return value, and also because otherwise the function would be wrong (it
doesn't always return a tag toggle, if there is none).
Comment 2 Sébastien Wilmet 2015-09-22 13:18:41 UTC
Note: writing a unit test for the function is not directly possible in testsuite/gtk/textiter.c because the function is private.
Comment 3 Sébastien Wilmet 2015-09-22 14:14:44 UTC
(it seems that git-bz didn't add the bug url for me, so I added it myself locally)
Comment 4 Matthias Clasen 2015-09-23 17:54:14 UTC
Review of attachment 311857 [details] [review]:

Looks right to me. But why has this never shown up as problem before ? Shouldn't there be some misrendering somewhere that you can trigger with a testcase ?
Comment 5 Sébastien Wilmet 2015-09-24 08:30:53 UTC
Created attachment 312009 [details]
test case

Test case that triggers the bug.

The drawing bug happens if:
1. a tag property changes
2. the tag property must affect the size of the text (so that size_changed=TRUE in the tag-changed signal)
3. the tag spans multiple lines at the end of the buffer

Those three combined conditions are quite rare, except when writing a test program.

And anyway if we click in the text view after changing the property, it redraws correctly.
Comment 6 Sébastien Wilmet 2015-10-07 15:00:04 UTC
Comment on attachment 311857 [details] [review]
textiter: fix bug in _gtk_text_btree_get_iter_at_last_toggle()

I've pushed the commit, a test case was attached and the fix is quite trivial.