summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorbuliabyak <>2013-09-28 20:26:16 +0000
committerbuliabyak <>2013-09-28 20:26:16 +0000
commit6cc0d44d20de8e537e42dac66de344354ea80d1c (patch)
tree60552aca2791ed400b844973cec2d47428d9768b /src/libnrtype
parentprevent redundant firing of InitTheFace (pFont never changes, but init is cal... (diff)
downloadinkscape-6cc0d44d20de8e537e42dac66de344354ea80d1c.tar.gz
inkscape-6cc0d44d20de8e537e42dac66de344354ea80d1c.zip
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)
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/FontFactory.cpp17
1 files changed, 8 insertions, 9 deletions
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<PangoFontDescription*, font_instance*, font_descr_hash
// need to avoid using the size field
size_t font_descr_hash::operator()( PangoFontDescription *const &x) const {
int h = 0;
- h *= 1128467;
char const *theF = sp_font_description_get_family(x);
h += (theF)?g_str_hash(theF):0;
h *= 1128467;
@@ -295,7 +294,7 @@ font_factory *font_factory::Default(void)
}
font_factory::font_factory(void) :
- nbEnt(0),
+ nbEnt(0), // Note: this "ents" cache only keeps fonts from being unreffed, does not speed up access
maxEnt(32),
ents(static_cast<font_entry*>(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<FaceMapType*>(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<FaceMapType*>(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++) {