Be careful with QPainter::drawRect etc
John Tapsell
johnflux at gmail.com
Tue Sep 18 18:01:34 BST 2007
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.
(same for drawLine, etc)
John
More information about the kde-core-devel
mailing list