changeset 5107:55126bbf3cc9

7152608: [macosx] Crash in liblwawt.dylib in AccelGlyphCache_RemoveCellInfo Reviewed-by: kizune
author bae
date Fri, 16 Mar 2012 11:39:31 +0400
parents 54b91467ed95
children df49f9ddd89f
files src/macosx/classes/sun/font/CStrike.java src/macosx/classes/sun/font/CStrikeDisposer.java src/macosx/native/sun/font/AWTStrike.m
diffstat 3 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/font/CStrike.java	Thu Mar 15 20:55:45 2012 +0400
+++ b/src/macosx/classes/sun/font/CStrike.java	Fri Mar 16 11:39:31 2012 +0400
@@ -500,7 +500,10 @@
                 final Iterator<Long> i = generalCache.values().iterator();
                 while (i.hasNext()) {
                     final long longValue = i.next().longValue();
-                    if (longValue != -1 && longValue != 0) StrikeCache.freeLongPointer(longValue);
+                    if (longValue != -1 && longValue != 0) {
+                        removeGlyphInfoFromCache(longValue);
+                        StrikeCache.freeLongPointer(longValue);
+                    }
                 }
             }
 
@@ -512,7 +515,10 @@
         private static void disposeLongArray(final long[] longArray) {
             for (int i = 0; i < longArray.length; i++) {
                 final long ptr = longArray[i];
-                if (ptr != 0 && ptr != -1) StrikeCache.freeLongPointer(ptr); // free's the native struct pointer
+                if (ptr != 0 && ptr != -1) {
+                    removeGlyphInfoFromCache(ptr);
+                    StrikeCache.freeLongPointer(ptr); // free's the native struct pointer
+                }
             }
         }
 
--- a/src/macosx/classes/sun/font/CStrikeDisposer.java	Thu Mar 15 20:55:45 2012 +0400
+++ b/src/macosx/classes/sun/font/CStrikeDisposer.java	Fri Mar 16 11:39:31 2012 +0400
@@ -85,4 +85,6 @@
     }
 
     private native void freeNativeScalerContext(long pContext);
+
+    protected static native void removeGlyphInfoFromCache(long glyphInfo);
 }
--- a/src/macosx/native/sun/font/AWTStrike.m	Thu Mar 15 20:55:45 2012 +0400
+++ b/src/macosx/native/sun/font/AWTStrike.m	Fri Mar 16 11:39:31 2012 +0400
@@ -27,11 +27,13 @@
 #import "java_awt_geom_PathIterator.h"
 #import "sun_awt_SunHints.h"
 #import "sun_font_CStrike.h"
+#import "sun_font_CStrikeDisposer.h"
 #import "CGGlyphImages.h"
 #import "CGGlyphOutlines.h"
 #import "AWTStrike.h"
 #import "CoreTextSupport.h"
 //#import "jni_util.h"
+#include "fontscalerdefs.h"
 
 @implementation AWTStrike
 
@@ -418,3 +420,19 @@
 
     return metrics;
 }
+
+extern void AccelGlyphCache_RemoveAllInfos(GlyphInfo* glyph);
+/*
+ * Class:     sun_font_CStrikeDisposer
+ * Method:    removeGlyphInfoFromCache
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_sun_font_CStrikeDisposer_removeGlyphInfoFromCache
+(JNIEnv *env, jclass cls, jlong glyphInfo)
+{
+    JNF_COCOA_ENTER(env);
+
+    AccelGlyphCache_RemoveAllCellInfos((GlyphInfo*)jlong_to_ptr(glyphInfo));
+
+    JNF_COCOA_EXIT(env);
+}