[Development] Fixing QRect::width() / height()

Иван Комиссаров abbapoh at gmail.com
Tue Mar 15 14:48:52 CET 2016


We can also validate rect on construction and allow to create rects no
bigger than QRect(*, *, MAX_INT, MAX_INT) rects?

2016-03-15 16:44 GMT+03:00 Poenitz Andre <Andre.Poenitz at theqtcompany.com>:

>
> On Tuesday 15 March 2016 13:08:42 Bo Thorsen wrote:
> > > Den 15-03-2016 kl. 14:07 skrev Marc Mutz:
> > [...]
> > > There is another option that doesn't mean a change of signature: Bound
> > > the result. So if the real result is > INT_MAX, return INT_MAX. Same
> for
> > > INT_MIN.
> > >
> > > Yes, it's not the correct result, but I completely agree with you that
> > > it's a theoretical problem. As long as it's documented in the width() I
> > > really don't see the problem with this solution.
> >
> > I like the idea to change width() to return a bounded result to avoid UB
> for
> > old users, but we need a code path that returns the correct result for
> new
> > users without everyone of them going quint64(1) + r.right() - r.left() by
> > themselves...
>
> You seem to claim that new users would need 64 bit QRects.
>
> This is unlikely.
>
> Bo's proposal addresses the problem and does not require API
> changes.
>
> Andre'
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160315/70130871/attachment.html>


More information about the Development mailing list