summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidplatformwindow.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-01-14 13:09:29 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-01-23 14:24:24 +0100
commitc27e1f498f933406aebc1334482da6761fe6de8c (patch)
tree9250685021cbc0fc6d3ca36598a650e71cda8e1a /src/plugins/platforms/android/qandroidplatformwindow.cpp
parente58a721c5de90208ba544c84ecd1b83d0544dfd8 (diff)
Android: Fix crash in QCompleter test
The call to QPlatformWindow::setVisible() will trigger flushing of the window system events. Depending on the events, this could lead to the window being hidden. Since platformScreen()->addWindow() and removeWindow() was done *after* this flush, you could get the remove for a window before it had been added, whereas the logic in these functions were written under the assumption that there is exactly one remove per add, and that add always precedes the remove. This has only been seen when running the QCompleter test so far. This patch reorders the statements to make sure the events are flushed after the window stack has been updated. In addition, it adds asserts for the assumptions in the addWindow/removeWindow code to catch bugs there earlier. Change-Id: Ic67b03afbf7acbcb78be86bffa4c26360dc5832f Task-number: QTBUG-43836 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformwindow.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidplatformwindow.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp
index 03cb186a81..1207d7c90b 100644
--- a/src/plugins/platforms/android/qandroidplatformwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp
@@ -82,15 +82,15 @@ void QAndroidPlatformWindow::setVisible(bool visible)
setGeometry(platformScreen()->availableGeometry());
}
- QRect availableGeometry = screen()->availableGeometry();
- if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
- QPlatformWindow::setVisible(visible);
-
if (visible)
platformScreen()->addWindow(this);
else
platformScreen()->removeWindow(this);
+ QRect availableGeometry = screen()->availableGeometry();
+ if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
+ QPlatformWindow::setVisible(visible);
+
// The Android Activity is activated before Qt is initialized, causing the application state to
// never be set to 'active'. We explicitly set this state when the first window becomes visible.
if (visible)