summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAssam Boudjelthia <[email protected]>2025-06-27 17:08:46 +0300
committerAssam Boudjelthia <[email protected]>2025-06-28 03:52:49 +0300
commitd9f10bfaaeef52a5ccfc60c7e75339df39b96ff3 (patch)
tree966fc64808b4dc0a90af9bae171706f2e7c08407
parentbb12c984b2c838bdb06169ef7d659384c02c8b82 (diff)
Android: fix potential exceptions in Java CursorHandle
Under initOverlay(), obtainStyledAttributes() was using an auto closeable try() block but that's not guaranteed to be implemented on all system, to opt in for manually recycling. Moreover, under width(), m_cursorView is not always guaranteed to be non-null, so guard against that. Pick-to: 6.10 6.9 Change-Id: I35bf6d2ecbaf8913c94b070e7d99f72d2030f8b7 Reviewed-by: Ville Voutilainen <[email protected]>
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/CursorHandle.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java b/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java
index 41256cc64a1..0079135e518 100644
--- a/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java
+++ b/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java
@@ -108,8 +108,11 @@ class CursorHandle implements ViewTreeObserver.OnPreDrawListener
Context context = m_layout.getContext();
int[] attrs = {m_attr};
Drawable drawable;
- try (TypedArray a = context.getTheme().obtainStyledAttributes(attrs)) {
+ TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
+ try {
drawable = a.getDrawable(0);
+ } finally {
+ a.recycle();
}
m_cursorView = new CursorView(context, this);
@@ -189,6 +192,9 @@ class CursorHandle implements ViewTreeObserver.OnPreDrawListener
int width()
{
+ if (m_cursorView == null)
+ return 0;
+
return m_cursorView.getDrawable().getIntrinsicWidth();
}