changeset 7084:1ea1fc4d89b9

RT-37226: [Accessibility] JavaFX crashes when Narrator is closed.
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Tue, 20 May 2014 15:50:13 -0700
parents 7b60160523d6
children 83dd569f52e6
files modules/graphics/src/main/native-glass/win/GlassAccessible.cpp
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/win/GlassAccessible.cpp	Tue May 20 10:18:48 2014 -0700
+++ b/modules/graphics/src/main/native-glass/win/GlassAccessible.cpp	Tue May 20 15:50:13 2014 -0700
@@ -458,6 +458,11 @@
 IFACEMETHODIMP GlassAccessible::AdviseEventAdded(EVENTID eventId, SAFEARRAY *propertyIDs)
 {
     JNIEnv* env = GetEnv();
+    /* For some reason, probably a bug, Windows call AdviseEventRemoved() on a different thread when
+     * Narrator is shutting down. The fix is to ignored any method on IRawElementProviderAdviseEvents
+     * if env is NULL.
+     */
+    if (env == NULL) return E_FAIL;
     env->CallVoidMethod(m_jAccessible, mid_AdviseEventAdded, eventId, (jlong)propertyIDs);
     if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
@@ -467,6 +472,11 @@
 IFACEMETHODIMP GlassAccessible::AdviseEventRemoved(EVENTID eventId, SAFEARRAY *propertyIDs)
 {
     JNIEnv* env = GetEnv();
+    /* For some reason, probably a bug, Windows call AdviseEventRemoved() on a different thread when
+     * Narrator is shutting down. The fix is to ignored any method on IRawElementProviderAdviseEvents
+     * if env is NULL.
+     */
+    if (env == NULL) return E_FAIL;
     env->CallVoidMethod(m_jAccessible, mid_AdviseEventRemoved, eventId, (jlong)propertyIDs);
     if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;