Android: extract parentId for hidden object in advance
This commit amends 850a7f1238.
We can't extract the parentId for the hidden object on Java side,
because the Java call is executed in a separate thread, so the
original hidden object can be destroyed somewhere in the middle of
parentId() call.
As a workaround, we get the parentId in advance, on C++ side, and pass
it as a parameter to JNI function.
Task-number: QTBUG-95764
Pick-to: 6.3 6.2 5.15
Change-Id: Ied2ab4ab39b947f3f582575cf77cc76fbac9e274
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
bb10
parent
81178294f1
commit
6d00aac109
|
|
@ -907,11 +907,11 @@ public class QtActivityDelegate
|
|||
m_accessibilityDelegate.notifyLocationChange();
|
||||
}
|
||||
|
||||
public void notifyObjectHide(int viewId)
|
||||
public void notifyObjectHide(int viewId, int parentId)
|
||||
{
|
||||
if (m_accessibilityDelegate == null)
|
||||
return;
|
||||
m_accessibilityDelegate.notifyObjectHide(viewId);
|
||||
m_accessibilityDelegate.notifyObjectHide(viewId, parentId);
|
||||
}
|
||||
|
||||
public void notifyObjectFocus(int viewId)
|
||||
|
|
|
|||
|
|
@ -974,13 +974,13 @@ public class QtNative
|
|||
});
|
||||
}
|
||||
|
||||
private static void notifyObjectHide(final int viewId)
|
||||
private static void notifyObjectHide(final int viewId, final int parentId)
|
||||
{
|
||||
runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (m_activityDelegate != null) {
|
||||
m_activityDelegate.notifyObjectHide(viewId);
|
||||
m_activityDelegate.notifyObjectHide(viewId, parentId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
|||
invalidateVirtualViewId(m_focusedVirtualViewId);
|
||||
}
|
||||
|
||||
public void notifyObjectHide(int viewId)
|
||||
public void notifyObjectHide(int viewId, int parentId)
|
||||
{
|
||||
// If the object had accessibility focus, we need to clear it.
|
||||
// Note: This code is mostly copied from
|
||||
|
|
@ -210,7 +210,6 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
|
|||
}
|
||||
// When the object is hidden, we need to notify its parent about
|
||||
// content change, not the hidden object itself
|
||||
final int parentId = QtNativeAccessibility.parentId(viewId);
|
||||
invalidateVirtualViewId(parentId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1138,9 +1138,9 @@ public class QtActivity extends Activity
|
|||
QtNative.activityDelegate().notifyAccessibilityLocationChange();
|
||||
}
|
||||
|
||||
public void notifyObjectHide(int viewId)
|
||||
public void notifyObjectHide(int viewId, int parentId)
|
||||
{
|
||||
QtNative.activityDelegate().notifyObjectHide(viewId);
|
||||
QtNative.activityDelegate().notifyObjectHide(viewId, parentId);
|
||||
}
|
||||
|
||||
public void notifyObjectFocus(int viewId)
|
||||
|
|
|
|||
|
|
@ -113,9 +113,13 @@ namespace QtAndroidAccessibility
|
|||
QtAndroid::notifyAccessibilityLocationChange();
|
||||
}
|
||||
|
||||
static jint parentId(JNIEnv *, jobject, jint objectId); // forward declaration
|
||||
|
||||
void notifyObjectHide(uint accessibilityObjectId)
|
||||
{
|
||||
QtAndroid::notifyObjectHide(accessibilityObjectId);
|
||||
jobject unused {};
|
||||
const auto parentObjectId = parentId(nullptr, unused, accessibilityObjectId);
|
||||
QtAndroid::notifyObjectHide(accessibilityObjectId, parentObjectId);
|
||||
}
|
||||
|
||||
void notifyObjectFocus(uint accessibilityObjectId)
|
||||
|
|
|
|||
|
|
@ -215,9 +215,10 @@ namespace QtAndroid
|
|||
QJniObject::callStaticMethod<void>(m_applicationClass, "notifyAccessibilityLocationChange");
|
||||
}
|
||||
|
||||
void notifyObjectHide(uint accessibilityObjectId)
|
||||
void notifyObjectHide(uint accessibilityObjectId, uint parentObjectId)
|
||||
{
|
||||
QJniObject::callStaticMethod<void>(m_applicationClass, "notifyObjectHide","(I)V", accessibilityObjectId);
|
||||
QJniObject::callStaticMethod<void>(m_applicationClass, "notifyObjectHide", "(II)V",
|
||||
accessibilityObjectId, parentObjectId);
|
||||
}
|
||||
|
||||
void notifyObjectFocus(uint accessibilityObjectId)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace QtAndroid
|
|||
jobject createBitmapDrawable(jobject bitmap, JNIEnv *env = nullptr);
|
||||
|
||||
void notifyAccessibilityLocationChange();
|
||||
void notifyObjectHide(uint accessibilityObjectId);
|
||||
void notifyObjectHide(uint accessibilityObjectId, uint parentObjectId);
|
||||
void notifyObjectFocus(uint accessibilityObjectId);
|
||||
void notifyQtAndroidPluginRunning(bool running);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue