[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Bug#8266: Non-printable characters lead to infinite loop in QPainter's qt_format_text
From:       David Faure <david () mandrakesoft ! com>
Date:       2000-08-16 17:33:53
[Download RAW message or body]

Version: 2.2beta1
Severity: critical

A file with a non-printable character in its name in a QIconView can lead
to an infinite loop in QFontMetrics::boundingRect() (which qiconview calls in word-wrap mode).

The illegal chars in the filename can happen this way:
* create a file on a Window machine, containing accentuated letters
* copy it to a linux machine using smb.
-> the file will have illegal chars in the filename

The filename appears under ls as
"La d?marche qualit? sur les ?tudes.doc"
where the '?' is in fact a 'e' with an acute accent, when written under Windows,
and for this char, QChar::unicode() returns 130.

Tried to debug qt_format_text, which is the one that loops indefinitely, but
that stuff is quite hairy ;-)

The main loop in qt_format_text loops indefinitely, going to 38 (the end of the string),
then back to 28, 29, 30... 38, 28, 29 etc. :)
Since breakindex is never set to something else than 0, when it arrives
at the end it substracts 10 and starts again.

This pseudo patch below fixes the problem for me, but I have no idea if
that's the right thing to do at all.

                if ( tw+cw > w ) {
                    if ( breakindex > 0 ) {
                        breakwithinwords = FALSE;
                        codes[begline] = BEGLINE | QMIN(tw,MAXWIDTH);
                        maxwidth = QMAX(maxwidth,tw);
                        begline = breakindex;
                        tw = cw;
                        breakindex = tabindex = 0;
                        cw = 0;
                        nlines++;
-                    }
+                    } else
                    if ( /* do not add !breakwithinwords &&*/
                        tw+cw > w && word.length() > 1) {
                        breakwithinwords = TRUE;
                        breakwidth = 0;
                        p -= word.length();
                        k -= word.length();
                        index = begline+1;
                        tw = 0;
                        word = "";
                        continue;
                    }

Thanks for looking into this asap.

Feel free to ask for some more info or debug output, or for sending a patch for me to test,
in case you don't have a windows machine at hand :)

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://home.clara.net/faure/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today
See http://www.kde.org/kde1-and-kde2.html for how to set up KDE 2

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic