summaryrefslogtreecommitdiffstats
path: root/src/android/jar
diff options
context:
space:
mode:
authorTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-02-22 15:08:06 +0200
committerTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-03-13 15:50:14 +0000
commitd899cdb3a4dc9eb1ad489f7541244110e7e80f61 (patch)
tree0446ed125a4ba01dc70d344acdd1a1c843ea0cb0 /src/android/jar
parent39c4c868a4c1acb5cceb00418b2bb0ca3836d0a3 (diff)
Android: Synchronize window creation in QtEmbeddedDelegate
Qt window loading is initiated either when the QtView is attached to its Android window, or when the Android QPA plugin has been loaded and is ready, depending on the order. Since the window attachment happens in the Android UI thread, and the Android QPA plugin callback happens in Qt thread, add synchronized block to make sure the execution stays ordered. Fixes: QTBUG-122626 Pick-to: 6.7 Change-Id: Id476032f02aa8990432a02f62b6bf6237a17e7ac Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android/jar')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java
index 975b26b915..74617706f9 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java
@@ -26,6 +26,7 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppS
private QtView m_view;
private long m_rootWindowRef = 0L;
private QtNative.ApplicationStateDetails m_stateDetails;
+ private boolean m_windowLoaded = false;
private static native void createRootWindow(View rootView);
static native void deleteWindow(long windowReference);
@@ -89,16 +90,18 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppS
@Override
public void onAppStateDetailsChanged(QtNative.ApplicationStateDetails details) {
- m_stateDetails = details;
- if (m_stateDetails.nativePluginIntegrationReady) {
- QtNative.runAction(() -> {
- DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
- QtDisplayManager.setApplicationDisplayMetrics(m_activity,
- metrics.widthPixels,
- metrics.heightPixels);
- if (m_view != null)
- createRootWindow(m_view);
- });
+ synchronized (this) {
+ m_stateDetails = details;
+ if (m_stateDetails.nativePluginIntegrationReady) {
+ QtNative.runAction(() -> {
+ DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
+ QtDisplayManager.setApplicationDisplayMetrics(m_activity,
+ metrics.widthPixels,
+ metrics.heightPixels);
+
+ });
+ createRootWindow();
+ }
}
}
@@ -128,8 +131,9 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppS
public void queueLoadWindow()
{
- if (m_stateDetails.nativePluginIntegrationReady) {
- createRootWindow(m_view);
+ synchronized (this) {
+ if (m_stateDetails.nativePluginIntegrationReady)
+ createRootWindow();
}
}
@@ -148,4 +152,11 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppS
deleteWindow(m_rootWindowRef);
m_rootWindowRef = 0L;
}
+
+ private void createRootWindow() {
+ if (m_view != null && !m_windowLoaded) {
+ createRootWindow(m_view);
+ m_windowLoaded = true;
+ }
+ }
}