Be careful with QPainter::drawRect etc
Thiago Macieira
thiago at kde.org
Tue Sep 18 19:57:30 BST 2007
John Tapsell wrote:
>Hey all,
>
> I have tracked down a bugs in KFormula where the problem was that:
>
>QPainterPath rect;
>rect.addRect(0, -baseLine(), width(), baseLine() );
>painter.drawPath( rect );
>
>and
>
>painter.drawRect(0, -baseLine(), width(), baseLine() );
>
>Draw different rectangles. The reason for this is that addRect takes
>reals, and drawRect takes int. The drawRect thus loses precision, and
>draws incorrectly.
>
>This is a very subtle and very nasty bug, as at 500% zoom, it's off by
>less than 10 pixels typically.
>
>I have grepped the koffice source code and found hundreds of uses of
>drawRect, drawLine etc. I'm sure that many of this are wrong.
>
>Can we put a check for this use ebn? There will be false positives,
>but I think we need to check all uses of this.
Please file this with qt-bugs and have Trolltech verify that this is the
intended behaviour.
Someone today showed to me some rectangles drawn with incorrect sizes
under some circumstances. He was showing some painter code. It could be
the same problem.
When you see a problem in Qt, don't forget to tell Trolltech so we can fix
it.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070918/af2710a6/attachment.sig>
More information about the kde-core-devel
mailing list