summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Pohjanheimo <lauri.pohjanheimo@qt.io>2024-03-22 15:43:36 +0200
committerLauri Pohjanheimo <lauri.pohjanheimo@qt.io>2024-04-09 11:54:14 +0000
commitb2c648c57261550474308aee09bfc1054818fb60 (patch)
treea22e2b0d5ac01882baa01b4fe566682bce4b935e
parenta79ca35abef38f882a1ab574063eb9ed6ffe6846 (diff)
Android: runAction can now be run past queue
On vulkan implementation it was possible that when going background destroySurface was queued and then run when coming back foreground that caused vulkan not being able to draw. Fixes: QTBUG-118985 Fixes: QTBUG-118840 Pick-to: 6.7 Change-Id: I5957b74b89384ea84fc09d9b55afcccf5c82e390 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtNative.java22
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtWindow.java4
2 files changed, 18 insertions, 8 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtNative.java b/src/android/jar/src/org/qtproject/qt/android/QtNative.java
index e2f908e54a..97a45ef8fa 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtNative.java
@@ -269,15 +269,25 @@ class QtNative
// otherwise, queue it to be posted when the the app is active again
public static void runAction(Runnable action)
{
+ runAction(action, true);
+ }
+
+ public static void runAction(Runnable action, boolean queueWhenInactive)
+ {
synchronized (m_mainActivityMutex) {
final Looper mainLooper = Looper.getMainLooper();
final Handler handler = new Handler(mainLooper);
- final boolean isStateVisible =
- (m_stateDetails.state != ApplicationState.ApplicationSuspended)
- && (m_stateDetails.state != ApplicationState.ApplicationHidden);
- final boolean active = (isActivityValid() && isStateVisible) || isServiceValid();
- if (!active || !handler.post(action))
- m_lostActions.add(action);
+
+ if (queueWhenInactive) {
+ final boolean isStateVisible =
+ (m_stateDetails.state != ApplicationState.ApplicationSuspended)
+ && (m_stateDetails.state != ApplicationState.ApplicationHidden);
+ final boolean active = (isActivityValid() && isStateVisible) || isServiceValid();
+ if (!active || !handler.post(action))
+ m_lostActions.add(action);
+ } else {
+ handler.post(action);
+ }
}
}
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
index 86d5e9b448..d72e69d32a 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
@@ -122,8 +122,8 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
if (m_surfaceContainer != null) {
removeView(m_surfaceContainer);
m_surfaceContainer = null;
- }
- });
+ }
+ }, false);
}
public void setGeometry(final int x, final int y, final int w, final int h)