From 9f7bc42b7d6466b8422c7cc3900a7eb3bfa60bf9 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 5 Apr 2013 16:20:15 +0300 Subject: Fix QFontconfigDatabase unable to fallback to a localized family When populating the font database, FcPatternGetString(FC_FAMILY) gets a localized font family name; but, in fallbacksForFamily, it gets a non-localized font family name, so it unable to find the proper font to fallback. Simply register all family name variants as aliases to localized name and make sure they are checked when getting fallback families. Task-number: QTBUG-28806 Task-number: QTBUG-30415 Change-Id: I71c03ae9b51a28736c2576f3442f1bbdb3497c09 Reviewed-by: Friedemann Kleint Reviewed-by: jian liang Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontdatabase.cpp | 20 +++++++------------- src/gui/text/qfontdatabase_qpa.cpp | 3 +-- 2 files changed, 8 insertions(+), 15 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index e3270b430f..86a5bed15d 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -344,6 +344,7 @@ struct QtFontFamily bool askedForFallback; unsigned char writingSystems[QFontDatabase::WritingSystemsCount]; + bool matchesFamilyName(const QString &familyName) const; QtFontFoundry *foundry(const QString &f, bool = false); }; @@ -383,6 +384,11 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) return foundries[count++]; } +bool QtFontFamily::matchesFamilyName(const QString &familyName) const +{ + return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive); +} + class QFontDatabasePrivate { @@ -852,19 +858,7 @@ static bool matchFamilyName(const QString &familyName, QtFontFamily *f) { if (familyName.isEmpty()) return true; - - if (f->name.compare(familyName, Qt::CaseInsensitive) == 0) - return true; - - QStringList::const_iterator it = f->aliases.constBegin(); - while (it != f->aliases.constEnd()) { - if ((*it).compare(familyName, Qt::CaseInsensitive) == 0) - return true; - - ++it; - } - - return false; + return f->matchesFamilyName(familyName); } /*! diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index be42e892fa..32580ada7a 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -110,8 +110,7 @@ static QStringList fallbackFamilies(const QString &family, QFont::Style style, Q for (i = retList.begin(); i != retList.end(); ++i) { bool contains = false; for (int j = 0; j < db->count; j++) { - QtFontFamily *qtFamily = db->families[j]; - if (!(i->compare(qtFamily->name,Qt::CaseInsensitive))) { + if (db->families[j]->matchesFamilyName(*i)) { contains = true; break; } -- cgit v1.2.3 From c0300eed194e742d3d802b742379f83018be7bfa Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 9 Apr 2013 16:02:30 +0300 Subject: QFreetypeFace: Fix getFace() uses UTF-8 paths on non UTF-8 locales QFontEngine::FaceId::filename is intended to be local8Bit-encoded but QFreetypeFace::getFace() always treats it like UTF-8-encoded. Also replace explicit (to|from)Local8Bit and toLatin FaceId::filename conversions with QFile::(en|de)codeName, where appropriate. Change-Id: Ic7beabf0a160f2f02f1667bcb8e6067adaba1c16 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 19b4411b47..10225febcb 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -232,7 +232,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, QScopedPointer newFreetype(new QFreetypeFace); FT_Face face; if (!face_id.filename.isEmpty()) { - QString fileName = QString::fromUtf8(face_id.filename); + QString fileName = QFile::decodeName(face_id.filename); if (face_id.filename.startsWith(":qmemoryfonts/")) { // from qfontdatabase.cpp QByteArray idx = face_id.filename; -- cgit v1.2.3 From 3a3e9b74ebdeef6a1bfcf87a47a23d12ad471105 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Wed, 10 Apr 2013 12:03:39 +0200 Subject: Do not show the warning if queryAI() returns an invalid interface. We should only warn about missing a11y plugins if iface is 0, since we obviously have the plugin otherwise. This got triggered by that a visible widget got destructed, which in turn called hide(), which ultimately ended up calling QAccessible::updateAccessibility(QAccessible::ObjectHide). When QAccessibleEvent::accessibleInterface() then called queryAccessibleInterface(), QAI::isValid() would return false because the widget was in its destructor. Change-Id: If655e00e7bb3737a39e24e26dbd1e23edd515bf5 Reviewed-by: Friedemann Kleint Reviewed-by: Frederik Gladhorn --- src/gui/accessible/qaccessible.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 7487aabde5..4fd595ed5a 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -1507,7 +1507,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object); if (!iface || !iface->isValid()) { static bool hasWarned = false; - if (!hasWarned) { + if (!iface && !hasWarned) { qWarning() << "Problem creating accessible interface for: " << m_object << endl << "Make sure to deploy Qt with accessibility plugins."; hasWarned = true; -- cgit v1.2.3 From e9760f1559361c39f269fb89f1ebd01f6ee8378d Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Mon, 11 Mar 2013 14:41:52 +0100 Subject: Fix the check if mouse events should be synthesized from touch events In QGuiApplication only Qt::AA_SynthesizeMouseForUnhandledTouchEvents is taken into account when synthesizing mouse from touch events, in QApplication only the PlatformIntegration syle hint QPlatformIntegration::SynthesizeMouseFromTouchEvents. With this patch both attributes are checked. Furthermore the check was moved out of translateTouchToMouse in QApplication in order not to influence the result which is returned to the user, when mouse events are not be synthesized. Change-Id: I87ac7299f0a9fbf0a083eff9c547f0dbfab75dfb Reviewed-by: Fabian Bumberger Reviewed-by: Shawn Rutledge --- src/gui/kernel/qguiapplication.cpp | 8 +++++++- src/gui/kernel/qguiapplication_p.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index c2e19ca2a8..432929fec5 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -602,6 +602,12 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking return false; } +bool QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled() +{ + return QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents) + && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool(); +} + /*! Returns the QWindow that receives events tied to focus, such as key events. @@ -2054,7 +2060,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To } QGuiApplication::sendSpontaneousEvent(w, &touchEvent); - if (!e->synthetic && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) { + if (!e->synthetic && !touchEvent.isAccepted() && synthesizeMouseFromTouchEventsEnabled()) { // exclude touchpads as those generate their own mouse events if (touchEvent.device()->type() != QTouchDevice::TouchPad) { Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton; diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 22d95b2121..376890ef47 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -191,6 +191,8 @@ public: static void updateBlockedStatus(QWindow *window); virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const; + static bool synthesizeMouseFromTouchEventsEnabled(); + static Qt::MouseButtons buttons; static ulong mousePressTime; static Qt::MouseButton mousePressButton; -- cgit v1.2.3 From b3dae6848dfbc46e5574a5289ea44019eb2dafd7 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sun, 7 Apr 2013 16:29:22 +0300 Subject: Fix leaking of QFontEngineData QFontCache now references QFontEngineData-s it maintains, so that QFont instances not freed prior to calling ~QFontCache() would destroy QFontEngineData on their own. Task-number: QTBUG-25434 Change-Id: Ia7679d64de436841f09ac7be62ceb570e50cce5b Reviewed-by: Friedemann Kleint Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: jian liang --- src/gui/text/qfont.cpp | 23 ++++++++++++++--------- src/gui/text/qfont_p.h | 3 +++ src/gui/text/qfontdatabase.cpp | 3 +-- 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index fc694dc497..1d6cf3ceca 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -191,8 +191,8 @@ QFontPrivate::QFontPrivate(const QFontPrivate &other) QFontPrivate::~QFontPrivate() { - if (engineData) - engineData->ref.deref(); + if (engineData && !engineData->ref.deref()) + delete engineData; engineData = 0; if (scFont && scFont != this) scFont->ref.deref(); @@ -210,7 +210,8 @@ QFontEngine *QFontPrivate::engineForScript(int script) const script = QChar::Script_Common; if (engineData && engineData->fontCache != QFontCache::instance()) { // throw out engineData that came from a different thread - engineData->ref.deref(); + if (!engineData->ref.deref()) + delete engineData; engineData = 0; } if (!engineData || !QT_FONT_ENGINE_FROM_DATA(engineData, script)) @@ -316,13 +317,14 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other) QFontEngineData::QFontEngineData() - : ref(1), fontCache(QFontCache::instance()) + : ref(0), fontCache(QFontCache::instance()) { memset(engines, 0, QChar::ScriptCount * sizeof(QFontEngine *)); } QFontEngineData::~QFontEngineData() { + Q_ASSERT(ref.load() == 0); for (int i = 0; i < QChar::ScriptCount; ++i) { if (engines[i]) { if (!engines[i]->ref.deref()) @@ -637,8 +639,8 @@ QFont::QFont(QFontPrivate *data) void QFont::detach() { if (d->ref.load() == 1) { - if (d->engineData) - d->engineData->ref.deref(); + if (d->engineData && !d->engineData->ref.deref()) + delete d->engineData; d->engineData = 0; if (d->scFont && d->scFont != d.data()) d->scFont->ref.deref(); @@ -2641,7 +2643,7 @@ QFontCache::~QFontCache() EngineDataCache::ConstIterator it = engineDataCache.constBegin(), end = engineDataCache.constEnd(); while (it != end) { - if (it.value()->ref.load() == 0) + if (!it.value()->ref.deref()) delete it.value(); else FC_DEBUG("QFontCache::~QFontCache: engineData %p still has refcount %d", @@ -2713,7 +2715,9 @@ void QFontCache::insertEngineData(const QFontDef &def, QFontEngineData *engineDa def.pixelSize, def.weight, def.style, def.fixedPitch); } #endif + Q_ASSERT(!engineDataCache.contains(def)); + engineData->ref.ref(); engineDataCache.insert(def, engineData); increaseCost(sizeof(QFontEngineData)); } @@ -2829,7 +2833,7 @@ void QFontCache::timerEvent(QTimerEvent *) for (; it != end; ++it) { FC_DEBUG(" %p: ref %2d", it.value(), int(it.value()->ref.load())); - if (it.value()->ref.load() != 0) + if (it.value()->ref.load() != 1) in_use_cost += engine_data_cost; } } @@ -2894,9 +2898,10 @@ void QFontCache::timerEvent(QTimerEvent *) // clean out all unused engine data EngineDataCache::Iterator it = engineDataCache.begin(); while (it != engineDataCache.end()) { - if (it.value()->ref.load() == 0) { + if (it.value()->ref.load() == 1) { FC_DEBUG(" %p", it.value()); decreaseCost(sizeof(QFontEngineData)); + it.value()->ref.deref(); delete it.value(); it = engineDataCache.erase(it); } else { diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 4cbf51d59c..115e866f24 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -143,6 +143,9 @@ public: QFontCache *fontCache; QFontEngine *engines[QChar::ScriptCount]; + +private: + Q_DISABLE_COPY(QFontEngineData) }; diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 86a5bed15d..62379cd592 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -619,9 +619,8 @@ static void getEngineData(const QFontPrivate *d, const QFontDef &def) // create a new one d->engineData = new QFontEngineData; QFontCache::instance()->insertEngineData(def, d->engineData); - } else { - d->engineData->ref.ref(); } + d->engineData->ref.ref(); } static QStringList familyList(const QFontDef &req) -- cgit v1.2.3