From 38f8d9d7a17037a34f4df229b1089536a6cdc8dc Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Thu, 27 Jan 2011 00:14:13 -0800 Subject: Correctly free resouces bound to scripts when the scripts are deleted. Change-Id: Idfcc30f1a7de0badeb6d8254ed508938d89f4070 b: 3381615 --- libs/rs/rsFont.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'libs/rs/rsFont.cpp') diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp index 8571c32e95ec..7fdfbe05f287 100644 --- a/libs/rs/rsFont.cpp +++ b/libs/rs/rsFont.cpp @@ -74,6 +74,15 @@ bool Font::init(const char *name, float fontSize, uint32_t dpi, const void *data return true; } +void Font::preDestroy() const { + for (uint32_t ct = 0; ct < mRSC->mStateFont.mActiveFonts.size(); ct++) { + if (mRSC->mStateFont.mActiveFonts[ct] == this) { + mRSC->mStateFont.mActiveFonts.removeAt(ct); + break; + } + } +} + void Font::invalidateTextureCache() { for (uint32_t i = 0; i < mCachedGlyphs.size(); i ++) { mCachedGlyphs.valueAt(i)->mIsValid = false; @@ -309,13 +318,6 @@ Font::~Font() { FT_Done_Face(mFace); } - for (uint32_t ct = 0; ct < mRSC->mStateFont.mActiveFonts.size(); ct++) { - if (mRSC->mStateFont.mActiveFonts[ct] == this) { - mRSC->mStateFont.mActiveFonts.removeAt(ct); - break; - } - } - for (uint32_t i = 0; i < mCachedGlyphs.size(); i ++) { CachedGlyphInfo *glyph = mCachedGlyphs.valueAt(i); delete glyph; @@ -799,11 +801,6 @@ void FontState::deinit(Context *rsc) { mDefault.clear(); - Vector fontsToDereference = mActiveFonts; - for (uint32_t i = 0; i < fontsToDereference.size(); i ++) { - fontsToDereference[i]->zeroUserRef(); - } - if (mLibrary) { FT_Done_FreeType( mLibrary ); mLibrary = NULL; -- cgit v1.2.3-59-g8ed1b