diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qimage.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qxpmhandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qcursor.cpp | 6 | ||||
-rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qoffscreensurface.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 12 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 1 | ||||
-rw-r--r-- | src/gui/painting/qregion.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qcssparser.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qfontengine.cpp | 59 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qfontengine_p.h | 7 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtexthtmlparser.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qtexthtmlparser_p.h | 2 |
16 files changed, 55 insertions, 60 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 9b14500e7a..e1da0ffffc 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2129,7 +2129,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format, */ QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags) const { - if (d->format == format) + if (!d || d->format == format) return *this; if (format <= QImage::Format_Indexed8 && depth() == 32) { diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 756e31318f..1f1f6b388f 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -80,7 +80,7 @@ static const int xpmRgbTblSize = 657; static const struct XPMRGBData { uint value; - const char *name; + const char name[21]; } xpmRgbTbl[] = { { QRGB(240,248,255), "aliceblue" }, { QRGB(250,235,215), "antiquewhite" }, diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index dad6a1f382..b7035d47c4 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -374,9 +374,6 @@ QDataStream &operator>>(QDataStream &s, QCursor &c) because this size is supported on all platforms. Some platforms also support 16 x 16, 48 x 48, and 64 x 64 cursors. - \note On Windows CE, the cursor size is fixed. If the pixmap - is bigger than the system size, it will be scaled. - \sa QPixmap::QPixmap(), QPixmap::setMask() */ @@ -433,9 +430,6 @@ QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY) because this size is supported on all platforms. Some platforms also support 16 x 16, 48 x 48, and 64 x 64 cursors. - \note On Windows CE, the cursor size is fixed. If the pixmap - is bigger than the system size, it will be scaled. - \sa QBitmap::QBitmap(), QBitmap::setMask() */ 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..a9535a6ad7 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(QLatin1String("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/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a385332d6d..ac11b0f324 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5925,9 +5925,9 @@ static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int dg = gamma[dg]; db = gamma[db]; - int nr = qt_div_255((sr - dr) * mr) + dr; - int ng = qt_div_255((sg - dg) * mg) + dg; - int nb = qt_div_255((sb - db) * mb) + db; + int nr = qt_div_255(sr * mr + dr * (255 - mr)); + int ng = qt_div_255(sg * mg + dg * (255 - mg)); + int nb = qt_div_255(sb * mb + db * (255 - mb)); nr = invgamma[nr]; ng = invgamma[ng]; @@ -5952,9 +5952,9 @@ static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, in int alpha = coverage; int ialpha = 255 - alpha; - int nr = (sr * alpha + ialpha * dr) / 255; - int ng = (sg * alpha + ialpha * dg) / 255; - int nb = (sb * alpha + ialpha * db) / 255; + int nr = qt_div_255(sr * alpha + dr * ialpha); + int ng = qt_div_255(sg * alpha + dg * ialpha); + int nb = qt_div_255(sb * alpha + db * ialpha); nr = invgamma[nr]; ng = invgamma[ng]; diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 922ff157e2..664117a730 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -760,6 +760,7 @@ static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16_32(uint x, uint a) { return t; } +// qt_div_255 is a fast rounded division by 255 using an approximation that is accurate for all positive 16-bit integers static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; } diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 1ba6345bf9..0571e1a328 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE \section1 Additional License Information - On Embedded Linux, Windows CE and X11 platforms, parts of this class rely on + On Embedded Linux and X11 platforms, parts of this class rely on code obtained under the following licenses: \legalese diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 4548b6f8b9..cb19a42688 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -60,7 +60,7 @@ using namespace QCss; struct QCssKnownValue { - const char *name; + const char name[28]; quint64 id; }; diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index dbd47151bd..74ea8d15b7 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1046,46 +1046,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) @@ -1565,12 +1564,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) { } @@ -1580,7 +1578,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_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 46f5e6c070..62941b6cac 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -70,7 +70,7 @@ #include FT_CONFIG_OPTIONS_H #endif -#if defined(FT_LCD_FILTER_H) && defined(FT_CONFIG_OPTION_SUBPIXEL_RENDERING) +#if defined(FT_LCD_FILTER_H) #define QT_USE_FREETYPE_LCDFILTER #endif diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 69331cb0bb..42610e9b70 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -359,12 +359,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; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 75899dec80..07aec6f019 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1315,7 +1315,7 @@ QTextCursor QTextDocument::find(const QString &subString, int from, FindFlags op //do not include the character given in the position. if (options & FindBackward) { --pos ; - if (pos < subString.size()) + if (pos < 0) return QTextCursor(); } diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 7fac3331f1..d4c43b3069 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE // see also tst_qtextdocumentfragment.cpp #define MAX_ENTITY 258 -static const struct QTextHtmlEntity { const char *name; quint16 code; } entities[MAX_ENTITY]= { +static const struct QTextHtmlEntity { const char name[9]; quint16 code; } entities[]= { { "AElig", 0x00c6 }, { "AMP", 38 }, { "Aacute", 0x00c1 }, @@ -320,6 +320,7 @@ static const struct QTextHtmlEntity { const char *name; quint16 code; } entities { "zwj", 0x200d }, { "zwnj", 0x200c } }; +Q_STATIC_ASSERT(MAX_ENTITY == sizeof entities / sizeof *entities); #if defined(Q_CC_MSVC) && _MSC_VER < 1600 bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2) diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h index 4ea6e44138..e93d46a59f 100644 --- a/src/gui/text/qtexthtmlparser_p.h +++ b/src/gui/text/qtexthtmlparser_p.h @@ -145,7 +145,7 @@ enum QTextHTMLElements { struct QTextHtmlElement { - const char *name; + const char name[11]; QTextHTMLElements id; enum DisplayMode { DisplayBlock, DisplayInline, DisplayTable, DisplayNone } displayMode; }; |