Correctly free resouces bound to scripts when the scripts are deleted.
Change-Id: Idfcc30f1a7de0badeb6d8254ed508938d89f4070
b: 3381615
diff --git a/rsFont.cpp b/rsFont.cpp
index 8571c32..7fdfbe0 100644
--- a/rsFont.cpp
+++ b/rsFont.cpp
@@ -74,6 +74,15 @@
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 @@
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 @@
mDefault.clear();
- Vector<Font*> fontsToDereference = mActiveFonts;
- for (uint32_t i = 0; i < fontsToDereference.size(); i ++) {
- fontsToDereference[i]->zeroUserRef();
- }
-
if (mLibrary) {
FT_Done_FreeType( mLibrary );
mLibrary = NULL;