Make QWindow::isActive return false when the application loses the focus

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 <jesus.palencia@openbossa.org>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
Anselmo L. S. Melo 2012-03-08 20:01:24 -03:00 committed by Qt by Nokia
parent 1741f6890c
commit 8b5218a1e9

View File

@ -597,6 +597,11 @@ bool QWindow::isActive() const
return false; return false;
QWindow *focus = QGuiApplication::focusWindow(); QWindow *focus = QGuiApplication::focusWindow();
// Means the whole application lost the focus
if (!focus)
return false;
if (focus == this) if (focus == this)
return true; return true;