summaryrefslogtreecommitdiffstats
path: root/src/android/jar
diff options
context:
space:
mode:
authorPetri Virkkunen <petri.virkkunen@qt.io>2024-04-30 13:09:59 +0300
committerPetri Virkkunen <petri.virkkunen@qt.io>2024-04-30 22:17:03 +0300
commit9ef4435fbf68d2f628047ad75ef7104cf498682b (patch)
treeba788c2efe3adb17ae3caa7991b9f1857b60a03f /src/android/jar
parent6d2db42f7cac69c7c60fcad9109611c53f46aff8 (diff)
Android: Delete parent window in QtView instead of just the child view
Since the parent window wraps the QtView, it should always be destroyed when the QtView is, and live inside QtView rather than the delegate. Destroying the parent window will always destroy the child window, so do not destroy the child window separately. Move createRootWindow and deleteWindow native functions to QtView. Fixes: QTBUG-124908 Change-Id: Ib6b3c6388a9dd3f74d16fa09a442b0a6f8ccb336 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.java19
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtView.java11
2 files changed, 9 insertions, 21 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 1c0fd0f7d8..5545b0a09d 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java
@@ -24,13 +24,9 @@ import java.util.HashMap;
class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppStateDetailsListener {
// TODO simplistic implementation with one QtView, expand to support multiple views QTBUG-117649
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, int x, int y, int width, int height);
- static native void deleteWindow(long windowReference);
-
public QtEmbeddedDelegate(Activity context) {
super(context);
@@ -82,7 +78,6 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppS
QtNative.terminateQt();
QtNative.setActivity(null);
QtNative.getQtThread().exit();
- onDestroy();
}
}
});
@@ -154,20 +149,10 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppS
m_inputDelegate.setEditPopupMenu(new EditPopupMenu(m_activity, m_view));
}
-
- public void setRootWindowRef(long ref) {
- m_rootWindowRef = ref;
- }
-
- public void onDestroy() {
- if (m_rootWindowRef != 0L)
- deleteWindow(m_rootWindowRef);
- m_rootWindowRef = 0L;
- }
-
private void createRootWindow() {
if (m_view != null && !m_windowLoaded) {
- createRootWindow(m_view, m_view.getLeft(), m_view.getTop(), m_view.getWidth(), m_view.getHeight());
+ QtView.createRootWindow(m_view, m_view.getLeft(), m_view.getTop(), m_view.getWidth(),
+ m_view.getHeight());
m_windowLoaded = true;
}
}
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtView.java b/src/android/jar/src/org/qtproject/qt/android/QtView.java
index 6836171187..b253548a5c 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtView.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtView.java
@@ -29,6 +29,7 @@ abstract class QtView extends ViewGroup {
protected QtWindow m_window;
protected long m_windowReference;
+ protected long m_parentWindowReference;
protected QtWindowListener m_windowListener;
protected QtEmbeddedDelegate m_delegate;
// Implement in subclass to handle the creation of the QWindow and its parent container.
@@ -37,6 +38,8 @@ abstract class QtView extends ViewGroup {
// too much JNI back and forth. Related to parent window creation, so handle with QTBUG-121511.
abstract protected void createWindow(long parentWindowRef);
+ static native void createRootWindow(View rootView, int x, int y, int width, int height);
+ static native void deleteWindow(long windowReference);
private static native void setWindowVisible(long windowReference, boolean visible);
private static native void resizeWindow(long windowReference,
int x, int y, int width, int height);
@@ -156,7 +159,7 @@ abstract class QtView extends ViewGroup {
// viewReference - the reference to the created QQuickView
void addQtWindow(QtWindow window, long viewReference, long parentWindowRef) {
setWindowReference(viewReference);
- m_delegate.setRootWindowRef(parentWindowRef);
+ m_parentWindowReference = parentWindowRef;
final Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
@@ -176,9 +179,9 @@ abstract class QtView extends ViewGroup {
// Destroy the underlying QWindow
void destroyWindow() {
- if (m_windowReference != 0L)
- QtEmbeddedDelegate.deleteWindow(m_windowReference);
- m_windowReference = 0L;
+ if (m_parentWindowReference != 0L)
+ deleteWindow(m_parentWindowReference);
+ m_parentWindowReference = 0L;
}
QtWindow getQtWindow() {