From 15cf4757dc0099301662f8a26da561434cc07cfa Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Mon, 5 May 2014 16:08:07 -0700 Subject: Proper refcounting for Minikin objects This patch introduces proper lifecycle maintenance (based on reference counting) for Minkin objects, particularly FontFamily and FontCollection. The patch depends on the corresponding Ref and Unref methods being available in Minikin. Change-Id: I91935e953d5a522e1adc496f2ce3a598be35de2b --- graphics/java/android/graphics/FontFamily.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'graphics') diff --git a/graphics/java/android/graphics/FontFamily.java b/graphics/java/android/graphics/FontFamily.java index 7c55ae8..a759a79 100644 --- a/graphics/java/android/graphics/FontFamily.java +++ b/graphics/java/android/graphics/FontFamily.java @@ -36,13 +36,21 @@ public class FontFamily { throw new RuntimeException(); } } - // TODO: finalization + + @Override + protected void finalize() throws Throwable { + try { + nUnrefFamily(mNativePtr); + } finally { + super.finalize(); + } + } public boolean addFont(File path) { return nAddFont(mNativePtr, path.getAbsolutePath()); } static native long nCreateFamily(); - static native void nDestroyFamily(long nativePtr); + static native void nUnrefFamily(long nativePtr); static native boolean nAddFont(long nativeFamily, String path); } -- cgit v1.1