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

Friedrich W. H. Kossebau noreply at phabricator.kde.org
Thu Sep 27 12:54:53 BST 2018


kossebau added a comment.


  In D15625#332551 <https://phabricator.kde.org/D15625#332551>, @kossebau wrote:
  
  > When it comes to updating the spacing on style changes, something like this should work:
  >
  >   void IdealButtonBarLayout::changeEvent(QEvent* event)
  >   {
  >       QBoxLayout::changeEvent(event);
  >       if (event->type() == QEvent::StyleChange) {
  >           setSpacing(buttonSpacing());
  >       }
  >   }
  >
  
  
  Eek, missed that `changeEvent(QEvent *event)` is only added for QWidget, not QObject itself. We would need to install an event filter to the parent widget.

INLINE COMMENTS

> ideallayout.cpp:47
> +    setContentsMargins(0, 0, 0, 0);
> +    setSpacing(buttonSpacing());
>  }

We have an issue here. `buttonSpacing()` looks for any `parentWidget()` to take the style from, otherwise defaults to `0`.
And currently we create IdealButtonBarLayout without any QWidget parent, so at this point in time the spacing is set to the default value `0`.
So we need to somehow learn about the containing parent widget.

One solution might be to add an explicit property *QWidget* m_styleParentWidget` to 
`IdealButtonBarLayout`, which gets set via the constructor, so it is available from the start. And could also be used for catching the event about style changes.

REPOSITORY
  R32 KDevelop

BRANCH
  segfault-fix

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

To: amhndu, #kdevelop, kossebau, rjvbb
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/20180927/7e63055a/attachment.html>


More information about the KDevelop-devel mailing list