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

Marc Mutz marc.mutz at kdab.com
Tue Mar 15 15:43:46 CET 2016


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...

Thanks,
Marc

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list