diff -rup qt-everywhere-commercial-src-4.8.4/src/gui/text/qfontdatabase_qws.cpp qt-everywhere-commercial-src-4.8.4-patched/src/gui/text/qfontdatabase_qws.cpp --- qt-everywhere-commercial-src-4.8.4/src/gui/text/qfontdatabase_qws.cpp 2012-11-23 11:28:53.000000000 +0100 +++ qt-everywhere-commercial-src-4.8.4-patched/src/gui/text/qfontdatabase_qws.cpp 2013-01-16 11:31:24.000000000 +0100 @@ -40,6 +40,11 @@ #include #include "qplatformdefs.h" +#if !defined(Q_OS_INTEGRITY) +#define QT_USE_MMAP +#endif + +#ifdef QT_USE_MMAP // for mmap #include #include @@ -48,6 +53,7 @@ #include #include #include +#endif // QT_USE_MMAP #ifdef QT_FONTS_ARE_RESOURCES #include @@ -79,15 +85,27 @@ void QFontDatabasePrivate::addQPF2File(c int f = QT_OPEN(file, O_RDONLY, 0); if (f < 0) return; +#ifdef QT_USE_MMAP const uchar *data = (const uchar *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, f, 0); +#else // QT_USE_MMAP + uchar *data = new uchar[st.st_size]; + if (QT_READ(f, data, st.st_size) != (qint64)st.st_size) + qFatal("Failed to read '%s'", QFile::encodeName(file).constData()); + +#endif // QT_USE_MMAP const int dataSize = st.st_size; -#else + FD_DEBUG() << "addQPF2File" << file << data; +#else // QT_FONTS_ARE_RESOURCES QResource res(QLatin1String(file.constData())); const uchar *data = res.data(); const int dataSize = res.size(); - //qDebug() << "addQPF2File" << file << data; -#endif + FD_DEBUG() << "addQPF2File" << file << data; +#endif // QT_FONTS_ARE_RESOURCES +#ifdef QT_USE_MMAP if (data && data != (const uchar *)MAP_FAILED) { +#else // QT_USE_MMAP + if (data) { +#endif // QT_USE_MMAP if (QFontEngineQPF::verifyHeader(data, dataSize)) { QString fontName = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_FontName).toString(); int pixelSize = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_PixelSize).toInt(); @@ -120,7 +138,11 @@ void QFontDatabasePrivate::addQPF2File(c qDebug() << "header verification of QPF2 font" << file << "failed. maybe it is corrupt?"; } #ifndef QT_FONTS_ARE_RESOURCES +#ifdef QT_USE_MMAP munmap((void *)data, st.st_size); +#else // QT_USE_MMAP + delete [] data; +#endif // QT_USE_MMAP #endif } #ifndef QT_FONTS_ARE_RESOURCES @@ -189,7 +211,7 @@ bool QFontDatabasePrivate::loadFromCache QString familyname; stream >> familyname; - //qDebug() << "populating database from" << binaryDb.fileName(); + FD_DEBUG() << "populating database from" << binaryDb.fileName(); while (!familyname.isEmpty() && !stream.atEnd()) { QString foundryname; int weight; @@ -218,7 +240,7 @@ bool QFontDatabasePrivate::loadFromCache } stream >> fallbackFamilies; - //qDebug() << "fallback families from cache:" << fallbackFamilies; + FD_DEBUG() << "fallback families from cache:" << fallbackFamilies; return true; } #endif // QT_FONTS_ARE_RESOURCES @@ -292,7 +314,7 @@ static void initializeDb() binaryDb.open(QIODevice::WriteOnly | QIODevice::Truncate); db->stream = new QDataStream(&binaryDb); *db->stream << DatabaseVersion << quint8(db->stream->version()) << fontpath; -// qDebug() << "creating binary database at" << binaryDb.fileName(); + FD_DEBUG() << "creating binary database at" << binaryDb.fileName(); // Load in font definition file FILE* fontdef=fopen(fontDirFile.toLocal8Bit().constData(),"r"); @@ -347,7 +369,7 @@ static void initializeDb() dir.refresh(); for (int i = 0; i < int(dir.count()); ++i) { const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i])); -// qDebug() << "looking at" << file; + FD_DEBUG() << "looking at" << file; db->addTTFile(file); } #endif @@ -357,7 +379,7 @@ static void initializeDb() dir.refresh(); for (int i = 0; i < int(dir.count()); ++i) { const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i])); -// qDebug() << "looking at" << file; + FD_DEBUG() << "looking at" << file; db->addQPF2File(file); } #endif @@ -375,7 +397,7 @@ static void initializeDb() QDir dir(fontpath, QLatin1String("*.qpf2")); for (int i = 0; i < int(dir.count()); ++i) { const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i])); - //qDebug() << "looking at" << file; + FD_DEBUG() << "looking at" << file; db->addQPF2File(file); } #endif @@ -424,7 +446,7 @@ static void initializeDb() #ifndef QT_NO_LIBRARY QStringList pluginFoundries = loader()->keys(); -// qDebug() << "plugin foundries:" << pluginFoundries; + FD_DEBUG() << "plugin foundries:" << pluginFoundries; for (int i = 0; i < pluginFoundries.count(); ++i) { const QString foundry(pluginFoundries.at(i)); @@ -478,7 +500,7 @@ static void initializeDb() if (add) db->fallbackFamilies << family->name; } - //qDebug() << "fallbacks on the server:" << db->fallbackFamilies; + FD_DEBUG() << "fallbacks on the server:" << db->fallbackFamilies; #ifndef QT_FONTS_ARE_RESOURCES *db->stream << db->fallbackFamilies; #endif diff -rup qt-everywhere-commercial-src-4.8.4/src/gui/text/qfontengine_qpf.cpp qt-everywhere-commercial-src-4.8.4-patched/src/gui/text/qfontengine_qpf.cpp --- qt-everywhere-commercial-src-4.8.4/src/gui/text/qfontengine_qpf.cpp 2012-11-23 11:28:53.000000000 +0100 +++ qt-everywhere-commercial-src-4.8.4-patched/src/gui/text/qfontengine_qpf.cpp 2013-01-16 11:00:08.000000000 +0100 @@ -31,6 +31,11 @@ #endif #include "private/qcore_unix_p.h" // overrides QT_OPEN +#if !defined(Q_OS_INTEGRITY) +#define QT_USE_MMAP +#endif + +#ifdef QT_USE_MMAP // for mmap #include #include @@ -39,6 +44,7 @@ #include #include #include +#endif // QT_USE_MMAP QT_BEGIN_NAMESPACE @@ -234,8 +240,15 @@ QList QFontEngineQPF::cleanU int fd = QT_OPEN(fileName.constData(), O_RDONLY, 0); if (fd >= 0) { +#ifdef QT_USE_MMAP void *header = ::mmap(0, sizeof(QFontEngineQPF::Header), PROT_READ, MAP_SHARED, fd, 0); if (header && header != MAP_FAILED) { +#else // QT_USE_MMAP + void *header = (void*)new uchar[sizeof(QFontEngineQPF::Header)]; + if (QT_READ(fd, header, sizeof(QFontEngineQPF::Header)) != (qint64)sizeof(QFontEngineQPF::Header)) + qFatal("Failed to read '%s'", QFile::encodeName(fileName).constData()); + if (header) { +#endif // QT_USE_MMAP quint32 lockValue = reinterpret_cast(header)->lock; if (lockValue && crashedClientIds.contains(lockValue)) { @@ -243,7 +256,11 @@ QList QFontEngineQPF::cleanU QFile::remove(QFile::decodeName(fileName)); } +#ifdef QT_USE_MMAP ::munmap(header, sizeof(QFontEngineQPF::Header)); +#else // QT_USE_MMAP + delete [] header; +#endif // QT_USE_MMAP } QT_CLOSE(fd); } @@ -371,12 +388,19 @@ QFontEngineQPF::QFontEngineQPF(const QFo } dataSize = st.st_size; - +#ifdef QT_USE_MMAP fontData = (const uchar *)::mmap(0, st.st_size, PROT_READ | (renderingFontEngine ? PROT_WRITE : 0), MAP_SHARED, fd, 0); if (!fontData || fontData == (const uchar *)MAP_FAILED) { #if defined(DEBUG_FONTENGINE) perror("mmap failed"); #endif +#else // QT_USE_MMAP + uchar *tempData = new uchar[st.st_size]; + if (QT_READ(fd, tempData, st.st_size) != (qint64)st.st_size) + qFatal("Failed to read '%s'", QFile::encodeName(fileName).constData()); + fontData = tempData; + if (!fontData) { +#endif // QT_USE_MMAP fontData = 0; return; } @@ -502,12 +526,16 @@ QFontEngineQPF::~QFontEngineQPF() #endif delete renderingFontEngine; if (fontData) { +#ifdef QT_USE_MMAP if (munmap((void *)fontData, dataSize) == -1) { #if defined(DEBUG_FONTENGINE) qErrnoWarning(errno, "~QFontEngineQPF: Unable to munmap"); #endif } - } +#else // QT_USE_MMAP + delete [] fontData; +#endif // QT_USE_MMAP + } if (fd != -1) ::close(fd); #if !defined(QT_NO_FREETYPE)