GNOME Bugzilla – Bug 402119
Minor bug while editing text
Last modified: 2007-02-09 19:21:24 UTC
I've noticed two strange things when editing text. Here is the first thing: 1. Open the diagram http://www.md.kth.se/~chr/dia/bug1.dia 2. Click on the text 3. Press END to get at the end 4. Press BACKSPACE to try and delete the last character Nothing happens, except it says that the diagram has been changed 5. Press BACKSPACE again. This time the last character is deleted. The second thing I'm unfortunately unable to Here is the second thing: Sometimes when I tried deleting the last character, some unprintable characters showed up instead. I'm guessing they are unprintable as it looked like a small box. Unfortunately I'm not able to reproduce this consistenly, but I'm hoping the first bug is related.
I opened that diagram: with Dia 0.96-pre3 and verified what Christian said. Cristian's diagram contains one Text with characters needing more than one byte. My locale is Spanish; and the same happens with a Text with just two accented letters After playing around writing and deleting ... I also observed characters I have not written and unexpedted changes of position Dia 0.95.1 works well.
It looks as if: after pressing the end key (if there are at least one charecter needing more than one byte) Dia pre3 believe text is longer than it is. Even, some times, waning messages appear talking of position of inexisting characters: my text was three accented o ** (lt-dia:4153): WARNING **: Text at char 5 not valid Christian detected this bug working in Windows; I verified it working with Suse 10.1 (app/run_dia.sh)
If there's more than one non-ASCII character, there's more "invisible characters" at the end. The problem appears to be that we use strlen where we should be using g_utf8_strlen. However, replacing that in text.c leads to crashes on some diagrams, and not in an obvious way. There may be issues with somebody having assumed a long time ago that one character == one byte. This desparately needs fixing.
Fiddled with it some more, and replaced only the appropriate strlen's with g_utf8_strlen(). Some places actually base allocation on strlen.
Oh, BTW, thank you *very* much for reporting this. It would have been an embarrasing bug to have to make a bugfix release for.
*** Bug 402974 has been marked as a duplicate of this bug. ***
*** Bug 406175 has been marked as a duplicate of this bug. ***