From kde-core-devel Tue Sep 18 18:41:08 2007 From: Allen Winter Date: Tue, 18 Sep 2007 18:41:08 +0000 To: kde-core-devel Subject: Re: Be careful with QPainter::drawRect etc Message-Id: <200709181441.09234.winter () kde ! org> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=119014092605674 On Tuesday 18 September 2007 1:01:34 pm 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. > > (same for drawLine, etc) > Sounds like a job for a compiler.