qt5base-lts/src
Axel Spoerl e66cbdf684 Harden QMenuPrivate::hideMenu() against menu argument becoming stale
QMenuPrivate::hideMenu() hides a menu and reposts events in case a new
action has become the active one. For that purpose, it waits 20ms and
60ms for visual effects to be rendered.
If the last action has been triggered, the menu's deleteLater slot has
been called before hideMenu(). In that case, it gets deleted while
events are processed during the waiting periods.
Subsequently, menu becomes stale.

This patch replaces the QMenu * argument with a QPointer. Early returns
are inserted after waiting. QSignalBlocker is replaced by manual signal
blocking, to prevent the signal blocker from recovering the state of a
stale object, when it goes out of scope.

An auto test is not added: The error scenario occurs, when a menu is
triggered by keyboard input, while a mouse event is sent to the main
window from outside the menu. Such a test scenario is complex to match
and exposed to flakiness.

Fixes: QTBUG-115597
Pick-to: 6.6 6.5 6.2
Change-Id: I4f937fe66fb1b5cf78ebee70fd0006712172cb12
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-14 17:05:36 +02:00
..
3rdparty CI: Enable tests under corelib/serialization for Wasm platform 2023-08-14 16:08:32 +02:00
android Doc: Move \target command to inside table cell 2023-08-03 12:15:40 +02:00
assets Add XDG theme file for example icons 2023-06-26 17:32:10 +00:00
concurrent [docs] Link from QtConcurent::run() to QThreadPool::start(Callable&&) 2023-08-04 19:49:32 +02:00
corelib Modernize snippet 2023-08-14 12:05:32 +00:00
dbus Revert "QDbus: Avoid memory leak in registerComplexDBusType" 2023-08-11 22:30:30 +02:00
entrypoint src: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-10 23:36:51 +01:00
gui rhi: Expand lastCompletedGpuTime docs 2023-08-14 17:05:36 +02:00
network Make QNetworkInformation thread safe 2023-08-14 16:24:46 +02:00
opengl Enable QT_NO_CONTEXTLESS_CONNECT for most of QtBase 2023-07-11 22:44:29 +02:00
openglwidgets QOpenGLWidget: invalidate the depth/stencil after rendering 2023-07-26 06:46:51 +02:00
platformsupport Fix link to platform window in QAndroidPlatformBackingStore::flush() 2023-08-04 10:40:05 +02:00
plugins QAndroidPlatformInputContext: send composition text and cursor jointly 2023-08-14 16:24:45 +02:00
printsupport Enable QT_NO_CONTEXTLESS_CONNECT for most of QtBase 2023-07-11 22:44:29 +02:00
sql Doc: Fix warning about undocumented parameter 2023-08-08 09:12:16 +02:00
testlib Add QEXPECT_FAIL to tst_QApplication::sendEventsOnProcessEvents 2023-08-10 16:42:51 +03:00
tools moc: Remove remnants of USE_LEXEM_STORE 2023-08-10 10:17:45 +02:00
widgets Harden QMenuPrivate::hideMenu() against menu argument becoming stale 2023-08-14 17:05:36 +02:00
xml Doc: Remove link to removed example 2023-08-07 13:16:37 +02:00
CMakeLists.txt Add Qt icon library for examples 2023-04-22 18:14:38 +03:00