aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@qt.io>2017-01-03 13:46:46 +0100
committerJan Arve Sæther <jan-arve.saether@qt.io>2017-02-07 15:01:23 +0000
commite6cc5382d9b789274d3e16e8601f33075b6a4b1c (patch)
treeb0610f3e02b433fd028773546f1a808b7decfc16 /src/quicktemplates2
parentf0ce8b847e2169ad4ae884dbb35b58e6dd0f1859 (diff)
Fix a crash with focus handling when destructing QQAppWindow
Because QQuickApplicationWindow connected SIGNAL(activeFocusItemChanged()) to SLOT(_q_updateActiveFocus())); it would enter _q_updateActiveFocus() from the dtor of QQuickWindow (because dtor of QQuickWindow would emit activeFocusItemChanged()). At that point the QQuickApplicationWindow object for the member function _q_updateActiveFocus() was already destroyed, so we would crash. Instead, make sure we clear the focus as early as possible, and then disconnect in case activeFocusItemChanged() is emitted after QQuickApplicationWindow is destroyed. Task-number: QTBUG-57846 Change-Id: I4b1999e647b970394436a2d462b7f352f1c8a811 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index a79216b1..0123786a 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -293,6 +293,8 @@ QQuickApplicationWindow::QQuickApplicationWindow(QWindow *parent) :
QQuickApplicationWindow::~QQuickApplicationWindow()
{
Q_D(QQuickApplicationWindow);
+ d->setActiveFocusControl(nullptr);
+ disconnect(this, SIGNAL(activeFocusItemChanged()), this, SLOT(_q_updateActiveFocus()));
if (d->header)
QQuickItemPrivate::get(d->header)->removeItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility |
QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);