diff options
author | Tinja Paavoseppä <tinja.paavoseppa@qt.io> | 2024-03-27 15:43:43 +0200 |
---|---|---|
committer | Tinja Paavoseppä <tinja.paavoseppa@qt.io> | 2024-04-04 15:46:44 +0200 |
commit | 02bab22fde5de84c62e3eb86fde03248851d11dd (patch) | |
tree | 00e679a7b3a6b265b532a9cf42cdd8f13c5e9155 /src/plugins/platforms | |
parent | d45ce587784427c4ff72d306811eb63baa53cb3a (diff) |
Android/QtView: Move resizing of the QWindow to Qt thread
Since any window resize events originating from Qt side are ran in the
Qt thread, having the one originating from Android run in the Android
thread can lead to race conditions especially during orientation changes.
Pick-to: 6.7
Change-Id: Iebebec2fffdaf9181b01fc1e8f539c7bc232996d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/android/androidwindowembedding.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/plugins/platforms/android/androidwindowembedding.cpp b/src/plugins/platforms/android/androidwindowembedding.cpp index 20021283c5..230776f571 100644 --- a/src/plugins/platforms/android/androidwindowembedding.cpp +++ b/src/plugins/platforms/android/androidwindowembedding.cpp @@ -49,11 +49,13 @@ namespace QtAndroidWindowEmbedding { void resizeWindow(JNIEnv *, jclass, jlong windowRef, jint x, jint y, jint width, jint height) { - QWindow *window = reinterpret_cast<QWindow*>(windowRef); - QWindow *parent = window->parent(); - if (parent) - parent->setGeometry(x, y, width, height); - window->setGeometry(0, 0, width, height); + QMetaObject::invokeMethod(qApp, [windowRef, x, y, width, height] { + QWindow *window = reinterpret_cast<QWindow*>(windowRef); + QWindow *parent = window->parent(); + if (parent) + parent->setGeometry(x, y, width, height); + window->setGeometry(0, 0, width, height); + }); } bool registerNatives(QJniEnvironment& env) { |