Prevent 'recursive' update events when calling QToolButton::setMenu()
Commit bb3d2ca9f1
(QToolButton: properly reset the size hint when a
menu is set on it) didn't take the case of re-setting the same menu
into account, and the result was that we would unconditionally cause
an update, resulting in the following backtrace again and again, as
each posted update event was processed by the event loop:
frame #0: QToolButton::setMenu(this=0x7af59500, menu=0x00000000)
frame #1: QToolBarLayout::setUsePopupMenu(this=0x7ae65a30, set=false)
frame #2: QToolBarLayout::checkUsePopupMenu(this=0x7ae65a30)
frame #3: QToolBarAreaLayoutLine::fitLayout(this=0x78e5f870)
frame #4: QToolBarAreaLayoutInfo::fitLayout(this=0x790be278)
...
Besides consuming needless CPU time this also uncovered a case on iOS
where Qt would starve native events and animations from being processed,
preventing eg. rotation animations from running.
Change-Id: Ib6bd4ba21d8e84ca73fb0a75b598016dbd9ae0fd
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
parent
f5cf06f4af
commit
3edce263fb
@ -636,6 +636,9 @@ void QToolButton::setMenu(QMenu* menu)
|
||||
{
|
||||
Q_D(QToolButton);
|
||||
|
||||
if (d->menuAction == (menu ? menu->menuAction() : 0))
|
||||
return;
|
||||
|
||||
if (d->menuAction)
|
||||
removeAction(d->menuAction);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user