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 749875 - Gtk3 TextBuffer.serialize() returns text with format tags, even when there is visually none in the associated GtkTextView
Gtk3 TextBuffer.serialize() returns text with format tags, even when there is...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
3.12.x
Other Linux
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-05-26 06:57 UTC by keyboardmailtesting
Modified: 2018-05-02 16:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Minimal example (1.48 KB, text/plain)
2015-05-26 09:26 UTC, Phillip Berndt
Details

Description keyboardmailtesting 2015-05-26 06:57:54 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.
Comment 1 Phillip Berndt 2015-05-26 09:26:30 UTC
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.
Comment 2 keyboardmailtesting 2015-05-27 01:03:37 UTC
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?
Comment 3 Matthias Clasen 2018-02-10 05:05:21 UTC
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.
Comment 4 Phillip Berndt 2018-02-10 07:18:32 UTC
Yes, still relevant.
Comment 5 GNOME Infrastructure Team 2018-05-02 16:36:00 UTC
-- 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.