Go to file
Tor Arne Vestbø 2a76c41fdd macOS: Avoid recursively updating screens when window moves screen
The QWSI APIs for reporting added or removed screens is not transactional,
so when several screens change at once Qt will see each screen change as
a separate state.

As a result, Qt, or the application itself, may react to the first of
many screen updates by moving a window to a different screen -- one
which is going to updated (removed) in the next iteration of QWSI
calls.

This caused trouble on macOS, where we use many different signals to
detect that the system has changed the screens, one of them being that
a window has been moved to a different screen.

In the scenario above, we would be in the process of updating screens
in response to the system going to sleep, which means all 3 connected
screens will be disconnected and replaced with one fake screen provided
by the system.

As we delivered the removal of the first QScreen, Qt or the application,
would respond by moving the window to one of the other two screens, which
in turn would recursively trigger another round of screen updates. This
round would then proceed to remove (and delete) all remaining QScreens.
When we then recursed back to the initial round of screen updates
we would continue iterating and operating on screens that had already
been removed, causing a crash.

Since we know that the screens will stabilize eventually, and that
QCocoaScreen has cached all info based on the displayId and NSScreen,
we can safely skip any recursive invocations of updateScreens().

Fixes: QTBUG-102021
Fixes: QTBUG-84741
Pick-to: 5.15 6.2 6.3 6.4
Invaluable-help-by: Bruno Cadoret <bruno.cadoret_1@signify.com>
Change-Id: I9ff96dbcbc6f308ad2729faf2db2de7ef08513c0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-16 17:43:39 +02:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin CMake: Automatically use Xcode generator in qt-cmake + iOS 2022-05-20 13:06:00 +02:00
cmake Add ASAN build for qtbase 2022-06-15 23:58:16 +02:00
coin Try to consolidate Unix/Windows libexec directory in coin configs 2022-06-15 23:58:16 +02:00
config.tests CMake: Test the linker too for -mno-direct-extern-access 2022-05-25 16:29:31 -07:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Fix typos in docs and comments 2022-06-15 21:31:02 +02:00
examples Fix typos in docs and comments 2022-06-15 21:31:02 +02:00
lib
libexec Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
LICENSES Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
mkspecs wasm: don't enable specialHTMLTargets by default 2022-06-01 13:52:47 +02:00
qmake qmake: Document Xcode behavior when bundling translation files 2022-06-14 15:45:06 +02:00
src macOS: Avoid recursively updating screens when window moves screen 2022-06-16 17:43:39 +02:00
tests Endian: Remove old special integer bitfields 2022-06-16 06:12:27 +00:00
util Add ASAN build for qtbase 2022-06-15 23:58:16 +02:00
.cmake.conf Bump version to 6.5.0 2022-06-06 13:23:59 +03:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Assume qhelpgenerator in libexec instead of bin 2021-11-08 19:27:32 +01:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag
CMakeLists.txt Use REALPATH based check for symbolic links on Windows 2022-01-07 14:31:38 +01:00
conanfile.py Conan: Don't add 'qt_host_path' automatically when cross-building 2022-06-02 08:33:21 +03:00
config_help.txt C++23/c++2b support 2022-06-08 19:43:34 +02:00
configure Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
configure.bat Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
configure.cmake CMake: Fix typos 2022-06-13 15:37:36 +02:00
dependencies.yaml
qt_cmdline.cmake C++23/c++2b support 2022-06-08 19:43:34 +02:00
sync.profile Remove deprecated qgl.h from sync.profile 2022-06-11 00:42:13 +02:00