summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-25 16:12:11 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-25 16:12:11 +0200
commitc7cdf3aac7ef9571ce0c0cf25a2c8455c7604451 (patch)
treeff17379a7643d47224a500714d825d561172a282 /src/gui
parent3f64156e918a8cf5da1b68191a280f0daf3d954b (diff)
parent1e6630b54ce9a005c2cffac4dac95641838e8231 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/corelib/mimetypes/qmimeprovider.cpp src/corelib/mimetypes/qmimetype.cpp Change-Id: Ib483ddb6bfc380e7c8f195feca535703814c3872
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qkeysequence.cpp10
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp1
-rw-r--r--src/gui/kernel/qwindow.cpp2
-rw-r--r--src/gui/text/qfontengine.cpp59
-rw-r--r--src/gui/text/qfontengine_p.h7
5 files changed, 39 insertions, 40 deletions
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index f1135db307..9a75f4bc83 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -411,7 +411,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
static const struct {
int key;
- const char* name;
+ const char name[25];
} keyname[] = {
//: This and all following "incomprehensible" strings in QShortcut context
//: are key names. Please use the localized names appearing on actual
@@ -693,8 +693,8 @@ static const struct {
{ Qt::Key_TouchpadOn, QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
{ Qt::Key_TouchpadOff, QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
- { 0, 0 }
};
+static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
/*!
\enum QKeySequence::StandardKey
@@ -1179,7 +1179,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
for (int tran = 0; tran < 2; ++tran) {
if (!nativeText)
++tran;
- for (int i = 0; keyname[i].name; ++i) {
+ for (int i = 0; i < numKeyNames; ++i) {
QString keyName(tran == 0
? QCoreApplication::translate("QShortcut", keyname[i].name)
: QString::fromLatin1(keyname[i].name));
@@ -1318,7 +1318,7 @@ QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat forma
#if defined(Q_OS_MACX)
NonSymbol:
#endif
- while (keyname[i].name) {
+ while (i < numKeyNames) {
if (key == keyname[i].key) {
p = nativeText ? QCoreApplication::translate("QShortcut", keyname[i].name)
: QString::fromLatin1(keyname[i].name);
@@ -1330,7 +1330,7 @@ NonSymbol:
// fall back on the unicode representation of it...
// Or else characters like Qt::Key_aring may not get displayed
// (Really depends on you locale)
- if (!keyname[i].name) {
+ if (i >= numKeyNames) {
if (!QChar::requiresSurrogates(key)) {
p = QChar(ushort(key)).toUpper();
} else {
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
index d18847c434..41f7251277 100644
--- a/src/gui/kernel/qoffscreensurface.cpp
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -183,6 +183,7 @@ void QOffscreenSurface::create()
if (QThread::currentThread() != qGuiApp->thread())
qWarning("Attempting to create QWindow-based QOffscreenSurface outside the gui thread. Expect failures.");
d->offscreenWindow = new QWindow(d->screen);
+ d->offscreenWindow->setObjectName("QOffscreenSurface");
// Remove this window from the global list since we do not want it to be destroyed when closing the app.
// The QOffscreenSurface has to be usable even after exiting the event loop.
QGuiApplicationPrivate::window_list.removeOne(d->offscreenWindow);
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index f061a2bf50..5f71bdaded 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -210,6 +210,8 @@ QWindow::~QWindow()
{
destroy();
QGuiApplicationPrivate::window_list.removeAll(this);
+ if (!QGuiApplicationPrivate::is_app_closing)
+ QGuiApplicationPrivate::instance()->modalWindowList.removeOne(this);
}
void QWindowPrivate::init()
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index fe5d544dba..4f0c6d25f7 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1039,46 +1039,45 @@ QByteArray QFontEngine::getSfntTable(uint tag) const
return table;
}
-void QFontEngine::clearGlyphCache(const void *key)
+void QFontEngine::clearGlyphCache(const void *context)
{
- for (QLinkedList<GlyphCacheEntry>::iterator it = m_glyphCaches.begin(), end = m_glyphCaches.end(); it != end; ) {
- if (it->context == key)
- it = m_glyphCaches.erase(it);
- else
- ++it;
- }
+ m_glyphCaches.remove(context);
}
-void QFontEngine::setGlyphCache(const void *key, QFontEngineGlyphCache *data)
+void QFontEngine::setGlyphCache(const void *context, QFontEngineGlyphCache *cache)
{
- Q_ASSERT(data);
+ Q_ASSERT(cache);
- GlyphCacheEntry entry;
- entry.context = key;
- entry.cache = data;
- if (m_glyphCaches.contains(entry))
- return;
+ GlyphCaches &caches = m_glyphCaches[context];
+ for (GlyphCaches::const_iterator it = caches.constBegin(), end = caches.constEnd(); it != end; ++it) {
+ if (cache == it->cache.data())
+ return;
+ }
- // Limit the glyph caches to 4. This covers all 90 degree rotations and limits
- // memory use when there is continuous or random rotation
- if (m_glyphCaches.size() == 4)
- m_glyphCaches.removeLast();
+ // Limit the glyph caches to 4 per context. This covers all 90 degree rotations,
+ // and limits memory use when there is continuous or random rotation
+ if (caches.size() == 4)
+ caches.removeLast();
- m_glyphCaches.push_front(entry);
+ GlyphCacheEntry entry;
+ entry.cache = cache;
+ caches.push_front(entry);
}
-QFontEngineGlyphCache *QFontEngine::glyphCache(const void *key, GlyphFormat format, const QTransform &transform) const
+QFontEngineGlyphCache *QFontEngine::glyphCache(const void *context, GlyphFormat format, const QTransform &transform) const
{
- for (QLinkedList<GlyphCacheEntry>::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) {
- QFontEngineGlyphCache *c = it->cache.data();
- if (key == it->context
- && format == c->glyphFormat()
- && qtransform_equals_no_translate(c->m_transform, transform)) {
- return c;
- }
+ const QHash<const void*, GlyphCaches>::const_iterator caches = m_glyphCaches.constFind(context);
+ if (caches == m_glyphCaches.cend())
+ return Q_NULLPTR;
+
+ for (GlyphCaches::const_iterator it = caches->begin(), end = caches->end(); it != end; ++it) {
+ QFontEngineGlyphCache *cache = it->cache.data();
+ if (format == cache->glyphFormat() && qtransform_equals_no_translate(cache->m_transform, transform))
+ return cache;
}
- return 0;
+
+ return Q_NULLPTR;
}
static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs)
@@ -1558,12 +1557,11 @@ QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round)
QFontEngine::GlyphCacheEntry::GlyphCacheEntry()
- : context(0)
{
}
QFontEngine::GlyphCacheEntry::GlyphCacheEntry(const GlyphCacheEntry &o)
- : context(o.context), cache(o.cache)
+ : cache(o.cache)
{
}
@@ -1573,7 +1571,6 @@ QFontEngine::GlyphCacheEntry::~GlyphCacheEntry()
QFontEngine::GlyphCacheEntry &QFontEngine::GlyphCacheEntry::operator=(const GlyphCacheEntry &o)
{
- context = o.context;
cache = o.cache;
return *this;
}
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 1430444c7e..132531f5bc 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -357,12 +357,11 @@ private:
GlyphCacheEntry &operator=(const GlyphCacheEntry &);
- const void *context;
QExplicitlySharedDataPointer<QFontEngineGlyphCache> cache;
- bool operator==(const GlyphCacheEntry &other) const { return context == other.context && cache == other.cache; }
+ bool operator==(const GlyphCacheEntry &other) const { return cache == other.cache; }
};
-
- mutable QLinkedList<GlyphCacheEntry> m_glyphCaches;
+ typedef QLinkedList<GlyphCacheEntry> GlyphCaches;
+ mutable QHash<const void *, GlyphCaches> m_glyphCaches;
private:
QVariant m_userData;