diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2021-06-14 14:22:48 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-16 11:22:28 +0000 |
commit | 51838c964f9e6e62a30a6b5875302b9a8a1c4713 (patch) | |
tree | b3487bf02301061b940417bb00102f6ecbb50852 /src/plugins | |
parent | a225719ae8a5920ad00e20ffe35807fdce059953 (diff) |
iOS: cleanup connection when a screen disconnects
The iOS port creates one QIOSViewController per connected
screen. And each view controller listens for changes to
the application state. The problem is that we never
disconnect this connection again. So if a screen is removed, and
the corresponing view controller is deallocated, the
connection is still kept alive. This will cause crashes to
occur when the signal emits, since the slot will then be accessing
deleted memory.
Fixes: QTBUG-76948
Change-Id: I758e51af9297cd62de193aae825f4475a2c7c3e5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit d829d54a42393d797c5f6ab3b80e88df35fad1e4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/ios/qiosviewcontroller.mm | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 7d994f4394..7aeb3b9ca6 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -248,6 +248,7 @@ @implementation QIOSViewController { BOOL m_updatingProperties; QMetaObject::Connection m_focusWindowChangeConnection; + QMetaObject::Connection m_appStateChangedConnection; } #ifndef Q_OS_TVOS @@ -276,7 +277,7 @@ }); QIOSApplicationState *applicationState = &QIOSIntegration::instance()->applicationState; - QObject::connect(applicationState, &QIOSApplicationState::applicationStateDidChange, + m_appStateChangedConnection = QObject::connect(applicationState, &QIOSApplicationState::applicationStateDidChange, [self](Qt::ApplicationState oldState, Qt::ApplicationState newState) { if (oldState == Qt::ApplicationSuspended && newState != Qt::ApplicationSuspended) { // We may have ignored an earlier layout because the application was suspended, @@ -296,6 +297,7 @@ - (void)dealloc { QObject::disconnect(m_focusWindowChangeConnection); + QObject::disconnect(m_appStateChangedConnection); [super dealloc]; } |