diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-10-13 13:57:35 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-10-15 13:34:30 +0200 |
commit | 3edce263fb92ca96f6d7b5f90baf000bb2e0d74a (patch) | |
tree | 2d77ecdd953b7f828d37db1d9ef3fa240bc8225b /src/widgets/widgets/qtoolbutton.cpp | |
parent | f5cf06f4afc48198780e3c3d0d1a52afce425507 (diff) |
Prevent 'recursive' update events when calling QToolButton::setMenu()
Commit bb3d2ca9f18 (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>
Diffstat (limited to 'src/widgets/widgets/qtoolbutton.cpp')
-rw-r--r-- | src/widgets/widgets/qtoolbutton.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index 3d3f42605e..bb3f2d74a8 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -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); |