Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
IDEA-148854: AppCode crashes randomly every 15 mins or so
Browse files Browse the repository at this point in the history
--HG--
branch : 8u40-verified-fixes
  • Loading branch information
forantar committed Jan 21, 2016
1 parent deb7383 commit 02f9a5f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
21 changes: 15 additions & 6 deletions src/macosx/classes/sun/lwawt/macosx/CAccessibility.java
Expand Up @@ -82,6 +82,15 @@ static <T> T invokeAndWait(final Callable<T> callable, final Component c) {
return null;
}

static <T> T invokeAndWait(final Callable<T> callable, final Component c, final T defValue) {
T value = null;
try {
value = LWCToolkit.invokeAndWait(callable, c);
} catch (final Exception e) { e.printStackTrace(); }

return value != null ? value : defValue;
}

static void invokeLater(final Runnable runnable, final Component c) {
try {
LWCToolkit.invokeLater(runnable, c);
Expand Down Expand Up @@ -177,7 +186,7 @@ public Boolean call() throws Exception {

return new Boolean(as.isAccessibleChildSelected(index));
}
}, c);
}, c, false);
}

public static AccessibleStateSet getAccessibleStateSet(final AccessibleContext ac, final Component c) {
Expand All @@ -199,7 +208,7 @@ public Boolean call() throws Exception {
if (ass == null) return null;
return ass.contains(as);
}
}, c);
}, c, false);
}

static Field getAccessibleBundleKeyFieldWithReflection() {
Expand Down Expand Up @@ -265,7 +274,7 @@ public static int getCharCount(final AccessibleText at, final Component c) {
public Integer call() throws Exception {
return at.getCharCount();
}
}, c);
}, c, 0);
}

// Accessibility Threadsafety for JavaComponentAccessibility.m
Expand All @@ -290,7 +299,7 @@ public Integer call() throws Exception {
if (ac == null) return null;
return ac.getAccessibleIndexInParent();
}
}, c);
}, c, -1);
}

public static AccessibleComponent getAccessibleComponent(final Accessible a, final Component c) {
Expand Down Expand Up @@ -386,7 +395,7 @@ public Boolean call() throws Exception {

return aComp.isFocusTraversable();
}
}, c);
}, c, false);
}

public static Accessible accessibilityHitTest(final Container parent, final float hitPointX, final float hitPointY) {
Expand Down Expand Up @@ -443,7 +452,7 @@ public Boolean call() throws Exception {

return aComp.isEnabled();
}
}, c);
}, c, false);
}

// KCH - can we make this a postEvent instead?
Expand Down
2 changes: 1 addition & 1 deletion src/macosx/classes/sun/lwawt/macosx/CAccessible.java
Expand Up @@ -96,7 +96,7 @@ protected synchronized void dispose() {

@Override
public AccessibleContext getAccessibleContext() {
return accessible.getAccessibleContext();
return accessible != null ? accessible.getAccessibleContext() : null;
}

// currently only supports text components
Expand Down
7 changes: 4 additions & 3 deletions src/macosx/native/sun/awt/JavaComponentAccessibility.m
Expand Up @@ -323,8 +323,9 @@ + (JavaComponentAccessibility *)createWithAccessible:(jobject)jaccessible withEn
{
jobject jcomponent = [(AWTView *)view awtComponent:env];
jint index = JNFCallStaticIntMethod(env, sjm_getAccessibleIndexInParent, jaccessible, jcomponent);
NSString *javaRole = getJavaRole(env, jaccessible, jcomponent);
if (index < 0) return nil;

NSString *javaRole = getJavaRole(env, jaccessible, jcomponent);
return [self createWithAccessible:jaccessible role:javaRole index:index withEnv:env withView:view];
}

Expand Down Expand Up @@ -663,8 +664,8 @@ - (NSUInteger)accessibilityIndexOfChild:(id)child
if (![[self accessibilityRoleAttribute] isEqualToString:NSAccessibilityListRole]) {
return [super accessibilityIndexOfChild:child];
}

return JNFCallStaticIntMethod([ThreadUtilities getJNIEnv], sjm_getAccessibleIndexInParent, ((JavaComponentAccessibility *)child)->fAccessible, ((JavaComponentAccessibility *)child)->fComponent);
jint index = JNFCallStaticIntMethod([ThreadUtilities getJNIEnv], sjm_getAccessibleIndexInParent, ((JavaComponentAccessibility *)child)->fAccessible, ((JavaComponentAccessibility *)child)->fComponent);
return index >= 0 ? index : 0;
}

// Without this optimization accessibilityChildrenAttribute is called in order to get the entire array of children.
Expand Down

0 comments on commit 02f9a5f

Please sign in to comment.