D15625: Sublime: Fix crash caused when all tool view items are small

Friedrich W. H. Kossebau noreply at phabricator.kde.org
Fri Sep 21 14:06:44 BST 2018


kossebau added inline comments.

INLINE COMMENTS

> ideallayout.cpp:222
>  
> -        Q_ASSERT(_items.size() != smallItemCount); // should be true since rect.width != sizeHint.width
> -        // evenly distribute surplus height over large items
> -        shrinkedHeight = maximumHeight + surplus / (_items.size() - smallItemCount);
> +        if (_items.size() != smallItemCount) {
> +            // evenly distribute surplus height over large items

Please add a comment that this is protective code against the chance there is some bug in our logic which would lead to divide-by-zero then. Also worth a qCWarning in the else branch, so we could collect info where this happens.

Given the calculations above, there should be at least one too-large item. Otherwise we would have a bug in our sizeHint() code or in the what-and-how-to-shrink code above. Or the layouted items would suddenly start to report random sizeHint() values during the execution of this method, which would be even more unexpected.

> ideallayout.cpp:285
>  
> -        Q_ASSERT(_items.size() != smallItemCount); // should be true since rect.width != sizeHint.width
> -        // evenly distribute surplus width on the large items
> -        shrinkedWidth = maximumWidth + surplus / (_items.size() - smallItemCount);
> +        if (_items.size() != smallItemCount) {
> +            // evenly distribute surplus width on the large items

Same comment please.

REPOSITORY
  R32 KDevelop

REVISION DETAIL
  https://phabricator.kde.org/D15625

To: amhndu, #kdevelop
Cc: kossebau, rjvbb, kdevelop-devel, glebaccon, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180921/10702e57/attachment-0001.html>


More information about the KDevelop-devel mailing list