From 6cc0d44d20de8e537e42dac66de344354ea80d1c Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 17:26:16 -0300 Subject: order correction: unreffing fonts in ents needs loadedPtr so that must go before loadedPrt is nulled; this didn't crash simply because we never freed FontFactory before; also some comments and remove redundant multiply in hash function (bzr r12619) --- src/libnrtype/FontFactory.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index c896cc470..9fc553efd 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -25,7 +25,6 @@ typedef INK_UNORDERED_MAP(g_malloc(maxEnt*sizeof(font_entry)))), @@ -327,12 +326,6 @@ font_factory::font_factory(void) : font_factory::~font_factory(void) { - if (loadedPtr) { - FaceMapType* tmp = static_cast(loadedPtr); - delete tmp; - loadedPtr = 0; - } - for (int i = 0;i < nbEnt;i++) ents[i].f->Unref(); if ( ents ) g_free(ents); @@ -344,6 +337,12 @@ font_factory::~font_factory(void) #endif //g_object_unref(fontContext); + if (loadedPtr) { + FaceMapType* tmp = static_cast(loadedPtr); + delete tmp; + loadedPtr = 0; + } + // Delete the pango font pointers in the string to instance map PangoStringToDescrMap::iterator it = fontInstanceMap.begin(); while (it != fontInstanceMap.end()) { @@ -1126,7 +1125,7 @@ void font_factory::AddInCache(font_instance *who) return; } who->Ref(); - if ( nbEnt == maxEnt ) { + if ( nbEnt == maxEnt ) { // cache is filled, unref the oldest-accessed font in it int bi = 0; double ba = ents[bi].age; for (int i = 1;i < nbEnt;i++) { -- cgit v1.2.3