Fix crash with old versions (earlier than 2.2.92) of fontconfig.

* src/frontends/qt4/GuiFontLoader.{cpp,h}
	(GuiFontLoader::GuiFontLoader): don't store font IDs anymore,
	as we are not going to clean up after ourselves.
	(GuiFontLoader::~GuiFontLoader): make it virtual again and
	do nothing (avoids a crash with fontconfig < 2.2.92).


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20246 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2007-09-12 19:07:22 +00:00
parent 7eec20e0e1
commit e5cb4fc10f
2 changed files with 3 additions and 21 deletions

View File

@ -196,19 +196,17 @@ pair<QFont, bool> const getSymbolFont(string const & family)
GuiFontLoader::GuiFontLoader()
{
#if QT_VERSION >= 0x040200
fontID = new int[num_math_fonts];
string const fonts_dir =
addPath(package().system_support().absFilename(), "fonts");
for (int i = 0 ; i < num_math_fonts; ++i) {
string const font_file = lyx::support::os::external_path(
addName(fonts_dir, math_fonts[i] + ".ttf"));
fontID[i] = QFontDatabase::addApplicationFont(toqstr(font_file));
int fontID = QFontDatabase::addApplicationFont(toqstr(font_file));
LYXERR(Debug::FONT) << "Adding font " << font_file
<< static_cast<const char *>
(fontID[i] < 0 ? " FAIL" : " OK")
(fontID < 0 ? " FAIL" : " OK")
<< endl;
}
#endif
@ -221,19 +219,6 @@ GuiFontLoader::GuiFontLoader()
}
GuiFontLoader::~GuiFontLoader()
{
#if QT_VERSION >= 0x040200
for (int i = 0 ; i < num_math_fonts; ++i) {
if (fontID[i] >= 0)
QFontDatabase::removeApplicationFont(fontID[i]);
}
delete [] fontID;
#endif
}
void GuiFontLoader::update()
{
for (int i1 = 0; i1 < Font::NUM_FAMILIES; ++i1) {

View File

@ -48,7 +48,7 @@ public:
GuiFontLoader();
/// Destructor
~GuiFontLoader();
virtual ~GuiFontLoader() {}
virtual void update();
virtual bool available(Font const & f);
@ -74,9 +74,6 @@ public:
}
private:
#if QT_VERSION >= 0x040200
int * fontID;
#endif
/// BUTT ugly !
QLFontInfo * fontinfo_[Font::NUM_FAMILIES][2][4][10];
};