On Wed, Sep 12, 2007 at 01:00:02AM -0500, Bo Peng wrote:
> > I will compile with gcc 4 and try again.
> 
> Gcc4 + Qt 422 crashes.
> 
> Gcc4 + Qt 4.0 (or 4.11? not sure) does not.

Because that code is only compiled in for Qt >= 4.2

> Have not tested Gcc 3 + Qt 4.0, but it is likely a Qt 422 problem.

No, this must be a fontconfig problem. I tested it and saw that it
crashes with fontconfig version 2.2.3 but not with 2.4.2.

The attached patch should solve the problem. As the added fonts are
application specific, fontconfig should do the cleanup for us, even
if the docs say nothing to this end.

-- 
Enrico
Index: src/frontends/qt4/GuiFontLoader.cpp
===================================================================
--- src/frontends/qt4/GuiFontLoader.cpp (revision 20235)
+++ src/frontends/qt4/GuiFontLoader.cpp (working copy)
@@ -196,19 +196,17 @@
 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()
-{
-#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) {
Index: src/frontends/qt4/GuiFontLoader.h
===================================================================
--- src/frontends/qt4/GuiFontLoader.h   (revision 20235)
+++ src/frontends/qt4/GuiFontLoader.h   (working copy)
@@ -48,7 +48,7 @@
        GuiFontLoader();
 
        /// Destructor
-       ~GuiFontLoader();
+       virtual ~GuiFontLoader() {}
 
        virtual void update();
        virtual bool available(Font const & f);
@@ -74,9 +74,6 @@
        }
 
 private:
-#if QT_VERSION >= 0x040200
-       int * fontID;
-#endif
        /// BUTT ugly !
        QLFontInfo * fontinfo_[Font::NUM_FAMILIES][2][4][10];
 };

Reply via email to