Correct the order in which FT_Done_Face is called via the library's destructors. Fixes a Bzflag crash upon exit. Patch courtesy of Mathew Eis (kingrobot) from SF patch 2721799.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
diff --git a/msvc/vc71/ftgl_dll.vcproj b/msvc/vc71/ftgl_dll.vcproj
index f7e6cb0..e3e2b97 100644
--- a/msvc/vc71/ftgl_dll.vcproj
+++ b/msvc/vc71/ftgl_dll.vcproj
@@ -142,6 +142,9 @@
RelativePath="..\..\src\FTCharmap.cpp">
</File>
<File
+ RelativePath="..\..\src\FTCleanup.cpp">
+ </File>
+ <File
RelativePath="..\..\src\FTContour.cpp">
</File>
<File
@@ -252,6 +255,9 @@
RelativePath="..\..\src\FTCharToGlyphIndexMap.h">
</File>
<File
+ RelativePath="..\..\src\FTCleanup.h">
+ </File>
+ <File
RelativePath="..\..\src\FTContour.h">
</File>
<File
diff --git a/msvc/vc8/ftgl_dll.vcproj b/msvc/vc8/ftgl_dll.vcproj
index 8d10fbd..cacdda6 100644
--- a/msvc/vc8/ftgl_dll.vcproj
+++ b/msvc/vc8/ftgl_dll.vcproj
@@ -224,6 +224,10 @@
>
</File>
<File
+ RelativePath="..\..\src\FTCleanup.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\src\FTContour.cpp"
>
</File>
@@ -357,6 +361,10 @@
>
</File>
<File
+ RelativePath="..\..\src\FTCleanup.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\FTContour.h"
>
</File>
diff --git a/msvc/vc8/ftgl_static.vcproj b/msvc/vc8/ftgl_static.vcproj
index d88f354..a83c9e2 100644
--- a/msvc/vc8/ftgl_static.vcproj
+++ b/msvc/vc8/ftgl_static.vcproj
@@ -159,6 +159,10 @@
>
</File>
<File
+ RelativePath="..\..\src\FTCleanup.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\src\FTContour.cpp"
>
</File>
@@ -297,6 +301,10 @@
>
</File>
<File
+ RelativePath="..\..\src\FTCleanup.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\FTContour.h"
>
</File>
diff --git a/msvc/vc9/ftgl_dll.vcproj b/msvc/vc9/ftgl_dll.vcproj
index 10c9218..0965a9d 100644
--- a/msvc/vc9/ftgl_dll.vcproj
+++ b/msvc/vc9/ftgl_dll.vcproj
@@ -225,6 +225,10 @@
>
</File>
<File
+ RelativePath="..\..\src\FTCleanup.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\src\FTContour.cpp"
>
</File>
@@ -358,6 +362,10 @@
>
</File>
<File
+ RelativePath="..\..\src\FTCleanup.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\FTContour.h"
>
</File>
diff --git a/msvc/vc9/ftgl_static.vcproj b/msvc/vc9/ftgl_static.vcproj
index 24eba13..d52541e 100644
--- a/msvc/vc9/ftgl_static.vcproj
+++ b/msvc/vc9/ftgl_static.vcproj
@@ -160,6 +160,10 @@
>
</File>
<File
+ RelativePath="..\..\src\FTCleanup.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\src\FTContour.cpp"
>
</File>
@@ -298,6 +302,10 @@
>
</File>
<File
+ RelativePath="..\..\src\FTCleanup.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\FTContour.h"
>
</File>
diff --git a/src/FTFace.cpp b/src/FTFace.cpp
index 30f9793..eb6ffff 100644
--- a/src/FTFace.cpp
+++ b/src/FTFace.cpp
@@ -27,6 +27,7 @@
#include "config.h"
#include "FTFace.h"
+#include "FTCleanup.h"
#include "FTLibrary.h"
#include FT_TRUETYPE_TABLES_H
@@ -49,6 +50,8 @@ FTFace::FTFace(const char* fontFilePath, bool precomputeKerning)
return;
}
+ FTCleanup::Instance()->RegisterObject(&ftFace);
+
numGlyphs = (*ftFace)->num_glyphs;
hasKerningTable = (FT_HAS_KERNING((*ftFace)) != 0);
@@ -79,6 +82,8 @@ FTFace::FTFace(const unsigned char *pBufferBytes, size_t bufferSizeInBytes,
return;
}
+ FTCleanup::Instance()->RegisterObject(&ftFace);
+
numGlyphs = (*ftFace)->num_glyphs;
hasKerningTable = (FT_HAS_KERNING((*ftFace)) != 0);
@@ -95,6 +100,8 @@ FTFace::~FTFace()
if(ftFace)
{
+ FTCleanup::Instance()->UnregisterObject(&ftFace);
+
FT_Done_Face(*ftFace);
delete ftFace;
ftFace = 0;
diff --git a/src/FTLibrary.cpp b/src/FTLibrary.cpp
index 829ed59..da16e83 100644
--- a/src/FTLibrary.cpp
+++ b/src/FTLibrary.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "FTLibrary.h"
-
+#include "FTCleanup.h"
const FTLibrary& FTLibrary::Instance()
{
@@ -37,6 +37,8 @@ const FTLibrary& FTLibrary::Instance()
FTLibrary::~FTLibrary()
{
+ FTCleanup::Instance()->DestroyAll();
+
if(library != 0)
{
FT_Done_FreeType(*library);
@@ -70,5 +72,7 @@ bool FTLibrary::Initialise()
return false;
}
+ FTCleanup::Instance();
+
return true;
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 941b0cd..1cf74e5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,8 @@ libftgl_la_SOURCES = \
FTCharmap.cpp \
FTCharmap.h \
FTCharToGlyphIndexMap.h \
+ FTCleanup.cpp \
+ FTCleanup.h \
FTContour.cpp \
FTContour.h \
FTFace.cpp \