GNOME Bugzilla – Bug 749875
Gtk3 TextBuffer.serialize() returns text with format tags, even when there is visually none in the associated GtkTextView
Last modified: 2018-05-02 16:36:00 UTC
I've been using Gtk+ with Python 3.4.2 on Ubuntu 14.04/14.10 and there seems to be a bug with the TextBuffer.serialize() function where it will return Pango flags/tags around text, even when it shouldn't because the text is visually not formatted in the associated GtkTextView. You can view some example code here: http://pastebin.com/1VccdJXL. The editor.glade file is available here: http://pastebin.com/RnC7drCL - put them both in the same directory and run the code via python3 gui.py. To re-create this bug: 1. Apply the italic and underline flags (via the buttons - not in any specific order) 2. Type at least one character 3. Turn off the formatting flags (again, via the buttons) 4. Type some more (the text should now be visibly non-formatted) 5. Click Send 6. Look at the outputs in the terminal and see the text that is visibly non-formatted in the Gtk TextView is returned with Pango flags incorrectly. I've been trying to figure this issue out in my own code for over a week now and I can't seem to figure out a solution and thus am left with the option that it is, in fact, a Gtk+ bug. If anything else is needed, I'll be more than happy to oblige - I'm somewhat new to submitting bug reports.
Created attachment 303975 [details] Minimal example I'll attach a minimal example. The output text is <text><apply_tag name="tagone">tag1<apply_tag name="tagtwo">tags12</apply_tag></apply_tag><apply_tag name="tagtwo">notags</apply_tag></text> when <text><apply_tag name="tagone">tag1<apply_tag name="tagtwo">tags12</apply_tag></apply_tag>notags</text> would be expected.
I have noticed a few patterns about how this bug tends to occur. 1) The bold tag is *NEVER* incorrectly returned. 2) The total number of incorrectly returned tags is always one less than the total number of tags applied at any one time (caveat - see my third pattern.) Eg. Apply the Bold, Italic, & Underline formatting types, type a bit, then disable the formatting, and type a bit more. You'll see the returned text will have the italic and underline flags incorrectly applied. 3) If you apply the tags all at once, then type, then turn off all the formatting and type some more, the returned text is correct - no incorrect tags returned. See here: http://www.gfycat.com/OilyWatchfulIndianrhinoceros 4) Not really a pattern, but I noticed that when I first added the ability to type with the various formatting things applied, I had to add a call to the queue_draw() function whenever the underline tag was applied, otherwise it wouldn't show up. Perhaps this was the bug showing up elsewhere and I was able to work around it?
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Yes, still relevant.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/554.