From 8b5218a1e9136d6889d3e57b37b5341b4bcf6df0 Mon Sep 17 00:00:00 2001 From: "Anselmo L. S. Melo" Date: Thu, 8 Mar 2012 20:01:24 -0300 Subject: [PATCH] Make QWindow::isActive return false when the application loses the focus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In QTBUG-24807 there is a test case that shows a case when a segmentation fault happens inside isAncestorOf. When the whole application loses the focus, e.g. when it is minimized or other application receives the focus, QGuiApplication::focusWindow() returns a null pointer, so we need to do a check before proceed inside of isActive. Task-number: QTBUG-24807 Change-Id: I732c92bb9f236804ede5e89592f6e6609a4711b9 Reviewed-by: Jesus Sanchez-Palencia Reviewed-by: Samuel Rødal --- src/gui/kernel/qwindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 367cee70e3c..91eb7bdb884 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -597,6 +597,11 @@ bool QWindow::isActive() const return false; QWindow *focus = QGuiApplication::focusWindow(); + + // Means the whole application lost the focus + if (!focus) + return false; + if (focus == this) return true;