From f2205c48c21a6b135f2f59d0cf46e72f90f9f0f4 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 11 Nov 2016 15:29:28 +0100 Subject: QFontEngine: Cache whether or not a font can be smoothly scaled This will be used by QtQuick to correct a performance regression introduced by 592614ea3ecd90ede2ae1b8e6579d1b898f474ec -- QFontDatabase::isSmoothlyScalable is quite computationally expensive; and now it is unconditionally expensive regardless of the platform. Change-Id: I82bfa65a963c6c3c276d574f2b379da4a9ba5b69 Reviewed-by: Konstantin Ritt Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontdatabase.cpp | 3 ++- src/gui/text/qfontengine.cpp | 1 + src/gui/text/qfontengine_p.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index f1b2e84a1e..f1478515f4 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -948,8 +948,8 @@ QFontEngine *loadSingleEngine(int script, return 0; } + engine->isSmoothlyScalable = style->smoothScalable; fontCache->insertEngine(key, engine); - return engine; } } @@ -972,6 +972,7 @@ QFontEngine *loadSingleEngine(int script, return 0; } + engine->isSmoothlyScalable = style->smoothScalable; fontCache->insertEngine(key, engine); if (Q_LIKELY(cacheForCommonScript && !engine->symbol)) { diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index fa49b25073..790dd0b64b 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -251,6 +251,7 @@ QFontEngine::QFontEngine(Type type) cache_cost = 0; fsType = 0; symbol = false; + isSmoothlyScalable = false; glyphFormat = Format_None; m_subPixelPositionCount = 0; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 39cf826ee2..893dfb5092 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -283,6 +283,7 @@ public: uint cache_cost; // amount of mem used in bytes by the font uint fsType : 16; bool symbol; + bool isSmoothlyScalable; struct KernPair { uint left_right; QFixed adjust; -- cgit v1.2.3 From 083d8caee10892d2f3d9597609315231b6f8493a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Oct 2016 23:43:26 +0200 Subject: QXbmHandler: fix missing NUL-termination The buffer is fed into strstr() on the next loop iteration, but strstr() expects a NUL-terminated string. In the equivalent code some lines up, the buffer is explicitly terminated, and we never write the last character of the buffer again, so we'll not fall off the end of the buffer, but if we read less bytes than in the last line, we'll parse garbage from the previous line. Change-Id: I354e1ce1dea71188942305190500b4778a69b4ff Reviewed-by: Edward Welbourne --- src/gui/image/qxbmhandler.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 44d07f1624..b21bc75bc4 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -157,6 +157,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) } else { // read another line if ((readBytes = device->readLine(buf,buflen)) <= 0) // EOF ==> truncated image break; + buf[readBytes] = '\0'; p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); } } -- cgit v1.2.3 From 1753d696070895f309c46ba5aee662b0f3a18bde Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Sat, 15 Oct 2016 14:14:00 +0200 Subject: QCss: Fix parsing of charset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When including a CSS file in a HTML file sent to QTextDocument, and the CSS file starts with «@charset "UTF-8";», which is the correct way of declaring that, the parsing fails. If you omit the space, like «@charset"UTF-8";» the parsing succeeds, which is wrong. Fix this by expecting and swallowing whitespace after the @charset tokens. Task-number: QTBUG-54829 Change-Id: I32044e8d24bda70c1eb06bf74af50d4cabe2211d Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qcssparser.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index e96aecdf68..3d6acccdb8 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -2175,6 +2175,7 @@ void Parser::init(const QString &css, bool isFile) bool Parser::parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity) { if (testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("charset"))) { + while (test(S) || test(CDO) || test(CDC)) {} if (!next(STRING)) return false; if (!next(SEMICOLON)) return false; } -- cgit v1.2.3 From e655426e7ac8396713272e123fe0218380e13de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Tue, 15 Nov 2016 13:45:22 +0000 Subject: docs: Reference QLineEdit::hasAcceptableInput() in setValidator() Easy to miss otherwise and hasAcceptableInput() already references setValidator(). Change-Id: Id2d63050db670ab8f7150d7f76492664751cd2da Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qlineedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 2cad5d325c..2069c91664 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -605,7 +605,7 @@ const QValidator * QLineEdit::validator() const The initial setting is to have no input validator (i.e. any input is accepted up to maxLength()). - \sa validator(), QIntValidator, QDoubleValidator, QRegExpValidator + \sa validator(), hasAcceptableInput(), QIntValidator, QDoubleValidator, QRegExpValidator */ void QLineEdit::setValidator(const QValidator *v) -- cgit v1.2.3 From 8d8991c697d001e3e205ad03533dc0e5ca5dde0b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Oct 2016 23:33:02 +0200 Subject: QXbmHandler: don't construct a QByteArray just to find '0x' in text Even QByteArray::fromRawData() allocates memory. Instead of QByteArray::contains() and indexOf(), use good ol' strstr(), like already done elsewhere in the same function. Apart from the memory allocations saved, this fixes a Coverity error complaining that indexOf() can return -1. It's a false positive on the first occurrence, because we didn't call that function unless we know there is a "0x" in the string, but the second _was_ wrong, because we applied it on a new buffer, with unknown content. Coverity-Id: 11262 Change-Id: I18f352c5576e24f89a5c3ef7f2f1b2176f2a235d Reviewed-by: Edward Welbourne --- src/gui/image/qxbmhandler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index b21bc75bc4..ada2485363 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -118,17 +118,18 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) qint64 readBytes = 0; + char *p; + // scan for database - for (;;) { + do { if ((readBytes = device->readLine(buf, buflen)) <= 0) { // end of file return false; } buf[readBytes] = '\0'; - if (QByteArray::fromRawData(buf, readBytes).contains("0x")) - break; - } + p = strstr(buf, "0x"); + } while (!p); if (outImage->size() != QSize(w, h) || outImage->format() != QImage::Format_MonoLSB) { *outImage = QImage(w, h, QImage::Format_MonoLSB); @@ -142,7 +143,6 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) int x = 0, y = 0; uchar *b = outImage->scanLine(0); - char *p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); w = (w+7)/8; // byte width while (y < h) { // for all encoded bytes... @@ -158,7 +158,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) if ((readBytes = device->readLine(buf,buflen)) <= 0) // EOF ==> truncated image break; buf[readBytes] = '\0'; - p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); + p = strstr(buf, "0x"); } } -- cgit v1.2.3 From 48d7db6b3119ee27d9ae6b1bd0fdb24333f44756 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 16 Nov 2016 13:51:08 +0300 Subject: QtCore: Add missing override Change-Id: Ifdec31aabdd0371f36abbb382e49f52f5b58ee94 Reviewed-by: hjk --- src/corelib/codecs/qsimplecodec_p.h | 10 +++++----- src/corelib/io/qfile_p.h | 2 +- src/corelib/io/qtemporaryfile_p.h | 14 +++++++------- src/corelib/mimetypes/qmimetypeparser_p.h | 10 +++++----- src/corelib/statemachine/qhistorystate_p.h | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/corelib/codecs/qsimplecodec_p.h b/src/corelib/codecs/qsimplecodec_p.h index d45cf2377f..a84f9af1e9 100644 --- a/src/corelib/codecs/qsimplecodec_p.h +++ b/src/corelib/codecs/qsimplecodec_p.h @@ -66,12 +66,12 @@ public: explicit QSimpleTextCodec(int); ~QSimpleTextCodec(); - QString convertToUnicode(const char *, int, ConverterState *) const; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; - QByteArray name() const; - QList aliases() const; - int mibEnum() const; + QByteArray name() const override; + QList aliases() const override; + int mibEnum() const override; private: int forwardIndex; diff --git a/src/corelib/io/qfile_p.h b/src/corelib/io/qfile_p.h index fd7db3c120..545890c6b3 100644 --- a/src/corelib/io/qfile_p.h +++ b/src/corelib/io/qfile_p.h @@ -70,7 +70,7 @@ protected: bool openExternalFile(int flags, int fd, QFile::FileHandleFlags handleFlags); bool openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handleFlags); - virtual QAbstractFileEngine *engine() const; + QAbstractFileEngine *engine() const override; QString fileName; }; diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index 58cc318ffd..40974bd6cd 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -69,7 +69,7 @@ protected: QTemporaryFilePrivate(); ~QTemporaryFilePrivate(); - QAbstractFileEngine *engine() const; + QAbstractFileEngine *engine() const override; void resetFileEngine() const; bool autoRemove; @@ -98,14 +98,14 @@ public: ~QTemporaryFileEngine(); bool isReallyOpen() const; - void setFileName(const QString &file); + void setFileName(const QString &file) override; void setFileTemplate(const QString &fileTemplate); - bool open(QIODevice::OpenMode flags); - bool remove(); - bool rename(const QString &newName); - bool renameOverwrite(const QString &newName); - bool close(); + bool open(QIODevice::OpenMode flags) override; + bool remove() override; + bool rename(const QString &newName) override; + bool renameOverwrite(const QString &newName) override; + bool close() override; quint32 fileMode; bool filePathIsTemplate; diff --git a/src/corelib/mimetypes/qmimetypeparser_p.h b/src/corelib/mimetypes/qmimetypeparser_p.h index a502439419..0ce39e701c 100644 --- a/src/corelib/mimetypes/qmimetypeparser_p.h +++ b/src/corelib/mimetypes/qmimetypeparser_p.h @@ -108,19 +108,19 @@ public: explicit QMimeTypeParser(QMimeXMLProvider &provider) : m_provider(provider) {} protected: - inline bool process(const QMimeType &t, QString *) + inline bool process(const QMimeType &t, QString *) override { m_provider.addMimeType(t); return true; } - inline bool process(const QMimeGlobPattern &glob, QString *) + inline bool process(const QMimeGlobPattern &glob, QString *) override { m_provider.addGlobPattern(glob); return true; } - inline void processParent(const QString &child, const QString &parent) + inline void processParent(const QString &child, const QString &parent) override { m_provider.addParent(child, parent); } - inline void processAlias(const QString &alias, const QString &name) + inline void processAlias(const QString &alias, const QString &name) override { m_provider.addAlias(alias, name); } - inline void processMagicMatcher(const QMimeMagicRuleMatcher &matcher) + inline void processMagicMatcher(const QMimeMagicRuleMatcher &matcher) override { m_provider.addMagicMatcher(matcher); } private: diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h index 2e93c31982..f3eb20f194 100644 --- a/src/corelib/statemachine/qhistorystate_p.h +++ b/src/corelib/statemachine/qhistorystate_p.h @@ -87,8 +87,8 @@ protected: // state, it will handle this transition as a special case. The history state itself is never // entered either: either the stored configuration will be used, or the target(s) of this // transition are used. - virtual bool eventTest(QEvent *event) { Q_UNUSED(event); return false; } - virtual void onTransition(QEvent *event) { Q_UNUSED(event); } + bool eventTest(QEvent *event) override { Q_UNUSED(event); return false; } + void onTransition(QEvent *event) override { Q_UNUSED(event); } }; QT_END_NAMESPACE -- cgit v1.2.3 From bd591064be388216f91d48522b3bdbc1be93bb92 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 21 Oct 2016 17:14:31 +0200 Subject: Use QPersistentModelIndex for storing a model index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QModelIndex is not safe to be used to store an index as it is designed to be discarded right after use as the index information can change. Therefore a QPersistentModelIndex should be used instead to store the index. Subsequently the m_index does not need to be updated whenever the model changes anymore as this is already done for us. Task-number: QTBUG-49907 Change-Id: Icc93e410de2821c503ea15a7a1dd9ae32634914e Reviewed-by: Jan Arve Sæther --- src/widgets/accessible/itemviews.cpp | 42 ++++++------------------------------ src/widgets/accessible/itemviews_p.h | 2 +- 2 files changed, 8 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 1b724c9a17..d58db8de32 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -550,20 +550,8 @@ void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) QAccessible::Id id = iter.value(); QAccessibleInterface *iface = QAccessible::accessibleInterface(id); Q_ASSERT(iface); - if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) { - Q_ASSERT(iface->tableCellInterface()); - QAccessibleTableCell *cell = static_cast(iface->tableCellInterface()); - if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted - && cell->m_index.row() >= event->firstRow()) { - int newRow = cell->m_index.row() + newRows; - cell->m_index = cell->m_index.sibling(newRow, cell->m_index.column()); - } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsInserted - && cell->m_index.column() >= event->firstColumn()) { - int newColumn = cell->m_index.column() + newColumns; - cell->m_index = cell->m_index.sibling(cell->m_index.row(), newColumn); - } - } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted - && iface->role() == QAccessible::RowHeader) { + if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted + && iface->role() == QAccessible::RowHeader) { QAccessibleTableHeaderCell *cell = static_cast(iface); if (cell->index >= event->firstRow()) { cell->index += newRows; @@ -602,27 +590,11 @@ void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) { Q_ASSERT(iface->tableCellInterface()); QAccessibleTableCell *cell = static_cast(iface->tableCellInterface()); - if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsRemoved) { - if (cell->m_index.row() < event->firstRow()) { - newCache.insert(indexOfChild(cell), id); - } else if (cell->m_index.row() > event->lastRow()) { - int newRow = cell->m_index.row() - deletedRows; - cell->m_index = cell->m_index.sibling(newRow, cell->m_index.column()); - newCache.insert(indexOfChild(cell), id); - } else { - QAccessible::deleteAccessibleInterface(id); - } - } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsRemoved) { - if (cell->m_index.column() < event->firstColumn()) { - newCache.insert(indexOfChild(cell), id); - } else if (cell->m_index.column() > event->lastColumn()) { - int newColumn = cell->m_index.column() - deletedColumns; - cell->m_index = cell->m_index.sibling(cell->m_index.row(), newColumn); - newCache.insert(indexOfChild(cell), id); - } else { - QAccessible::deleteAccessibleInterface(id); - } - } + // Since it is a QPersistentModelIndex, we only need to check if it is valid + if (cell->m_index.isValid()) + newCache.insert(indexOfChild(cell), id); + else + QAccessible::deleteAccessibleInterface(id); } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsRemoved && iface->role() == QAccessible::RowHeader) { QAccessibleTableHeaderCell *cell = static_cast(iface); diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h index 6a18a1231b..b3cd456585 100644 --- a/src/widgets/accessible/itemviews_p.h +++ b/src/widgets/accessible/itemviews_p.h @@ -207,7 +207,7 @@ private: QHeaderView *verticalHeader() const; QHeaderView *horizontalHeader() const; QPointer view; - QModelIndex m_index; + QPersistentModelIndex m_index; QAccessible::Role m_role; void selectCell(); -- cgit v1.2.3 From 658c8370e4dd74ee82046799b56947bb3c738b92 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 22 Jan 2016 17:03:48 +0100 Subject: QDateTimeParser: localize variable to avoid shadowing The outer scope it was in had a later clause with its own pos variable. Change-Id: I8d083d3d5935416ef82a78890ed145f02d6d6ded Reviewed-by: Timur Pocheptsov --- src/corelib/tools/qdatetimeparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 5b7bf0d3d4..bda786aa24 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -879,12 +879,12 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos State state = Acceptable; QDateTime newCurrentValue; - int pos = 0; bool conflicts = false; const int sectionNodesCount = sectionNodes.size(); QDTPDEBUG << "parse" << input; { + int pos = 0; int year, month, day; currentValue.date().getDate(&year, &month, &day); int year2digits = year % 100; -- cgit v1.2.3 From 4b1c343e5e8f75b567e88541c1b8ea89a3a5b666 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 15 Nov 2016 15:11:00 +0100 Subject: Doc: Add missing reference to qInfo() Change-Id: I7438aa8ff9fddf2e0155ffe0d442f96d4d9265d4 Reviewed-by: Leena Miettinen --- src/corelib/global/qlogging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index eb26b6198d..6b95449b3d 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1748,7 +1748,7 @@ void qErrnoWarning(int code, const char *msg, ...) \snippet code/src_corelib_global_qglobal.cpp 23 - \sa QtMessageHandler, QtMsgType, qDebug(), qWarning(), qCritical(), qFatal(), + \sa QtMessageHandler, QtMsgType, qDebug(), qInfo(), qWarning(), qCritical(), qFatal(), {Debugging Techniques} */ -- cgit v1.2.3 From 0d2f0164f45cb626c40a7c95026ba00fa56ac249 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 15 Nov 2016 15:12:16 +0100 Subject: Also release winmain, qopenglextensions under commercial licenses Add commercial licenses as an alternative to BSD for code that is statically linked into applications by default. BSD requires attribution even for commercial customers, which is not intended. This is a manual backport of parts of change 71404b0be146 in 5.7, and should be dropped when merging to 5.7. [ChangeLog][License Changes] Static libraries that are linked into executables (winmain and qopenglextensions) are now licensed under BSD _and_ commercial licenses. Change-Id: I0d33bc09c06548d63b11a39027e9bb12c1b9a915 Reviewed-by: Lars Knoll --- src/openglextensions/qopenglextensions.cpp | 14 ++++++++++++-- src/openglextensions/qopenglextensions.h | 14 ++++++++++++-- src/winmain/qtmain_win.cpp | 16 +++++++++++++--- src/winmain/qtmain_winrt.cpp | 16 +++++++++++++--- 4 files changed, 50 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/openglextensions/qopenglextensions.cpp b/src/openglextensions/qopenglextensions.cpp index 37c5a5d1f0..f35d5b298a 100644 --- a/src/openglextensions/qopenglextensions.cpp +++ b/src/openglextensions/qopenglextensions.cpp @@ -5,8 +5,18 @@ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/src/openglextensions/qopenglextensions.h b/src/openglextensions/qopenglextensions.h index c9d1ef1267..7ecdee44c0 100644 --- a/src/openglextensions/qopenglextensions.h +++ b/src/openglextensions/qopenglextensions.h @@ -5,8 +5,18 @@ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/src/winmain/qtmain_win.cpp b/src/winmain/qtmain_win.cpp index 2944e07e00..da3d722aa6 100644 --- a/src/winmain/qtmain_win.cpp +++ b/src/winmain/qtmain_win.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Windows main function of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp index 81ca07e447..a11efc1b74 100644 --- a/src/winmain/qtmain_winrt.cpp +++ b/src/winmain/qtmain_winrt.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Windows main function of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are -- cgit v1.2.3 From f1b4bd4790860e1ff5afcec111a359bc3a91cfda Mon Sep 17 00:00:00 2001 From: Peter Seiderer Date: Tue, 15 Nov 2016 20:09:47 +0100 Subject: eglfs: fix eglfs_mali compile for odroid-mali Avoid duplicated struct fbdev_window definition (introduced by commit 58bed4cda98e8e25db8adc61c7db73b6853077dc) by renaming the local shadow definition to struct shadow_fbdev_window. Task-number: QTBUG-57156 Change-Id: I72b03f09fc57ddcd0284d6d3554a5658e02b80fc Reviewed-by: Laszlo Agocs Reviewed-by: Julien Corjon --- .../eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp index 43decdf849..aeba83f9bf 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp @@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE -struct fbdev_window { +struct shadow_fbdev_window { unsigned short width; unsigned short height; }; @@ -85,7 +85,7 @@ EGLNativeWindowType QEglFSMaliIntegration::createNativeWindow(QPlatformWindow *w Q_UNUSED(window); Q_UNUSED(format); - fbdev_window *fbwin = reinterpret_cast(malloc(sizeof(fbdev_window))); + shadow_fbdev_window *fbwin = reinterpret_cast(malloc(sizeof(shadow_fbdev_window))); if (NULL == fbwin) return 0; -- cgit v1.2.3 From 3691f7ca0c7117f18ea38ca3950ee9a8a91a53c8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 20 Sep 2013 02:38:22 +0200 Subject: QFutureInterface: make accesses to 'state' thread-safe Introduce helper functions switch_{on,off,from_to} to make the code more readable, and prepare everything for later optimizations reducing the sizes of critical sections (by locking the mutex later, or even never). This commit, however, is only concerned with shutting up tsan. In waitForResult(), simplified the code by removing an unneeded if guard: the condition is checked in the while loop immediately following in the then-block, and the local variable declaration that precedes the loop is not worth guarding. Change-Id: I24bfd864ca96f862302536ad8662065e6f366fa8 Reviewed-by: David Faure --- src/corelib/thread/qfutureinterface.cpp | 109 ++++++++++++++++++-------------- src/corelib/thread/qfutureinterface_p.h | 2 +- 2 files changed, 64 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 2fe038165b..a29f8ebba7 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -77,13 +77,33 @@ QFutureInterfaceBase::~QFutureInterfaceBase() delete d; } +static inline int switch_on(QAtomicInt &a, int which) +{ + return a.fetchAndOrRelaxed(which) | which; +} + +static inline int switch_off(QAtomicInt &a, int which) +{ + return a.fetchAndAndRelaxed(~which) & ~which; +} + +static inline int switch_from_to(QAtomicInt &a, int from, int to) +{ + int newValue; + int expected = a.load(); + do { + newValue = (expected & ~from) | to; + } while (!a.testAndSetRelaxed(expected, newValue, expected)); + return newValue; +} + void QFutureInterfaceBase::cancel() { QMutexLocker locker(&d->m_mutex); - if (d->state & Canceled) + if (d->state.load() & Canceled) return; - d->state = State((d->state & ~Paused) | Canceled); + switch_from_to(d->state, Paused, Canceled); d->waitCondition.wakeAll(); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); @@ -93,10 +113,10 @@ void QFutureInterfaceBase::setPaused(bool paused) { QMutexLocker locker(&d->m_mutex); if (paused) { - d->state = State(d->state | Paused); + switch_on(d->state, Paused); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); } else { - d->state = State(d->state & ~Paused); + switch_off(d->state, Paused); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Resumed)); } @@ -105,29 +125,24 @@ void QFutureInterfaceBase::setPaused(bool paused) void QFutureInterfaceBase::togglePaused() { QMutexLocker locker(&d->m_mutex); - if (d->state & Paused) { - d->state = State(d->state & ~Paused); + if (d->state.load() & Paused) { + switch_off(d->state, Paused); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Resumed)); } else { - d->state = State(d->state | Paused); + switch_on(d->state, Paused); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); } } void QFutureInterfaceBase::setThrottled(bool enable) { - // bail out if we are not changing the state - if ((enable && (d->state & Throttled)) || (!enable && !(d->state & Throttled))) - return; - - // lock and change the state QMutexLocker lock(&d->m_mutex); if (enable) { - d->state = State(d->state | Throttled); + switch_on(d->state, Throttled); } else { - d->state = State(d->state & ~Throttled); - if (!(d->state & Paused)) + switch_off(d->state, Throttled); + if (!(d->state.load() & Paused)) d->pausedWaitCondition.wakeAll(); } } @@ -178,11 +193,15 @@ bool QFutureInterfaceBase::waitForNextResult() void QFutureInterfaceBase::waitForResume() { // return early if possible to avoid taking the mutex lock. - if ((d->state & Paused) == false || (d->state & Canceled)) - return; + { + const int state = d->state.load(); + if (!(state & Paused) || (state & Canceled)) + return; + } QMutexLocker lock(&d->m_mutex); - if ((d->state & Paused) == false || (d->state & Canceled)) + const int state = d->state.load(); + if (!(state & Paused) || (state & Canceled)) return; // decrease active thread count since this thread will wait. @@ -230,7 +249,7 @@ bool QFutureInterfaceBase::isProgressUpdateNeeded() const void QFutureInterfaceBase::reportStarted() { QMutexLocker locker(&d->m_mutex); - if ((d->state & Started) || (d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Started|Canceled|Finished)) return; d->setState(State(Started | Running)); @@ -246,11 +265,11 @@ void QFutureInterfaceBase::reportCanceled() void QFutureInterfaceBase::reportException(const QException &exception) { QMutexLocker locker(&d->m_mutex); - if ((d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Canceled|Finished)) return; d->m_exceptionStore.setException(exception); - d->state = State(d->state | Canceled); + switch_on(d->state, Canceled); d->waitCondition.wakeAll(); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); @@ -260,8 +279,8 @@ void QFutureInterfaceBase::reportException(const QException &exception) void QFutureInterfaceBase::reportFinished() { QMutexLocker locker(&d->m_mutex); - if (!(d->state & Finished)) { - d->state = State((d->state & ~Running) | Finished); + if (!isFinished()) { + switch_from_to(d->state, Running, Finished); d->waitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); } @@ -281,7 +300,7 @@ int QFutureInterfaceBase::expectedResultCount() bool QFutureInterfaceBase::queryState(State state) const { - return (d->state & state); + return d->state.load() & state; } void QFutureInterfaceBase::waitForResult(int resultIndex) @@ -289,7 +308,7 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) d->m_exceptionStore.throwPossibleException(); QMutexLocker lock(&d->m_mutex); - if (!(d->state & Running)) + if (!isRunning()) return; lock.unlock(); @@ -299,11 +318,9 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) lock.relock(); - if (d->state & Running) { - const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; - while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false) - d->waitCondition.wait(&d->m_mutex); - } + const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; + while (isRunning() && !d->internal_isResultReadyAt(waitIndex)) + d->waitCondition.wait(&d->m_mutex); d->m_exceptionStore.throwPossibleException(); } @@ -311,7 +328,7 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) void QFutureInterfaceBase::waitForFinished() { QMutexLocker lock(&d->m_mutex); - const bool alreadyFinished = !(d->state & Running); + const bool alreadyFinished = !isRunning(); lock.unlock(); if (!alreadyFinished) { @@ -319,7 +336,7 @@ void QFutureInterfaceBase::waitForFinished() lock.relock(); - while (d->state & Running) + while (isRunning()) d->waitCondition.wait(&d->m_mutex); } @@ -328,7 +345,7 @@ void QFutureInterfaceBase::waitForFinished() void QFutureInterfaceBase::reportResultsReady(int beginIndex, int endIndex) { - if ((d->state & Canceled) || (d->state & Finished) || beginIndex == endIndex) + if (beginIndex == endIndex || (d->state.load() & (Canceled|Finished))) return; d->waitCondition.wakeAll(); @@ -390,7 +407,7 @@ void QFutureInterfaceBase::setProgressValueAndText(int progressValue, if (d->m_progressValue >= progressValue) return; - if ((d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Canceled|Finished)) return; if (d->internal_updateProgress(progressValue, progressText)) { @@ -462,10 +479,10 @@ bool QFutureInterfaceBasePrivate::internal_waitForNextResult() if (m_results.hasNextResult()) return true; - while ((state & QFutureInterfaceBase::Running) && m_results.hasNextResult() == false) + while ((state.load() & QFutureInterfaceBase::Running) && m_results.hasNextResult() == false) waitCondition.wait(&m_mutex); - return (!(state & QFutureInterfaceBase::Canceled) && m_results.hasNextResult()); + return !(state.load() & QFutureInterfaceBase::Canceled) && m_results.hasNextResult(); } bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress, @@ -488,16 +505,16 @@ bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress, void QFutureInterfaceBasePrivate::internal_setThrottled(bool enable) { // bail out if we are not changing the state - if ((enable && (state & QFutureInterfaceBase::Throttled)) - || (!enable && !(state & QFutureInterfaceBase::Throttled))) + if ((enable && (state.load() & QFutureInterfaceBase::Throttled)) + || (!enable && !(state.load() & QFutureInterfaceBase::Throttled))) return; // change the state if (enable) { - state = QFutureInterfaceBase::State(state | QFutureInterfaceBase::Throttled); + switch_on(state, QFutureInterfaceBase::Throttled); } else { - state = QFutureInterfaceBase::State(state & ~QFutureInterfaceBase::Throttled); - if (!(state & QFutureInterfaceBase::Paused)) + switch_off(state, QFutureInterfaceBase::Throttled); + if (!(state.load() & QFutureInterfaceBase::Paused)) pausedWaitCondition.wakeAll(); } } @@ -532,7 +549,7 @@ void QFutureInterfaceBasePrivate::connectOutputInterface(QFutureCallOutInterface { QMutexLocker locker(&m_mutex); - if (state & QFutureInterfaceBase::Started) { + if (state.load() & QFutureInterfaceBase::Started) { interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Started)); interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ProgressRange, m_progressMinimum, @@ -552,13 +569,13 @@ void QFutureInterfaceBasePrivate::connectOutputInterface(QFutureCallOutInterface it.batchedAdvance(); } - if (state & QFutureInterfaceBase::Paused) + if (state.load() & QFutureInterfaceBase::Paused) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); - if (state & QFutureInterfaceBase::Canceled) + if (state.load() & QFutureInterfaceBase::Canceled) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); - if (state & QFutureInterfaceBase::Finished) + if (state.load() & QFutureInterfaceBase::Finished) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); outputConnections.append(interface); @@ -577,7 +594,7 @@ void QFutureInterfaceBasePrivate::disconnectOutputInterface(QFutureCallOutInterf void QFutureInterfaceBasePrivate::setState(QFutureInterfaceBase::State newState) { - state = newState; + state.store(newState); } QT_END_NAMESPACE diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h index e2d588cd07..eb0c38421b 100644 --- a/src/corelib/thread/qfutureinterface_p.h +++ b/src/corelib/thread/qfutureinterface_p.h @@ -155,7 +155,7 @@ public: int m_progressValue; // TQ int m_progressMinimum; // TQ int m_progressMaximum; // TQ - QFutureInterfaceBase::State state; + QAtomicInt state; // reads and writes can happen unprotected, both must be atomic QElapsedTimer progressTime; QWaitCondition pausedWaitCondition; QtPrivate::ResultStoreBase m_results; -- cgit v1.2.3 From d20773824529d191e7b483b505107dce6c1b1c3d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 18 Nov 2016 16:54:09 +0100 Subject: Fix missing last modification time stamp in qrc content The time stamp is added at the end of the node information and consequently this also bumps the version. Task-number: QTBUG-57182 Change-Id: Ia10e006f28c0b168b2bcd74ed8b7098f84d10af3 Reviewed-by: hjk --- src/corelib/io/qresource.cpp | 65 +++++++++++++++++++++++++++++++++++--------- src/corelib/io/qresource.h | 1 + src/tools/rcc/rcc.cpp | 46 ++++++++++++++++++++++++++++--- src/tools/rcc/rcc.h | 1 + 4 files changed, 96 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 7fe3753da4..72042e1600 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -101,35 +101,38 @@ class QResourceRoot Directory = 0x02 }; const uchar *tree, *names, *payloads; - inline int findOffset(int node) const { return node * 14; } //sizeof each tree element + int version; + inline int findOffset(int node) const { return node * (14 + (version >= 0x02 ? 8 : 0)); } //sizeof each tree element uint hash(int node) const; QString name(int node) const; short flags(int node) const; public: mutable QAtomicInt ref; - inline QResourceRoot(): tree(0), names(0), payloads(0) {} - inline QResourceRoot(const uchar *t, const uchar *n, const uchar *d) { setSource(t, n, d); } + inline QResourceRoot(): tree(0), names(0), payloads(0), version(0) {} + inline QResourceRoot(int version, const uchar *t, const uchar *n, const uchar *d) { setSource(version, t, n, d); } virtual ~QResourceRoot() { } int findNode(const QString &path, const QLocale &locale=QLocale()) const; inline bool isContainer(int node) const { return flags(node) & Directory; } inline bool isCompressed(int node) const { return flags(node) & Compressed; } const uchar *data(int node, qint64 *size) const; + QDateTime lastModified(int node) const; QStringList children(int node) const; virtual QString mappingRoot() const { return QString(); } bool mappingRootSubdir(const QString &path, QString *match=0) const; inline bool operator==(const QResourceRoot &other) const - { return tree == other.tree && names == other.names && payloads == other.payloads; } + { return tree == other.tree && names == other.names && payloads == other.payloads && version == other.version; } inline bool operator!=(const QResourceRoot &other) const { return !operator==(other); } enum ResourceRootType { Resource_Builtin, Resource_File, Resource_Buffer }; virtual ResourceRootType type() const { return Resource_Builtin; } protected: - inline void setSource(const uchar *t, const uchar *n, const uchar *d) { + inline void setSource(int v, const uchar *t, const uchar *n, const uchar *d) { tree = t; names = n; payloads = d; + version = v; } }; @@ -231,6 +234,7 @@ public: mutable qint64 size; mutable const uchar *data; mutable QStringList children; + mutable QDateTime lastModified; QResource *q_ptr; Q_DECLARE_PUBLIC(QResource) @@ -244,6 +248,7 @@ QResourcePrivate::clear() data = 0; size = 0; children.clear(); + lastModified = QDateTime(); container = 0; for(int i = 0; i < related.size(); ++i) { QResourceRoot *root = related.at(i); @@ -274,6 +279,7 @@ QResourcePrivate::load(const QString &file) size = 0; compressed = 0; } + lastModified = res->lastModified(node); } else if(res->isContainer(node) != container) { qWarning("QResourceInfo: Resource [%s] has both data and children!", file.toLatin1().constData()); } @@ -284,6 +290,7 @@ QResourcePrivate::load(const QString &file) data = 0; size = 0; compressed = 0; + lastModified = QDateTime(); res->ref.ref(); related.append(res); } @@ -513,6 +520,17 @@ const uchar *QResource::data() const return d->data; } +/*! + Returns the date and time when the file was last modified before + packaging into a resource. +*/ +QDateTime QResource::lastModified() const +{ + Q_D(const QResource); + d->ensureInitialized(); + return d->lastModified; +} + /*! Returns \c true if the resource represents a directory and thus may have children() in it, false if it represents a file. @@ -780,6 +798,24 @@ const uchar *QResourceRoot::data(int node, qint64 *size) const *size = 0; return 0; } + +QDateTime QResourceRoot::lastModified(int node) const +{ + if (node == -1 || version < 0x02) + return QDateTime(); + + const int offset = findOffset(node) + 14; + + const quint64 timeStamp = (quint64(tree[offset+0]) << 56) + (quint64(tree[offset+1]) << 48) + + (quint64(tree[offset+2]) << 40) + (quint64(tree[offset+3]) << 32) + + (quint64(tree[offset+4]) << 24) + (quint64(tree[offset+5]) << 16) + + (quint64(tree[offset+6]) << 8) + (quint64(tree[offset+7])); + if (timeStamp == 0) + return QDateTime(); + + return QDateTime::fromMSecsSinceEpoch(timeStamp); +} + QStringList QResourceRoot::children(int node) const { if(node == -1) @@ -829,9 +865,9 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree, const unsigned char *name, const unsigned char *data) { QMutexLocker lock(resourceMutex()); - if(version == 0x01 && resourceList()) { + if ((version == 0x01 || version == 0x2) && resourceList()) { bool found = false; - QResourceRoot res(tree, name, data); + QResourceRoot res(version, tree, name, data); for(int i = 0; i < resourceList()->size(); ++i) { if(*resourceList()->at(i) == res) { found = true; @@ -839,7 +875,7 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree, } } if(!found) { - QResourceRoot *root = new QResourceRoot(tree, name, data); + QResourceRoot *root = new QResourceRoot(version, tree, name, data); root->ref.ref(); resourceList()->append(root); } @@ -852,8 +888,8 @@ Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tre const unsigned char *name, const unsigned char *data) { QMutexLocker lock(resourceMutex()); - if(version == 0x01 && resourceList()) { - QResourceRoot res(tree, name, data); + if ((version == 0x01 || version == 0x02) && resourceList()) { + QResourceRoot res(version, tree, name, data); for(int i = 0; i < resourceList()->size(); ) { if(*resourceList()->at(i) == res) { QResourceRoot *root = resourceList()->takeAt(i); @@ -919,9 +955,9 @@ public: if (size >= 0 && (tree_offset >= size || data_offset >= size || name_offset >= size)) return false; - if(version == 0x01) { + if (version == 0x01 || version == 0x02) { buffer = b; - setSource(b+tree_offset, b+name_offset, b+data_offset); + setSource(version, b+tree_offset, b+name_offset, b+data_offset); return true; } return false; @@ -1430,8 +1466,11 @@ QString QResourceFileEngine::owner(FileOwner) const return QString(); } -QDateTime QResourceFileEngine::fileTime(FileTime) const +QDateTime QResourceFileEngine::fileTime(FileTime time) const { + Q_D(const QResourceFileEngine); + if (time == ModificationTime) + return d->resource.lastModified(); return QDateTime(); } diff --git a/src/corelib/io/qresource.h b/src/corelib/io/qresource.h index a50bbbdaca..895cf0456e 100644 --- a/src/corelib/io/qresource.h +++ b/src/corelib/io/qresource.h @@ -69,6 +69,7 @@ public: bool isCompressed() const; qint64 size() const; const uchar *data() const; + QDateTime lastModified() const; static void addSearchPath(const QString &path); static QStringList searchPaths(); diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 18772d2816..c8ac554cd4 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -203,6 +203,12 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) } if (text || pass1) lib.writeChar('\n'); + + // last modified time stamp + const QDateTime lastModified = m_fileInfo.lastModified(); + lib.writeNumber8(quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0)); + if (text || pass1) + lib.writeChar('\n'); } qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset, @@ -833,6 +839,38 @@ void RCCResourceLibrary::writeNumber4(quint32 number) } } +void RCCResourceLibrary::writeNumber8(quint64 number) +{ + if (m_format == RCCResourceLibrary::Pass2) { + m_outDevice->putChar(char(number >> 56)); + m_outDevice->putChar(char(number >> 48)); + m_outDevice->putChar(char(number >> 40)); + m_outDevice->putChar(char(number >> 32)); + m_outDevice->putChar(char(number >> 24)); + m_outDevice->putChar(char(number >> 16)); + m_outDevice->putChar(char(number >> 8)); + m_outDevice->putChar(char(number)); + } else if (m_format == RCCResourceLibrary::Binary) { + writeChar(number >> 56); + writeChar(number >> 48); + writeChar(number >> 40); + writeChar(number >> 32); + writeChar(number >> 24); + writeChar(number >> 16); + writeChar(number >> 8); + writeChar(number); + } else { + writeHex(number >> 56); + writeHex(number >> 48); + writeHex(number >> 40); + writeHex(number >> 32); + writeHex(number >> 24); + writeHex(number >> 16); + writeHex(number >> 8); + writeHex(number); + } +} + bool RCCResourceLibrary::writeHeader() { if (m_format == C_Code || m_format == Pass1) { @@ -1076,7 +1114,7 @@ bool RCCResourceLibrary::writeInitializer() if (m_root) { writeString(" "); writeAddNamespaceFunction("qRegisterResourceData"); - writeString("\n (0x01, qt_resource_struct, " + writeString("\n (0x02, qt_resource_struct, " "qt_resource_name, qt_resource_data);\n"); } writeString(" return 1;\n"); @@ -1097,7 +1135,7 @@ bool RCCResourceLibrary::writeInitializer() if (m_root) { writeString(" "); writeAddNamespaceFunction("qUnregisterResourceData"); - writeString("\n (0x01, qt_resource_struct, " + writeString("\n (0x02, qt_resource_struct, " "qt_resource_name, qt_resource_data);\n"); } writeString(" return 1;\n"); @@ -1114,10 +1152,10 @@ bool RCCResourceLibrary::writeInitializer() } else if (m_format == Binary) { int i = 4; char *p = m_out.data(); - p[i++] = 0; // 0x01 + p[i++] = 0; // 0x02 p[i++] = 0; p[i++] = 0; - p[i++] = 1; + p[i++] = 2; p[i++] = (m_treeOffset >> 24) & 0xff; p[i++] = (m_treeOffset >> 16) & 0xff; diff --git a/src/tools/rcc/rcc.h b/src/tools/rcc/rcc.h index 8d0d83e00c..157cd4809f 100644 --- a/src/tools/rcc/rcc.h +++ b/src/tools/rcc/rcc.h @@ -118,6 +118,7 @@ private: void writeHex(quint8 number); void writeNumber2(quint16 number); void writeNumber4(quint32 number); + void writeNumber8(quint64 number); void writeChar(char c) { m_out.append(c); } void writeByteArray(const QByteArray &); void write(const char *, int len); -- cgit v1.2.3 From e798d0b18acfb6756a614aec3e7b4bcb1ef5ff58 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 21 Nov 2016 12:55:54 +0100 Subject: qnativesocketengine_winrt - do not shadow a variable We first hide identifier 'hr' and then later we check the one that was never correctly initialized. Task-number: QTBUG-57226 Change-Id: Ibbf1bb99aa752c2e4090caf4533dc5f5b71b5e41 Reviewed-by: Oliver Wolff --- src/network/socket/qnativesocketengine_winrt.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 32fafc2cb0..934c8fe785 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -252,19 +252,18 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: // Start processing incoming data if (d->socketType == QAbstractSocket::TcpSocket) { - HRESULT hr; - QEventDispatcherWinRT::runOnXamlThread([d, &hr, socket, this]() { + HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d, socket, this]() { ComPtr buffer; HRESULT hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &buffer); - RETURN_OK_IF_FAILED("initialize(): Could not create buffer"); + RETURN_HR_IF_FAILED("initialize(): Could not create buffer"); ComPtr stream; hr = socket->get_InputStream(&stream); - RETURN_OK_IF_FAILED("initialize(): Could not obtain input stream"); + RETURN_HR_IF_FAILED("initialize(): Could not obtain input stream"); hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, d->readOp.GetAddressOf()); - RETURN_OK_IF_FAILED_WITH_ARGS("initialize(): Failed to read from the socket buffer (%s).", + RETURN_HR_IF_FAILED_WITH_ARGS("initialize(): Failed to read from the socket buffer (%s).", socketDescription(this).constData()); hr = d->readOp->put_Completed(Callback(d, &QNativeSocketEnginePrivate::handleReadyRead).Get()); - RETURN_OK_IF_FAILED_WITH_ARGS("initialize(): Failed to set socket read callback (%s).", + RETURN_HR_IF_FAILED_WITH_ARGS("initialize(): Failed to set socket read callback (%s).", socketDescription(this).constData()); return S_OK; }); -- cgit v1.2.3 From 38675e18fcc841228141568a2ecfafdeb99eba2a Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 17 Nov 2016 10:40:44 +0100 Subject: Add support for Visual Studio 2017 Tested with RC Task-number: QTBUG-57086 Change-Id: I21f56edca3852b52edd2c5fdcce76817141e8d4a Reviewed-by: Friedemann Kleint --- src/corelib/global/qlibraryinfo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 8bcacca13f..14be4c3475 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -310,8 +310,10 @@ QLibraryInfo::buildDate() # define COMPILER_STRING "MSVC 2012" # elif _MSC_VER < 1900 # define COMPILER_STRING "MSVC 2013" -# elif _MSC_VER < 2000 +# elif _MSC_VER < 1910 # define COMPILER_STRING "MSVC 2015" +# elif _MSC_VER < 2000 +# define COMPILER_STRING "MSVC 2017" # else # define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER) # endif -- cgit v1.2.3 From 9f17c245893e296d5c92ed1ef1e5d08896b469b1 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 17 Nov 2016 10:40:44 +0100 Subject: Enable constexpr support for Visual Studio 2017 Change-Id: I894789c41cc2c1a327c14d0526e658520d096085 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 3 +++ src/corelib/thread/qbasicatomic.h | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e324c043af..25e6e4c6bf 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -931,6 +931,9 @@ # define Q_COMPILER_THREADSAFE_STATICS # define Q_COMPILER_UNIFORM_INIT # endif +# if _MSC_VER >= 1910 +# define Q_COMPILER_CONSTEXPR +# endif # endif /* __cplusplus */ #endif /* Q_CC_MSVC */ diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 7960174277..c1e01a3212 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -78,6 +78,9 @@ # error "Qt has not been ported to this platform" #endif +QT_WARNING_PUSH +QT_WARNING_DISABLE_MSVC(4522) + QT_BEGIN_NAMESPACE #if 0 @@ -340,4 +343,6 @@ public: QT_END_NAMESPACE +QT_WARNING_POP + #endif // QBASICATOMIC_H -- cgit v1.2.3 From 3cd457bdad6eee4a703ef9773b80165a272fbdc7 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 21 Nov 2016 11:38:43 +0100 Subject: Handle RemovePath correctly when calling matches() Change-Id: Ied324a537df127e676fad26b42e658a9d5aeec9b Reviewed-by: David Faure --- src/corelib/io/qurl.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 7512bcd83f..de78d09dd9 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3703,6 +3703,9 @@ bool QUrl::matches(const QUrl &url, FormattingOptions options) const if ((d->sectionIsPresent & mask) != (url.d->sectionIsPresent & mask)) return false; + if (options & QUrl::RemovePath) + return true; + // Compare paths, after applying path-related options QString path1; d->appendPath(path1, options, QUrlPrivate::Path); -- cgit v1.2.3 From 7920cfe46ad11ce1cd5592a71cfa16422e9207e1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 21 Nov 2016 10:57:25 +0100 Subject: Fix SCTP API according to Qt conventions inDatagramMode() -> isInDatagramMode() maxChannelCount -> maximumChannelCount Change-Id: Ib64bf52cc3b40354927ee11e3f41d47e84c6d9c4 Reviewed-by: Lars Knoll --- src/network/socket/qsctpserver.cpp | 28 ++++++++++++------------ src/network/socket/qsctpserver.h | 4 ++-- src/network/socket/qsctpserver_p.h | 2 +- src/network/socket/qsctpsocket.cpp | 44 +++++++++++++++++++------------------- src/network/socket/qsctpsocket.h | 6 +++--- src/network/socket/qsctpsocket_p.h | 2 +- 6 files changed, 43 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/network/socket/qsctpserver.cpp b/src/network/socket/qsctpserver.cpp index 24f18e1ee8..77cb997192 100644 --- a/src/network/socket/qsctpserver.cpp +++ b/src/network/socket/qsctpserver.cpp @@ -60,7 +60,7 @@ The most common way to use QSctpServer is to construct an object and set the maximum number of channels that the server is - prepared to support, by calling setMaxChannelCount(). You can set + prepared to support, by calling setMaximumChannelCount(). You can set the TCP emulation mode by passing a negative argument in this call. Also, a special value of 0 (the default) indicates to use the peer's value as the actual number of channels. The new incoming @@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE /*! \internal */ QSctpServerPrivate::QSctpServerPrivate() - : maxChannelCount(0) + : maximumChannelCount(0) { } @@ -119,7 +119,7 @@ void QSctpServerPrivate::configureCreatedSocket() QTcpServerPrivate::configureCreatedSocket(); if (socketEngine) socketEngine->setOption(QAbstractSocketEngine::MaxStreamsSocketOption, - maxChannelCount == -1 ? 1 : maxChannelCount); + maximumChannelCount == -1 ? 1 : maximumChannelCount); } /*! @@ -128,7 +128,7 @@ void QSctpServerPrivate::configureCreatedSocket() Sets the datagram operation mode. The \a parent argument is passed to QObject's constructor. - \sa setMaxChannelCount(), listen(), setSocketDescriptor() + \sa setMaximumChannelCount(), listen(), setSocketDescriptor() */ QSctpServer::QSctpServer(QObject *parent) : QTcpServer(QAbstractSocket::SctpSocket, *new QSctpServerPrivate, parent) @@ -159,19 +159,19 @@ QSctpServer::~QSctpServer() Call this method only when QSctpServer is in UnconnectedState. - \sa maxChannelCount(), QSctpSocket + \sa maximumChannelCount(), QSctpSocket */ -void QSctpServer::setMaxChannelCount(int count) +void QSctpServer::setMaximumChannelCount(int count) { Q_D(QSctpServer); if (d->state != QAbstractSocket::UnconnectedState) { - qWarning("QSctpServer::setMaxChannelCount() is only allowed in UnconnectedState"); + qWarning("QSctpServer::setMaximumChannelCount() is only allowed in UnconnectedState"); return; } #if defined(QSCTPSERVER_DEBUG) - qDebug("QSctpServer::setMaxChannelCount(%i)", count); + qDebug("QSctpServer::setMaximumChannelCount(%i)", count); #endif - d->maxChannelCount = count; + d->maximumChannelCount = count; } /*! @@ -183,11 +183,11 @@ void QSctpServer::setMaxChannelCount(int count) Returns -1, if QSctpServer running in TCP emulation mode. - \sa setMaxChannelCount() + \sa setMaximumChannelCount() */ -int QSctpServer::maxChannelCount() const +int QSctpServer::maximumChannelCount() const { - return d_func()->maxChannelCount; + return d_func()->maximumChannelCount; } /*! \reimp @@ -199,7 +199,7 @@ void QSctpServer::incomingConnection(qintptr socketDescriptor) #endif QSctpSocket *socket = new QSctpSocket(this); - socket->setMaxChannelCount(d_func()->maxChannelCount); + socket->setMaximumChannelCount(d_func()->maximumChannelCount); socket->setSocketDescriptor(socketDescriptor); addPendingConnection(socket); } @@ -234,7 +234,7 @@ QSctpSocket *QSctpServer::nextPendingDatagramConnection() QSctpSocket *socket = qobject_cast(i.next()); Q_ASSERT(socket); - if (socket->inDatagramMode()) { + if (socket->isInDatagramMode()) { i.remove(); Q_ASSERT(d->socketEngine); d->socketEngine->setReadNotificationEnabled(true); diff --git a/src/network/socket/qsctpserver.h b/src/network/socket/qsctpserver.h index fb017a924d..f39257485d 100644 --- a/src/network/socket/qsctpserver.h +++ b/src/network/socket/qsctpserver.h @@ -57,8 +57,8 @@ public: explicit QSctpServer(QObject *parent = nullptr); virtual ~QSctpServer(); - void setMaxChannelCount(int count); - int maxChannelCount() const; + void setMaximumChannelCount(int count); + int maximumChannelCount() const; QSctpSocket *nextPendingDatagramConnection(); diff --git a/src/network/socket/qsctpserver_p.h b/src/network/socket/qsctpserver_p.h index 32760caffe..274939fc3d 100644 --- a/src/network/socket/qsctpserver_p.h +++ b/src/network/socket/qsctpserver_p.h @@ -64,7 +64,7 @@ public: QSctpServerPrivate(); virtual ~QSctpServerPrivate(); - int maxChannelCount; + int maximumChannelCount; void configureCreatedSocket() Q_DECL_OVERRIDE; }; diff --git a/src/network/socket/qsctpsocket.cpp b/src/network/socket/qsctpsocket.cpp index cb07e80299..fe76f64c42 100644 --- a/src/network/socket/qsctpsocket.cpp +++ b/src/network/socket/qsctpsocket.cpp @@ -83,14 +83,14 @@ \endlist To set a continuous byte stream mode, instantiate QSctpSocket and - call setMaxChannelCount() with a negative value. This gives the + call setMaximumChannelCount() with a negative value. This gives the ability to use QSctpSocket as a regular buffered QTcpSocket. You can call connectToHost() to initiate connection with endpoint, write() to transmit and read() to receive data from the peer, but you cannot distinguish message boundaries. By default, QSctpSocket operates in datagram mode. Before - connecting, call setMaxChannelCount() to set the maximum number of + connecting, call setMaximumChannelCount() to set the maximum number of channels that the application is prepared to support. This number is a parameter negotiated with the remote endpoint and its value can be bounded by the operating system. The default value of 0 @@ -130,7 +130,7 @@ QT_BEGIN_NAMESPACE /*! \internal */ QSctpSocketPrivate::QSctpSocketPrivate() - : maxChannelCount(0) + : maximumChannelCount(0) { } @@ -150,7 +150,7 @@ bool QSctpSocketPrivate::canReadNotification() #endif // Handle TCP emulation mode in the base implementation. - if (!q->inDatagramMode()) + if (!q->isInDatagramMode()) return QTcpSocketPrivate::canReadNotification(); const int savedCurrentChannel = currentReadChannel; @@ -248,7 +248,7 @@ bool QSctpSocketPrivate::writeToSocket() #endif // Handle TCP emulation mode in the base implementation. - if (!q->inDatagramMode()) + if (!q->isInDatagramMode()) return QTcpSocketPrivate::writeToSocket(); if (!socketEngine) @@ -331,7 +331,7 @@ void QSctpSocketPrivate::configureCreatedSocket() { if (socketEngine) socketEngine->setOption(QAbstractSocketEngine::MaxStreamsSocketOption, - maxChannelCount < 0 ? 1 : maxChannelCount); + maximumChannelCount < 0 ? 1 : maximumChannelCount); } /*! @@ -340,7 +340,7 @@ void QSctpSocketPrivate::configureCreatedSocket() Sets the datagram operation mode. The \a parent argument is passed to QObject's constructor. - \sa socketType(), setMaxChannelCount() + \sa socketType(), setMaximumChannelCount() */ QSctpSocket::QSctpSocket(QObject *parent) : QTcpSocket(SctpSocket, *new QSctpSocketPrivate, parent) @@ -418,19 +418,19 @@ void QSctpSocket::disconnectFromHost() Call this method only when QSctpSocket is in UnconnectedState. - \sa maxChannelCount(), readChannelCount(), writeChannelCount() + \sa maximumChannelCount(), readChannelCount(), writeChannelCount() */ -void QSctpSocket::setMaxChannelCount(int count) +void QSctpSocket::setMaximumChannelCount(int count) { Q_D(QSctpSocket); if (d->state != QAbstractSocket::UnconnectedState) { - qWarning("QSctpSocket::setMaxChannelCount() is only allowed in UnconnectedState"); + qWarning("QSctpSocket::setMaximumChannelCount() is only allowed in UnconnectedState"); return; } #if defined(QSCTPSOCKET_DEBUG) - qDebug("QSctpSocket::setMaxChannelCount(%i)", count); + qDebug("QSctpSocket::setMaximumChannelCount(%i)", count); #endif - d->maxChannelCount = qMax(count, -1); + d->maximumChannelCount = qMax(count, -1); } /*! @@ -443,22 +443,22 @@ void QSctpSocket::setMaxChannelCount(int count) Returns -1 if QSctpSocket is running in continuous byte stream mode. - \sa setMaxChannelCount(), readChannelCount(), writeChannelCount() + \sa setMaximumChannelCount(), readChannelCount(), writeChannelCount() */ -int QSctpSocket::maxChannelCount() const +int QSctpSocket::maximumChannelCount() const { - return d_func()->maxChannelCount; + return d_func()->maximumChannelCount; } /*! Returns \c true if the socket is running in datagram mode. - \sa setMaxChannelCount() + \sa setMaximumChannelCount() */ -bool QSctpSocket::inDatagramMode() const +bool QSctpSocket::isInDatagramMode() const { Q_D(const QSctpSocket); - return d->maxChannelCount != -1 && d->isBuffered; + return d->maximumChannelCount != -1 && d->isBuffered; } /*! @@ -471,13 +471,13 @@ bool QSctpSocket::inDatagramMode() const On failure, returns a QNetworkDatagram that reports \l {QNetworkDatagram::isValid()}{not valid}. - \sa writeDatagram(), inDatagramMode(), currentReadChannel() + \sa writeDatagram(), isInDatagramMode(), currentReadChannel() */ QNetworkDatagram QSctpSocket::readDatagram() { Q_D(QSctpSocket); - if (!isReadable() || !inDatagramMode()) { + if (!isReadable() || !isInDatagramMode()) { qWarning("QSctpSocket::readDatagram(): operation is not permitted"); return QNetworkDatagram(); } @@ -507,14 +507,14 @@ QNetworkDatagram QSctpSocket::readDatagram() Writes a \a datagram to the buffer of the current write channel. Returns true on success; otherwise returns false. - \sa readDatagram(), inDatagramMode(), currentWriteChannel() + \sa readDatagram(), isInDatagramMode(), currentWriteChannel() */ bool QSctpSocket::writeDatagram(const QNetworkDatagram &datagram) { Q_D(QSctpSocket); if (!isWritable() || d->state != QAbstractSocket::ConnectedState || !d->socketEngine - || !d->socketEngine->isValid() || !inDatagramMode()) { + || !d->socketEngine->isValid() || !isInDatagramMode()) { qWarning("QSctpSocket::writeDatagram(): operation is not permitted"); return false; } diff --git a/src/network/socket/qsctpsocket.h b/src/network/socket/qsctpsocket.h index aaa4e1ecca..3e5a545c4b 100644 --- a/src/network/socket/qsctpsocket.h +++ b/src/network/socket/qsctpsocket.h @@ -59,9 +59,9 @@ public: void close() Q_DECL_OVERRIDE; void disconnectFromHost() Q_DECL_OVERRIDE; - void setMaxChannelCount(int count); - int maxChannelCount() const; - bool inDatagramMode() const; + void setMaximumChannelCount(int count); + int maximumChannelCount() const; + bool isInDatagramMode() const; QNetworkDatagram readDatagram(); bool writeDatagram(const QNetworkDatagram &datagram); diff --git a/src/network/socket/qsctpsocket_p.h b/src/network/socket/qsctpsocket_p.h index f38095330f..3f765ebed9 100644 --- a/src/network/socket/qsctpsocket_p.h +++ b/src/network/socket/qsctpsocket_p.h @@ -74,7 +74,7 @@ public: bool writeToSocket() Q_DECL_OVERRIDE; QByteArray incomingDatagram; - int maxChannelCount; + int maximumChannelCount; typedef std::deque IpHeaderList; QVector readHeaders; -- cgit v1.2.3 From e1f0e08e9a290689f2778ffcfafc133f8a1b99cf Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Fri, 18 Nov 2016 17:39:01 +0100 Subject: Add more information for QKeySequence::toString on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous documentation said: "On OS X, the string returned resembles the sequence that is shown in the menu bar." That was not completely true because the string returned depends on the format passed to the function. Task-number: QTWEBSITE-744 Change-Id: I1b7d9367547326670d1b3a8cfe48f066910f5a10 Reviewed-by: Topi Reiniö --- src/gui/kernel/qkeysequence.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index ea71e34e4b..77c5ae7a02 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1517,7 +1517,9 @@ bool QKeySequence::isDetached() const If the key sequence has no keys, an empty string is returned. On \macos, the string returned resembles the sequence that is - shown in the menu bar. + shown in the menu bar if \a format is + QKeySequence::NativeText; otherwise, the string uses the + "portable" format, suitable for writing to a file. \sa fromString() */ -- cgit v1.2.3 From 34c2a1dcf05661562cd00fe6dbdf884d8917933d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 27 Sep 2016 15:30:15 +0200 Subject: QFormLayout: fix use-after-free in clearQLayoutItem() Found by ASan when it should have been found by me in the initial review... The old code did, in this order: 1. delete item->layout() (which deletes item, as QLayoutItem::layout() is just a dynamic_cast implemented with virtual functions) 2. delete item->widget() (which is correct, but too late, as 'item' may have already been deleted; this is the first use-after-free bug) 3. delete item->spacerItem() (which is the second use-after-free). Fix by deleting item->widget() (which may be a no-op), _then_ checking for a QLayout, deleting all children (but not the layout), and finally deleting item as a QLayoutItem. Rename clearQLayoutItem() to clearAndDestroyQLayoutItem() to better match what it actually does. Change-Id: Id70a7a137dac5de466ef619f01bfd61dfc150418 Reviewed-by: Thiago Macieira Reviewed-by: Samuel Gaist Reviewed-by: Marc Mutz --- src/widgets/kernel/qformlayout.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 3e60723f17..f3f7280030 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -1410,18 +1410,15 @@ static QLayoutItem *ownershipCleanedItem(QFormLayoutItem *item, QFormLayout *lay return i; } -static void clearQLayoutItem(QLayoutItem *item) +static void clearAndDestroyQLayoutItem(QLayoutItem *item) { if (Q_LIKELY(item)) { + delete item->widget(); if (QLayout *layout = item->layout()) { - while (QLayoutItem *child = layout->takeAt(0)) { - clearQLayoutItem(child); - delete child; - } - delete layout; + while (QLayoutItem *child = layout->takeAt(0)) + clearAndDestroyQLayoutItem(child); } - delete item->widget(); - delete item->spacerItem(); + delete item; } } @@ -1453,8 +1450,8 @@ static void clearQLayoutItem(QLayoutItem *item) void QFormLayout::removeRow(int row) { TakeRowResult result = takeRow(row); - clearQLayoutItem(result.labelItem); - clearQLayoutItem(result.fieldItem); + clearAndDestroyQLayoutItem(result.labelItem); + clearAndDestroyQLayoutItem(result.fieldItem); } /*! @@ -1485,8 +1482,8 @@ void QFormLayout::removeRow(int row) void QFormLayout::removeRow(QWidget *widget) { TakeRowResult result = takeRow(widget); - clearQLayoutItem(result.labelItem); - clearQLayoutItem(result.fieldItem); + clearAndDestroyQLayoutItem(result.labelItem); + clearAndDestroyQLayoutItem(result.fieldItem); } /*! @@ -1518,8 +1515,8 @@ void QFormLayout::removeRow(QWidget *widget) void QFormLayout::removeRow(QLayout *layout) { TakeRowResult result = takeRow(layout); - clearQLayoutItem(result.labelItem); - clearQLayoutItem(result.fieldItem); + clearAndDestroyQLayoutItem(result.labelItem); + clearAndDestroyQLayoutItem(result.fieldItem); } /*! -- cgit v1.2.3 From d6c8fab8805f5085568065cdc8bfbfddfcfd8f2e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 17 Oct 2016 13:00:04 +0200 Subject: QMutex: make sure we try_lock_for no shorter than the duration passed By templating on the types and unconditionally using duration_cast to coerce the duration into a milliseconds, we allowed code such as mutex.try_lock_for(10us) to compile, which is misleading, since it's actually a zero- timeout try_lock(). Feedback from the std-discussions mailing list is that the wait_for functions should wait for _at least_ the duration given, because that is the natural direction of variance (tasks becoming ready to run might not get a CPU immediately, causing delays), while an interface that documents to wait _no more_ than the given duration is promising something it cannot fulfill. Fix by converting the given duration to the smallest number of milliseconds not less than the original duration. If that is not representable in an int, use INT_MAX, emulating the effect of a spurious wakeup, which are allowed to happen if the function returns false in that case. In the above example, the try_lock_for call is now equivalent to mutex.tryLock(1); The tryLock() docs state that the actual waiting time does not exceed the given milliseconds, but fixing that is a separate issue. Change-Id: Id4cbbea0ecc6fd2f94bb5aef28a1658be3728e52 Reviewed-by: Thiago Macieira --- src/corelib/thread/qmutex.cpp | 4 ++-- src/corelib/thread/qmutex.h | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 6e0fa4eedb..0aee4aeda4 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -275,7 +275,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT Attempts to lock the mutex. This function returns \c true if the lock was obtained; otherwise it returns \c false. If another thread has - locked the mutex, this function will wait for at most \a duration + locked the mutex, this function will wait for at least \a duration for the mutex to become available. Note: Passing a negative duration as the \a duration is equivalent to @@ -299,7 +299,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT Attempts to lock the mutex. This function returns \c true if the lock was obtained; otherwise it returns \c false. If another thread has - locked the mutex, this function will wait at most until \a timePoint + locked the mutex, this function will wait at least until \a timePoint for the mutex to become available. Note: Passing a \a timePoint which has already passed is equivalent diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 3a0e22e3bd..056ebdeaa5 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -46,8 +46,11 @@ #if QT_HAS_INCLUDE() # include +# include #endif +class tst_QMutex; + QT_BEGIN_NAMESPACE @@ -135,14 +138,7 @@ public: template bool try_lock_for(std::chrono::duration duration) { - // N4606 § 30.4.1.3 [thread.timedmutex.requirements]/5 specifies that - // a duration less than or equal to duration.zero() shall result in a - // try_lock, unlike QMutex's tryLock with a negative duration which - // results in a lock. - - if (duration <= duration.zero()) - return tryLock(0); - return tryLock(std::chrono::duration_cast(duration).count()); + return tryLock(convertToMilliseconds(duration)); } // TimedLockable concept @@ -162,6 +158,32 @@ public: private: Q_DISABLE_COPY(QMutex) friend class QMutexLocker; + friend class ::tst_QMutex; + +#if QT_HAS_INCLUDE() + template + static int convertToMilliseconds(std::chrono::duration duration) + { + // N4606 § 30.4.1.3.5 [thread.timedmutex.requirements] specifies that a + // duration less than or equal to duration.zero() shall result in a + // try_lock, unlike QMutex's tryLock with a negative duration which + // results in a lock. + + if (duration <= duration.zero()) + return 0; + + // when converting from 'duration' to milliseconds, make sure that + // the result is not shorter than 'duration': + std::chrono::milliseconds wait = std::chrono::duration_cast(duration); + if (wait < duration) + wait += std::chrono::milliseconds(1); + Q_ASSERT(wait >= duration); + const auto ms = wait.count(); + const auto maxInt = (std::numeric_limits::max)(); + + return ms < maxInt ? int(ms) : maxInt; + } +#endif }; class Q_CORE_EXPORT QMutexLocker -- cgit v1.2.3 From d377f14fd5b4fe3ed64392c6b743bac395f9f891 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 7 Nov 2016 11:28:16 +0100 Subject: Windows QPA: Detect Windows 10 tablet mode Add new file for dynamically loading Window 10 Helpers via combase.dll and add function qt_windowsIsTabletMode() querying UIViewSettings::get_UserInteractionMode() for "Touch" mode. The style hint QPlatformIntegration::ShowIsMaximized will then reflect the tablet mode setting. Task-number: QTBUG-56831 Change-Id: Ia361dd172fcf0e54fdfc70863c43527f3ea72fe2 Reviewed-by: Oliver Wolff Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/windows/qwin10helpers.cpp | 167 +++++++++++++++++++++ src/plugins/platforms/windows/qwin10helpers.h | 52 +++++++ src/plugins/platforms/windows/qwindowsclipboard.h | 2 + .../platforms/windows/qwindowsintegration.cpp | 7 + src/plugins/platforms/windows/windows.pri | 4 +- 5 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/windows/qwin10helpers.cpp create mode 100644 src/plugins/platforms/windows/qwin10helpers.h (limited to 'src') diff --git a/src/plugins/platforms/windows/qwin10helpers.cpp b/src/plugins/platforms/windows/qwin10helpers.cpp new file mode 100644 index 0000000000..3ded96b9d6 --- /dev/null +++ b/src/plugins/platforms/windows/qwin10helpers.cpp @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwin10helpers.h" + +#include +#include + +#if defined(Q_CC_MINGW) +# define HAS_UI_VIEW_SETTINGS_INTEROP +#elif !defined(Q_CC_MSVC) || _MSC_VER >= 1900 // MSVC2013 is lacking both +# define HAS_UI_VIEW_SETTINGS_INTEROP +# define HAS_UI_VIEW_SETTINGS +#endif + +#include + +#ifdef HAS_UI_VIEW_SETTINGS +# include +#endif + +#ifdef HAS_UI_VIEW_SETTINGS_INTEROP +# include +#endif + +#ifndef HAS_UI_VIEW_SETTINGS_INTEROP +MIDL_INTERFACE("3694dbf9-8f68-44be-8ff5-195c98ede8a6") +IUIViewSettingsInterop : public IInspectable +{ +public: + virtual HRESULT STDMETHODCALLTYPE GetForWindow( + __RPC__in HWND hwnd, + __RPC__in REFIID riid, + __RPC__deref_out_opt void **ppv) = 0; +}; +#endif // !HAS_UI_VIEW_SETTINGS_INTEROP + +#ifndef HAS_UI_VIEW_SETTINGS +namespace ABI { +namespace Windows { +namespace UI { +namespace ViewManagement { + +enum UserInteractionMode { Mouse, Touch }; + +MIDL_INTERFACE("C63657F6-8850-470D-88F8-455E16EA2C26") +IUIViewSettings : public IInspectable +{ +public: + virtual HRESULT STDMETHODCALLTYPE get_UserInteractionMode(UserInteractionMode *value) = 0; +}; + +} // namespace ViewManagement +} // namespace UI +} // namespace Windows +} // namespace ABI +#endif // HAS_UI_VIEW_SETTINGS + +QT_BEGIN_NAMESPACE + +// Starting from Windows 10 +struct QWindowsComBaseDLL +{ + bool init(); + bool isValid() const + { + return roGetActivationFactory != nullptr && windowsCreateStringReference != nullptr; + } + + typedef HRESULT (WINAPI *RoGetActivationFactory)(HSTRING, REFIID, void **); + typedef HRESULT (WINAPI *WindowsCreateStringReference)(PCWSTR, UINT32, HSTRING_HEADER *, HSTRING *); + + RoGetActivationFactory roGetActivationFactory = nullptr; + WindowsCreateStringReference windowsCreateStringReference = nullptr; +}; + +static QWindowsComBaseDLL baseComDll; + +bool QWindowsComBaseDLL::init() +{ + if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10 && !isValid()) { + QSystemLibrary library(QStringLiteral("combase")); + roGetActivationFactory = + reinterpret_cast(library.resolve("RoGetActivationFactory")); + windowsCreateStringReference = + reinterpret_cast(library.resolve("WindowsCreateStringReference")); + } + return isValid(); +} + +// Return tablet mode, note: Does not work for GetDesktopWindow(). +bool qt_windowsIsTabletMode(HWND hwnd) +{ + bool result = false; + + if (!baseComDll.init()) + return false; + + const wchar_t uiViewSettingsId[] = L"Windows.UI.ViewManagement.UIViewSettings"; + HSTRING_HEADER uiViewSettingsIdRefHeader; + HSTRING uiViewSettingsIdHs = nullptr; + const UINT32 uiViewSettingsIdLen = UINT32(sizeof(uiViewSettingsId) / sizeof(uiViewSettingsId[0]) - 1); + if (FAILED(baseComDll.windowsCreateStringReference(uiViewSettingsId, uiViewSettingsIdLen, &uiViewSettingsIdRefHeader, &uiViewSettingsIdHs))) + return false; + + IUIViewSettingsInterop *uiViewSettingsInterop = nullptr; + // __uuidof(IUIViewSettingsInterop); + const GUID uiViewSettingsInteropRefId = {0x3694dbf9, 0x8f68, 0x44be,{0x8f, 0xf5, 0x19, 0x5c, 0x98, 0xed, 0xe8, 0xa6}}; + + HRESULT hr = baseComDll.roGetActivationFactory(uiViewSettingsIdHs, uiViewSettingsInteropRefId, + reinterpret_cast(&uiViewSettingsInterop)); + if (FAILED(hr)) + return false; + + // __uuidof(ABI::Windows::UI::ViewManagement::IUIViewSettings); + const GUID uiViewSettingsRefId = {0xc63657f6, 0x8850, 0x470d,{0x88, 0xf8, 0x45, 0x5e, 0x16, 0xea, 0x2c, 0x26}}; + ABI::Windows::UI::ViewManagement::IUIViewSettings *viewSettings = nullptr; + hr = uiViewSettingsInterop->GetForWindow(hwnd, uiViewSettingsRefId, + reinterpret_cast(&viewSettings)); + if (SUCCEEDED(hr)) { + ABI::Windows::UI::ViewManagement::UserInteractionMode currentMode; + hr = viewSettings->get_UserInteractionMode(¤tMode); + if (SUCCEEDED(hr)) + result = currentMode == 1; // Touch, 1 + viewSettings->Release(); + } + uiViewSettingsInterop->Release(); + return result; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwin10helpers.h b/src/plugins/platforms/windows/qwin10helpers.h new file mode 100644 index 0000000000..e1485003dd --- /dev/null +++ b/src/plugins/platforms/windows/qwin10helpers.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWIN10HELPERS_H +#define QWIN10HELPERS_H + +#include +#include + +QT_BEGIN_NAMESPACE + +bool qt_windowsIsTabletMode(HWND hwnd); + +QT_END_NAMESPACE + +#endif // QWIN10HELPERS_H diff --git a/src/plugins/platforms/windows/qwindowsclipboard.h b/src/plugins/platforms/windows/qwindowsclipboard.h index 3fe0c74e78..992d34d492 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.h +++ b/src/plugins/platforms/windows/qwindowsclipboard.h @@ -73,6 +73,8 @@ public: static QWindowsClipboard *instance() { return m_instance; } + HWND clipboardViewer() const { return m_clipboardViewer; } + private: void clear(); void releaseIData(); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 004b03d9a9..f49ad0e767 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -41,6 +41,7 @@ #include "qwindowsintegration.h" #include "qwindowswindow.h" #include "qwindowscontext.h" +#include "qwin10helpers.h" #include "qwindowsopenglcontext.h" #include "qwindowsscreen.h" @@ -509,6 +510,12 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co #ifdef SPI_GETKEYBOARDSPEED case KeyboardAutoRepeatRate: return QVariant(keyBoardAutoRepeatRateMS()); +#endif + case QPlatformIntegration::ShowIsMaximized: +#ifndef QT_NO_CLIPBOARD + return qt_windowsIsTabletMode(d->m_clipboard.clipboardViewer()); +#else + break; #endif case QPlatformIntegration::StartDragTime: case QPlatformIntegration::StartDragDistance: diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index d97e49309f..20e0b81da9 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -25,7 +25,8 @@ SOURCES += \ $$PWD/qwindowsdialoghelpers.cpp \ $$PWD/qwindowsservices.cpp \ $$PWD/qwindowsnativeinterface.cpp \ - $$PWD/qwindowsopengltester.cpp + $$PWD/qwindowsopengltester.cpp \ + $$PWD/qwin10helpers.cpp HEADERS += \ $$PWD/qwindowswindow.h \ @@ -46,6 +47,7 @@ HEADERS += \ $$PWD/qwindowsnativeinterface.h \ $$PWD/qwindowsopengltester.h \ $$PWD/qwindowsthreadpoolrunner.h + $$PWD/qwin10helpers.h INCLUDEPATH += $$PWD -- cgit v1.2.3 From cff48c7845ccf51ac53a550a43dec78428124f70 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 21 Nov 2016 12:46:46 +0100 Subject: eglfs: Avoid unexpectedly flushing QPA input events Flushing all events to ensure that the expose (or other queued events) get processed right away is dangerous. Instead, pass ExcludeUserInputEvents like many other platform plugins do. This way queued input events do not get processed at an unexpected point in time and so do not interfere with modal dialogs for instance. Task-number: QTBUG-57229 Change-Id: I9da09e62627d26485fb5a37fc190cb4a4bcb28b6 Reviewed-by: Andy Nichols --- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 2 +- src/plugins/platforms/eglfs/qeglfswindow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index bb62506f33..2a6f3aa7cf 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -176,7 +176,7 @@ QPlatformBackingStore *QEglFSIntegration::createPlatformBackingStore(QWindow *wi QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window) const { - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); QEglFSWindow *w = qt_egl_device_integration()->createWindow(window); w->create(); if (window->type() != Qt::ToolTip) diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 84856831c3..3cc7079fbb 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -208,7 +208,7 @@ void QEglFSWindow::setVisible(bool visible) QWindowSystemInterface::handleExposeEvent(wnd, QRect(QPoint(0, 0), wnd->geometry().size())); if (visible) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); } void QEglFSWindow::setGeometry(const QRect &r) -- cgit v1.2.3 From e2b856d56290e9b3eaaf889b3e0a08badbaa6046 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 17 Nov 2016 16:10:11 +0100 Subject: QDir::tempPath - use NSTemporaryDirectory on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of hardcoded "/tmp". Task-number: QTBUG-57165 Change-Id: I9d3ae157c22ce131281b8279149eea87a26244e8 Reviewed-by: Morten Johan Sørvig --- src/corelib/io/qfilesystemengine_unix.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 3cc27bf847..a3b28a8d95 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -59,6 +59,13 @@ #include #endif +#if defined(Q_OS_DARWIN) +// We cannot include (it's an Objective-C header), but +// we need these declarations: +Q_FORWARD_DECLARE_OBJC_CLASS(NSString); +extern "C" NSString *NSTemporaryDirectory(); +#endif + QT_BEGIN_NAMESPACE #if defined(Q_OS_DARWIN) @@ -706,8 +713,17 @@ QString QFileSystemEngine::tempPath() return QDir::cleanPath(temp); #else QString temp = QFile::decodeName(qgetenv("TMPDIR")); - if (temp.isEmpty()) - temp = QLatin1String("/tmp"); + if (temp.isEmpty()) { +#if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED) + if (NSString *nsPath = NSTemporaryDirectory()) { + temp = QString::fromCFString((CFStringRef)nsPath); + } else { +#else + { +#endif + temp = QLatin1String("/tmp"); + } + } return QDir::cleanPath(temp); #endif } -- cgit v1.2.3 From b5222307af591c5360a64ffa311bde4a61af97d6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 19 Oct 2016 16:37:53 +0200 Subject: Fix some qdoc-warnings qtbase/src/corelib/kernel/qdeadlinetimer.cpp:343: warning: Cannot find 'setPreciseRemainingTime(...)' in '\fn' void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, unsigned nsecs, Qt::TimerType type) qtbase/src/corelib/kernel/qdeadlinetimer.cpp:459: warning: Overrides a previous doc qtbase/src/corelib/kernel/qelapsedtimer.cpp:86: warning: Unknown command '\ref' qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_2' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_3_0' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_1' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_0' in QSysInfo::MacVersion qtbase/src/corelib/kernel/qdeadlinetimer.cpp:175: warning: Missing parameter name qtbase/src/corelib/kernel/qdeadlinetimer.cpp:175: warning: No such parameter 'ForeverConstant' in QDeadlineTimer::QDeadlineTimer() qtbase/src/corelib/kernel/qdeadlinetimer.h:156: warning: No documentation for 'QDeadlineTimer::remainingTimeAsDuration()' qtbase/src/gui/painting/qcolor.cpp:796: warning: Undocumented parameter 'name' in QColor::QColor() qtbase/src/gui/painting/qcolor.cpp:802: warning: Undocumented parameter 'name' in QColor::QColor() Some errors in QDeadlineTimer remain due to qdoc not fully supporting templates. Change-Id: Ie7afd91c48048748eeda23c32056583c31fd7490 Reviewed-by: Nico Vertriest Reviewed-by: Jake Petroules --- src/corelib/global/qglobal.cpp | 6 ++++++ src/corelib/kernel/qdeadlinetimer.cpp | 25 ++++--------------------- src/corelib/kernel/qelapsedtimer.cpp | 2 +- src/gui/painting/qcolor.cpp | 8 ++++++++ 4 files changed, 19 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index d06acb83b2..6efdc4c22c 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1244,6 +1244,12 @@ bool qSharedBuild() Q_DECL_NOTHROW \value MV_TVOS_9_2 tvOS 9.2 \value MV_TVOS_10_0 tvOS 10.0 + \value MV_WATCHOS watchOS (any) + \value MV_WATCHOS_2_0 watchOS 2.0 + \value MV_WATCHOS_2_1 watchOS 2.1 + \value MV_WATCHOS_2_2 watchOS 2.2 + \value MV_WATCHOS_3_0 watchOS 3.0 + \value MV_None Not a Darwin operating system \sa WinVersion diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index 17a74b22d7..d670637d53 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -173,9 +173,9 @@ Q_DECL_CONST_FUNCTION static inline QPair toSecsAndNSecs(qint64 */ /*! - \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant, Qt::TimerType timerType) + \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant foreverConstant, Qt::TimerType timerType) - QDeadlineTimer objects created with parameter \a ForeverConstant never expire. + QDeadlineTimer objects created with parameter \a foreverConstant never expire. For such objects, remainingTime() will return -1, deadline() will return the maximum value, and isForever() will return true. @@ -295,7 +295,7 @@ void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) Q_D parameters are zero, this QDeadlineTimer will be marked as expired. The timer type for this QDeadlineTimer object will be set to the specified - \a type. + \a timerType. \sa setRemainingTime(), hasExpired(), isForever(), remainingTime() */ @@ -341,24 +341,7 @@ void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::Time */ /*! - \fn void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, unsigned nsecs, Qt::TimerType type) - - Sets the remaining time for this QDeadlineTimer object to \a secs seconds - and \a nsecs nanoseconds from now, if \a secs is a positive value. If both - values are zero, this QDeadlineTimer object will be marked as expired, - whereas if \a secs is -1, it will set it to never expire. - - If value of \a nsecs is more than 1 billion nanoseconds (1 second), this - function will adjust \a secs accordingly. - - The timer type for this QDeadlineTimer object will be set to the specified \a type. - - \sa setRemainingTime(), hasExpired(), isForever(), remainingTime() -*/ - -/*! - \overload - \fn Duration QDeadlineTimer::remainingTime() const + \fn std::chrono::nanoseconds remainingTimeAsDuration() const Returns a \c{std::chrono::duration} object of type \c{Duration} containing the remaining time in this QDeadlineTimer, if it still has time left. If diff --git a/src/corelib/kernel/qelapsedtimer.cpp b/src/corelib/kernel/qelapsedtimer.cpp index 5e9d1317ac..e578b5b8b3 100644 --- a/src/corelib/kernel/qelapsedtimer.cpp +++ b/src/corelib/kernel/qelapsedtimer.cpp @@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE \snippet qelapsedtimer/main.cpp 2 - It is often more convenient to use \ref{QDeadlineTimer} in this case, which + It is often more convenient to use \l{QDeadlineTimer} in this case, which counts towards a timeout in the future instead of tracking elapsed time. \section1 Reference Clocks diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index e3dbf663e1..6a8091bf8b 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -795,12 +795,20 @@ QColor::QColor(Spec spec) Q_DECL_NOTHROW /*! \fn QColor::QColor(const char *name) + + Constructs a named color in the same way as setNamedColor() using + the given \a name. + \overload \sa setNamedColor(), name(), isValid() */ /*! \fn QColor::QColor(QLatin1String name) + + Constructs a named color in the same way as setNamedColor() using + the given \a name. + \overload \since 5.8 \sa setNamedColor(), name(), isValid() -- cgit v1.2.3 From be94fc445a664fa10ce5ff5ea1e4fbe7d23585e7 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Sun, 13 Nov 2016 15:04:33 +0300 Subject: QString: optimize remove(QChar, Qt::CaseSensitivity) remove(int, int) with O(N) was used in a loop. We had a quadratic complexity. Use erase-remove idiom to fix it. Change-Id: I643a2a75619ec5ea2bf99e48a25f64a7f69ba156 Reviewed-by: Edward Welbourne Reviewed-by: Marc Mutz --- src/corelib/tools/qstring.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 8520bb5740..4262899e02 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2300,21 +2300,20 @@ QString &QString::remove(const QString &str, Qt::CaseSensitivity cs) */ QString &QString::remove(QChar ch, Qt::CaseSensitivity cs) { - int i = 0; - ushort c = ch.unicode(); - if (cs == Qt::CaseSensitive) { - while (i < d->size) - if (d->data()[i] == ch) - remove(i, 1); - else - i++; - } else { - c = foldCase(c); - while (i < d->size) - if (foldCase(d->data()[i]) == c) - remove(i, 1); - else - i++; + const int idx = indexOf(ch, 0, cs); + if (idx != -1) { + const auto first = begin(); // implicit detach() + auto last = end(); + if (cs == Qt::CaseSensitive) { + last = std::remove(first + idx, last, ch); + } else { + const QChar c = ch.toCaseFolded(); + auto caseInsensEqual = [c](QChar x) { + return c == x.toCaseFolded(); + }; + last = std::remove_if(first + idx, last, caseInsensEqual); + } + resize(last - first); } return *this; } -- cgit v1.2.3 From d8857f21ac2640215177b9cb7bb681b74bc66068 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 22 Nov 2016 09:46:14 +0100 Subject: If there are no available sizes, then fallback to the requested size In a case like the SVG iconengine there is no available sizes implementation. However in that case we don't need to provide different sizes as we can have SVG scale it for us to the one requested. So it is assumed that with no available sizes implementation that the icon engine will take care of this for us. This ensures that SVG files can be used as icons inside the menu on macOS. Task-number: QTBUG-40225 Task-number: QTBUG-55932 Change-Id: If01ca582c4c07834e6de16652924e0b7e118c87c Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoahelpers.h | 2 +- src/plugins/platforms/cocoa/qcocoahelpers.mm | 7 +++++-- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index c2abe4e245..bbb37937d2 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -64,7 +64,7 @@ inline NSMutableArray *qt_mac_QStringListToNSMutableArray(const QStringList &qst NSImage *qt_mac_cgimage_to_nsimage(CGImageRef iamge); NSImage *qt_mac_create_nsimage(const QPixmap &pm); -NSImage *qt_mac_create_nsimage(const QIcon &icon); +NSImage *qt_mac_create_nsimage(const QIcon &icon, int defaultSize = 0); CGImageRef qt_mac_toCGImage(const QImage &qImage); CGImageRef qt_mac_toCGImageMask(const QImage &qImage); QImage qt_mac_toQImage(CGImageRef image); diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 058209da7e..cd73148752 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -152,13 +152,16 @@ NSImage *qt_mac_create_nsimage(const QPixmap &pm) return nsImage; } -NSImage *qt_mac_create_nsimage(const QIcon &icon) +NSImage *qt_mac_create_nsimage(const QIcon &icon, int defaultSize) { if (icon.isNull()) return nil; NSImage *nsImage = [[NSImage alloc] init]; - foreach (QSize size, icon.availableSizes()) { + QList availableSizes = icon.availableSizes(); + if (availableSizes.isEmpty() && defaultSize > 0) + availableSizes << QSize(defaultSize, defaultSize); + foreach (QSize size, availableSizes) { QPixmap pm = icon.pixmap(size); QImage image = pm.toImage(); CGImageRef cgImage = qt_mac_toCGImage(image); diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 2d4073956a..fa8eb22569 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -348,7 +348,7 @@ NSMenuItem *QCocoaMenuItem::sync() NSImage *img = nil; if (!m_icon.isNull()) { - img = qt_mac_create_nsimage(m_icon); + img = qt_mac_create_nsimage(m_icon, m_iconSize); [img setSize:NSMakeSize(m_iconSize, m_iconSize)]; } [m_native setImage:img]; -- cgit v1.2.3 From a32424b46cd3ef6fd8d644354e3cec434d5ab951 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 15 Nov 2016 17:15:56 +0100 Subject: AreArgumentsNarrowedBase: Correct logic for narrowing connect() casts The prior test deemed there to be narrowing if source and destination integral-or-enum types didn't have the same signedness; but all values of an unsigned source type can be represented in a larger signed destination type, so there is no narrowing in this case. Updated QObject test-case to match. Change-Id: I517a5997adcad70e185d7469a8d26788e463cb75 Reviewed-by: Giuseppe D'Angelo --- src/corelib/kernel/qobjectdefs_impl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index e94e713e1f..79c9c8303e 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -229,8 +229,14 @@ namespace QtPrivate { (std::is_floating_point::value && std::is_integral::value) || (std::is_floating_point::value && std::is_floating_point::value && sizeof(From) > sizeof(To)) || ((std::is_integral::value || std::is_enum::value) && std::is_floating_point::value) || - (std::is_integral::value && std::is_integral::value && (sizeof(From) > sizeof(To) || std::is_signed::value != std::is_signed::value)) || - (std::is_enum::value && std::is_integral::value && (sizeof(From) > sizeof(To) || IsEnumUnderlyingTypeSigned::value != std::is_signed::value)) + (std::is_integral::value && std::is_integral::value + && (sizeof(From) > sizeof(To) + || (std::is_signed::value ? !std::is_signed::value + : (std::is_signed::value && sizeof(From) == sizeof(To))))) || + (std::is_enum::value && std::is_integral::value + && (sizeof(From) > sizeof(To) + || (IsEnumUnderlyingTypeSigned::value ? !std::is_signed::value + : (std::is_signed::value && sizeof(From) == sizeof(To))))) > { }; -- cgit v1.2.3 From 20017d0b1bde34190d96bebe34b4e641efdde779 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 21 Nov 2016 14:56:09 +0100 Subject: Remove some #if 0 blocks from API headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Noticed in API review for 5.8 release. Change-Id: I1dd48c676924048c32fab8307868cf61915df131 Reviewed-by: Jędrzej Nowacki --- src/widgets/kernel/qwidget.h | 10 ---------- src/widgets/widgets/qpushbutton.h | 3 --- 2 files changed, 13 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 5edf2c62da..58413c6bd3 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -570,16 +570,6 @@ public: inline QWidget *childAt(int x, int y) const; QWidget *childAt(const QPoint &p) const; -#if 0 // Used to be included in Qt4 for Q_WS_X11 - const QX11Info &x11Info() const; - Qt::HANDLE x11PictureHandle() const; -#endif - -#if 0 // Used to be included in Qt4 for Q_WS_MAC - Qt::HANDLE macQDHandle() const; - Qt::HANDLE macCGHandle() const; -#endif - void setAttribute(Qt::WidgetAttribute, bool on = true); inline bool testAttribute(Qt::WidgetAttribute) const; diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h index 859ac247fb..b0d1ccacdb 100644 --- a/src/widgets/widgets/qpushbutton.h +++ b/src/widgets/widgets/qpushbutton.h @@ -87,9 +87,6 @@ public Q_SLOTS: protected: bool event(QEvent *e) Q_DECL_OVERRIDE; -#if 0 // Used to be included in Qt4 for Q_WS_MAC - bool hitButton(const QPoint &pos) const; -#endif void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE; -- cgit v1.2.3 From e9fa435652ef064515bd5c04c0b5e5c4a30ebca4 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 4 Nov 2016 13:46:36 +0100 Subject: winrt: Add support for Windows Information Protection Windows Information Protection is used for splitting corporate and personal data, requiring connections to be established in a different way instantiating ThreadNetworkContext. Usage is enabled via the QT_WINRT_USE_THREAD_NETWORK_CONTEXT environment variable. Change-Id: I3aaa097b66fc616d42cd05a1e20bbcb004f6e467 Reviewed-by: James Tong Reviewed-by: Oliver Wolff --- src/network/socket/qabstractsocket.cpp | 13 +++-- src/network/socket/qnativesocketengine_winrt.cpp | 68 +++++++++++++++++++++++- 2 files changed, 76 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 02bba2d293..57c40194a3 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -1113,10 +1113,15 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() // Tries to connect to the address. If it succeeds immediately // (localhost address on BSD or any UDP connect), emit // connected() and return. - if (socketEngine->connectToHost(host, port)) { - //_q_testConnection(); - fetchConnectionParameters(); - return; + if ( +#if defined(Q_OS_WINRT) && _MSC_VER >= 1900 + !qEnvironmentVariableIsEmpty("QT_WINRT_USE_THREAD_NETWORK_CONTEXT") ? + socketEngine->connectToHostByName(hostName, port) : +#endif + socketEngine->connectToHost(host, port)) { + //_q_testConnection(); + fetchConnectionParameters(); + return; } // Check that we're in delayed connection state. If not, try diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 3daca38959..d0b8bff7f9 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -75,6 +75,9 @@ using namespace ABI::Windows::Storage::Streams; using namespace ABI::Windows::Networking; using namespace ABI::Windows::Networking::Connectivity; using namespace ABI::Windows::Networking::Sockets; +#if _MSC_VER >= 1900 +using namespace ABI::Windows::Security::EnterpriseData; +#endif typedef ITypedEventHandler ClientConnectedHandler; typedef ITypedEventHandler DatagramReceivedHandler; @@ -84,6 +87,45 @@ typedef IAsyncOperationWithProgress IAsyncBufferOperation; QT_BEGIN_NAMESPACE +#if _MSC_VER >= 1900 +static HRESULT qt_winrt_try_create_thread_network_context(QString host, ComPtr &context) +{ + HRESULT hr; + ComPtr protectionPolicyManager; + + hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Security_EnterpriseData_ProtectionPolicyManager).Get(), + &protectionPolicyManager); + RETURN_HR_IF_FAILED("Could not access ProtectionPolicyManager statics."); + + ComPtr hostNameFactory; + hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(), + &hostNameFactory); + RETURN_HR_IF_FAILED("Could not access HostName factory."); + + ComPtr hostName; + HStringReference hostRef(reinterpret_cast(host.utf16()), host.length()); + hr = hostNameFactory->CreateHostName(hostRef.Get(), &hostName); + RETURN_HR_IF_FAILED("Could not create hostname."); + + ComPtr> op; + hr = protectionPolicyManager->GetPrimaryManagedIdentityForNetworkEndpointAsync(hostName.Get(), &op); + RETURN_HR_IF_FAILED("Could not get identity operation."); + + HSTRING hIdentity; + hr = QWinRTFunctions::await(op, &hIdentity); + RETURN_HR_IF_FAILED("Could not wait for identity operation."); + + // Implies there is no need for a network context for this address + if (hIdentity == nullptr) + return S_OK; + + hr = protectionPolicyManager->CreateCurrentThreadNetworkContext(hIdentity, &context); + RETURN_HR_IF_FAILED("Could not create thread network context"); + + return S_OK; +} +#endif // _MSC_VER >= 1900 + static inline QString qt_QStringFromHString(const HString &string) { UINT32 length; @@ -367,9 +409,23 @@ bool QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 por bool QNativeSocketEngine::connectToHostByName(const QString &name, quint16 port) { Q_D(QNativeSocketEngine); + HRESULT hr; + +#if _MSC_VER >= 1900 + ComPtr networkContext; + if (!qEnvironmentVariableIsEmpty("QT_WINRT_USE_THREAD_NETWORK_CONTEXT")) { + hr = qt_winrt_try_create_thread_network_context(name, networkContext); + if (FAILED(hr)) { + setError(QAbstractSocket::ConnectionRefusedError, QLatin1String("Could not create thread network context.")); + d->socketState = QAbstractSocket::ConnectedState; + return true; + } + } +#endif // _MSC_VER >= 1900 + HStringReference hostNameRef(reinterpret_cast(name.utf16())); ComPtr hostNameFactory; - HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(), + hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(), &hostNameFactory); Q_ASSERT_SUCCEEDED(hr); ComPtr remoteHost; @@ -390,6 +446,16 @@ bool QNativeSocketEngine::connectToHostByName(const QString &name, quint16 port) } Q_ASSERT_SUCCEEDED(hr); +#if _MSC_VER >= 1900 + if (networkContext != nullptr) { + ComPtr networkContextCloser; + hr = networkContext.As(&networkContextCloser); + Q_ASSERT_SUCCEEDED(hr); + hr = networkContextCloser->Close(); + Q_ASSERT_SUCCEEDED(hr); + } +#endif // _MSC_VER >= 1900 + d->socketState = QAbstractSocket::ConnectingState; QEventDispatcherWinRT::runOnXamlThread([d, &hr]() { hr = d->connectOp->put_Completed(Callback( -- cgit v1.2.3 From d20a99c081491f020836904eaa1c9323b9b56921 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 17 Nov 2016 16:19:32 +0100 Subject: winrt: Add printsupport For WinRT QPrinter and co are disabled in the new configure system. Still, we need to have printsupport enabled as a module, providing no printer. Task-number: QTBUG-56321 Change-Id: I95ce538e8f54073832af551ccf7f981e877a3b25 Reviewed-by: Oliver Wolff --- src/printsupport/kernel/kernel.pri | 2 +- src/src.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/printsupport/kernel/kernel.pri b/src/printsupport/kernel/kernel.pri index 22d12e4cc3..90eab4a634 100644 --- a/src/printsupport/kernel/kernel.pri +++ b/src/printsupport/kernel/kernel.pri @@ -30,7 +30,7 @@ win32 { $$PWD/qprintengine_win_p.h SOURCES += \ $$PWD/qprintengine_win.cpp - LIBS_PRIVATE += -lwinspool -lcomdlg32 -lgdi32 -luser32 + !winrt: LIBS_PRIVATE += -lwinspool -lcomdlg32 -lgdi32 -luser32 } unix:!darwin:qtConfig(cups) { diff --git a/src/src.pro b/src/src.pro index f19b0bd354..54f3b6e020 100644 --- a/src/src.pro +++ b/src/src.pro @@ -186,7 +186,7 @@ qtConfig(gui) { SUBDIRS += src_opengl src_plugins.depends += src_opengl } - !wince:!winrt { + !wince { SUBDIRS += src_printsupport src_plugins.depends += src_printsupport } -- cgit v1.2.3 From fca4acbfba12121bffb3d49aa2198a55e4a762cf Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 18 Nov 2016 12:10:38 +0100 Subject: Remove wince checks Windows CE is not supported since 5.6. No need to have checks anymore. Change-Id: I384bd67e04dec06e83ee69b4ef5dc7dd97888c14 Reviewed-by: Oliver Wolff Reviewed-by: Oswald Buddenhagen --- src/src.pro | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index 54f3b6e020..b13bc4fa43 100644 --- a/src/src.pro +++ b/src/src.pro @@ -178,18 +178,14 @@ qtConfig(gui) { src_plugins.depends += src_gui src_platformsupport src_platformheaders src_testlib.depends += src_gui # if QtGui is enabled, QtTest requires QtGui's headers qtConfig(widgets) { - SUBDIRS += src_tools_uic src_widgets + SUBDIRS += src_tools_uic src_widgets src_printsupport TOOLS += src_tools_uic - src_plugins.depends += src_widgets + src_plugins.depends += src_widgets src_printsupport src_testlib.depends += src_widgets # if QtWidgets is enabled, QtTest requires QtWidgets's headers qtConfig(opengl) { SUBDIRS += src_opengl src_plugins.depends += src_opengl } - !wince { - SUBDIRS += src_printsupport - src_plugins.depends += src_printsupport - } } } SUBDIRS += src_plugins -- cgit v1.2.3 From 6542712dfafc4a64d505522ed23b02ae626ad38f Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 17 Nov 2016 16:52:31 +0100 Subject: Extend documentation for SHA-3 third-party license MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Write down which files are under CC0, and which under BSD. Change-Id: Ifdbfa3393b2a0f0d857e6c569bd105426c0719cb Reviewed-by: Topi Reiniö --- src/3rdparty/sha3/qt_attribution.json | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/3rdparty/sha3/qt_attribution.json b/src/3rdparty/sha3/qt_attribution.json index 13e6e971d9..4866be32ea 100644 --- a/src/3rdparty/sha3/qt_attribution.json +++ b/src/3rdparty/sha3/qt_attribution.json @@ -4,6 +4,7 @@ "Name": "Secure Hash Algorithm SHA-3 - brg_endian", "QDocModule": "qtcore", "QtUsage": "Used in Qt Core (QCryptographicHash).", + "Files": "brg_endian.h", "Description": "SHA-3, originally known as Keccak, is a cryptographic hash function.", "License": "BSD 3-clause \"New\" or \"Revised\" License", @@ -16,6 +17,7 @@ "Name": "Secure Hash Algorithm SHA-3 - Keccak", "QDocModule": "qtcore", "QtUsage": "Used in Qt Core (QCryptographicHash).", + "Files": "KeccakF-1600-32-rvk.macros KeccakF-1600-32.macros KeccakF-1600-64.macros KeccakF-1600-interface.h KeccakF-1600-opt32.c KeccakF-1600-opt64.c KeccakF-1600-unrolling.macros KeccakNISTInterface.c KeccakNISTInterface.h KeccakSponge.c KeccakSponge.h", "Description": "SHA-3, originally known as Keccak, is a cryptographic hash function.", "License": "Creative Commons Zero v1.0 Universal", -- cgit v1.2.3 From ae93a76c931d7de768d5ac600a092bdc87915d3e Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 19 Oct 2016 16:33:27 +0200 Subject: Document The Public Suffix List MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3c8b00e04ed30209b0de0927b473ba2b9a4f0c87 Reviewed-by: Thiago Macieira Reviewed-by: Topi Reiniö --- src/corelib/io/PSL-LICENSE.txt | 373 +++++++++++++++++++++++++++++++++++++ src/corelib/io/qt_attribution.json | 29 +++ src/corelib/io/qurltlds_p.h.INFO | 3 - 3 files changed, 402 insertions(+), 3 deletions(-) create mode 100644 src/corelib/io/PSL-LICENSE.txt (limited to 'src') diff --git a/src/corelib/io/PSL-LICENSE.txt b/src/corelib/io/PSL-LICENSE.txt new file mode 100644 index 0000000000..d0a1fa1482 --- /dev/null +++ b/src/corelib/io/PSL-LICENSE.txt @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/src/corelib/io/qt_attribution.json b/src/corelib/io/qt_attribution.json index 2a616a2819..c64f8cae4b 100644 --- a/src/corelib/io/qt_attribution.json +++ b/src/corelib/io/qt_attribution.json @@ -1,3 +1,4 @@ +[ { "Id": "qtemporaryfile", "Name": "Parts of QTemporaryFile", @@ -10,4 +11,32 @@ "LicenseId": "BSD-3-Clause", "LicenseFile": "QTEMPORARYFILE_LICENSE.txt", "Copyright": "Copyright (c) 1987, 1993 The Regents of the University of California." +}, +{ + "Id": "psl", + "Name": "The Public Suffix List", + "QDocModule": "qtcore", + "Description": "The Public Suffix List is an initiative of the Mozilla Project, +but is maintained as a community resource. It is available for use in any software, +but was originally created to meet the needs of browser manufacturers. +It allows browsers to, for example: + +- Avoid privacy-damaging \"supercookies\" being set for high-level domain name suffixes + +- Highlight the most important part of a domain name in the user interface + +- Accurately sort history entries by site", + + "Files": "qurltlds_p.h", + "QtUsage": "Used in Qt Core to avoid \"supercookies\" being set in the cookie jar +supported by Qt (by the QNetworkCookieJar class).", + + "Homepage": "http://publicsuffix.org/", + "Version": "Generated on 2016-10-20 from revision 915565885d0fbd25caf7d8b339cd3478f558da94", + "License": "Mozilla Public License 2.0", + "LicenseFile": "PSL-LICENSE.txt", + "LicenseId": "MPL-2.0", + "Copyright": "The list was originally provided by Jo Hermans . +It is now maintained on github (https://github.com/publicsuffix/list)." } +] diff --git a/src/corelib/io/qurltlds_p.h.INFO b/src/corelib/io/qurltlds_p.h.INFO index 3f3d808a21..33ccd458bf 100644 --- a/src/corelib/io/qurltlds_p.h.INFO +++ b/src/corelib/io/qurltlds_p.h.INFO @@ -9,9 +9,6 @@ Those arrays in qurltlds_p.h are derived from the Public Suffix List ([2]), which was originally provided by Jo Hermans . -The file qurltlds_p.h was last generated Thursday, -October 20th 8:40 2016. - ---- [1] list: http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1 [2] homepage: http://publicsuffix.org/ -- cgit v1.2.3 From b6f4003b87c92061cc5ef22f40f844ae16bf09bb Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 17 Nov 2016 15:48:17 +0100 Subject: Fix forkfd 3rd party documenation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bring the copyright lines in the license and the one's in the metadata into line by using the ones from forkfd.c. Also bring back description of forkfd from 5.6 documentation. Change-Id: I423ee8d5d1e1c866a34c346f78520d33ea099b5e Reviewed-by: Topi Reiniö --- src/3rdparty/forkfd/LICENSE | 1 + src/3rdparty/forkfd/qt_attribution.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty/forkfd/LICENSE b/src/3rdparty/forkfd/LICENSE index 351ebf705d..36ab612951 100644 --- a/src/3rdparty/forkfd/LICENSE +++ b/src/3rdparty/forkfd/LICENSE @@ -1,4 +1,5 @@ Copyright (C) 2016 Intel Corporation. +Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/3rdparty/forkfd/qt_attribution.json b/src/3rdparty/forkfd/qt_attribution.json index 89f25f4870..f004116753 100644 --- a/src/3rdparty/forkfd/qt_attribution.json +++ b/src/3rdparty/forkfd/qt_attribution.json @@ -7,6 +7,6 @@ "License": "MIT License", "LicenseId": "MIT", "LicenseFile": "LICENSE", - "Copyright": "Copyright (C) 2013-2016 Intel Corporation + "Copyright": "Copyright (C) 2016 Intel Corporation Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com" } -- cgit v1.2.3 From b200bc662ee0e593306a2a96a89b57d0e340d2c3 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 17 Nov 2016 15:58:44 +0100 Subject: Improve documentation for 3rdparty freebsd code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iad5c659c2c422bf20e7ba6161889c7b261512e9e Reviewed-by: Topi Reiniö --- src/3rdparty/freebsd/qt_attribution.json | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/3rdparty/freebsd/qt_attribution.json b/src/3rdparty/freebsd/qt_attribution.json index 40c337cc67..57f425cdbc 100644 --- a/src/3rdparty/freebsd/qt_attribution.json +++ b/src/3rdparty/freebsd/qt_attribution.json @@ -4,14 +4,10 @@ "QDocModule": "qtcore", "QtUsage": "Used in Qt Core.", + "Description": "strtoll() and strtoull() are functions for converting a string to (unsigned) long long integer.", "License": "BSD 3-clause \"New\" or \"Revised\" License", "LicenseId": "BSD-3-Clause", "LicenseFile": "LICENSE", - "Copyright": "Copyright (c) 1992, 1993 - The Regents of the University of California. All rights reserved. - -Copyright (c) 2011 The FreeBSD Foundation -All rights reserved. -Portions of this software were developed by David Chisnall -under sponsorship from the FreeBSD Foundation." + "Copyright": "Copyright (c) 1992, 1993 The Regents of the University of California. +Copyright (c) 2011 The FreeBSD Foundation" } -- cgit v1.2.3 From 7611028879c81e5072ed96301d7f392a74d7e42c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 22 Nov 2016 15:39:28 +0100 Subject: List ANGLE contributions after another MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Place ANGLE at the start of the title, so that the different entries are sorted correctly. Change-Id: I11e9d25874f06450a3d9049b5f5c94aa53621e08 Reviewed-by: Topi Reiniö --- src/3rdparty/angle/qt_attribution.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/3rdparty/angle/qt_attribution.json b/src/3rdparty/angle/qt_attribution.json index 230f30940b..e35e1f0eb9 100644 --- a/src/3rdparty/angle/qt_attribution.json +++ b/src/3rdparty/angle/qt_attribution.json @@ -12,7 +12,7 @@ }, { "Id": "angle-arrayboundsclamper", - "Name": "ANGLE Array Bounds Clamper for WebKit", + "Name": "ANGLE: Array Bounds Clamper for WebKit", "QDocModule": "qtgui", "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.", @@ -25,7 +25,7 @@ }, { "Id": "angle-murmurhash", - "Name": "Murmurhash (as part of ANGLE)", + "Name": "ANGLE: Murmurhash", "QDocModule": "qtgui", "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.", @@ -36,7 +36,7 @@ }, { "Id": "angle-systeminfo", - "Name": "Systeminfo (as part of ANGLE)", + "Name": "ANGLE: Systeminfo", "QDocModule": "qtgui", "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.", @@ -48,7 +48,7 @@ }, { "Id": "angle-trace_event", - "Name": "trace_event (as part of ANGLE)", + "Name": "ANGLE: trace_event", "QDocModule": "qtgui", "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.", -- cgit v1.2.3 From a5cf8d76c265913864298b78fadda61889a1babe Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 1 Nov 2016 15:28:12 +0100 Subject: Remove second mentioning of cycle.h 3rdparty license MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is now documented in the qt_attribution.json file added in commit 41a7d74385eece725435159ca021151e871bf116 . Change-Id: I4f13397a14de7d9f98ba146cabf64dafac5dada4 Reviewed-by: Topi Reiniö --- src/testlib/doc/src/qttestlib-manual.qdoc | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'src') diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index d775ae5b76..6bdf6c33c7 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -361,35 +361,6 @@ See \l {Chapter 5: Writing a Benchmark}{Writing a Benchmark} in the Qt Test Tutorial for more benchmarking examples. - - \section1 3rd Party Code - - The CPU tick counters used for benchmarking are licensed under the following - license: (from src/testlib/3rdparty/cycle.h) - - \legalese - Copyright (c) 2003, 2006 Matteo Frigo\br - Copyright (c) 2003, 2006 Massachusetts Institute of Technology - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - \endlegalese */ /*! -- cgit v1.2.3 From 9204b8c31ea1b5f0c05870c5b5d74c33b1a4f622 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 7 Nov 2016 14:37:58 +0100 Subject: Register fonts with preferred names on Windows Looks up the canonical names of enumerated fonts and register them under their preferred names if present. Also changes the logic handling registration of english aliases, so it is always done, even if it might in rare cases cause a double registration since that is safe. Task-number: QTBUG-53458 Change-Id: Ia010774b26072192b55697b717cc37442c852881 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/windows/qwindowsfontdatabase.cpp | 217 +++++++++++---------- .../windows/qwindowsfontdatabase_ft.cpp | 105 +++++----- .../fontdatabases/windows/qwindowsfontdatabase_p.h | 25 ++- .../fontdatabases/windows/qwindowsfontengine.cpp | 16 +- .../direct2d/qwindowsdirect2dpaintengine.cpp | 2 +- 5 files changed, 190 insertions(+), 175 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index b8d997bc35..1c615e06ed 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -759,7 +759,7 @@ static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSe ((quint32)(ch1)) \ ) -bool localizedName(const QString &name) +bool qt_localizedName(const QString &name) { const QChar *c = name.unicode(); for (int i = 0; i < name.length(); ++i) { @@ -769,24 +769,8 @@ bool localizedName(const QString &name) return false; } -static inline quint16 getUShort(const unsigned char *p) -{ - quint16 val; - val = *p++ << 8; - val |= *p; - - return val; -} - namespace { -struct FontNames { - QString name; // e.g. "DejaVu Sans Condensed" - QString style; // e.g. "Italic" - QString preferredName; // e.g. "DejaVu Sans" - QString preferredStyle; // e.g. "Condensed Italic" -}; - static QString readName(bool unicode, const uchar *string, int length) { QString out; @@ -797,7 +781,7 @@ static QString readName(bool unicode, const uchar *string, int length) out.resize(length); QChar *uc = out.data(); for (int i = 0; i < length; ++i) - uc[i] = getUShort(string + 2*i); + uc[i] = qt_getUShort(string + 2*i); } else { // Apple Roman @@ -822,7 +806,7 @@ enum PlatformFieldValue { PlatformId_Microsoft = 3 }; -static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes) +FontNames qt_getCanonicalFontNames(const uchar *table, quint32 bytes) { FontNames out; const int NameRecordSize = 12; @@ -836,11 +820,11 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes) if (bytes < 8) return out; - if (getUShort(table) != 0) + if (qt_getUShort(table) != 0) return out; - count = getUShort(table+2); - string_offset = getUShort(table+4); + count = qt_getUShort(table + 2); + string_offset = qt_getUShort(table + 4); names = table + 6; if (string_offset >= bytes || 6 + count*NameRecordSize > string_offset) @@ -859,10 +843,10 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes) for (int i = 0; i < count; ++i) { // search for the correct name entries - quint16 platform_id = getUShort(names + i*NameRecordSize); - quint16 encoding_id = getUShort(names + 2 + i*NameRecordSize); - quint16 language_id = getUShort(names + 4 + i*NameRecordSize); - quint16 name_id = getUShort(names + 6 + i*NameRecordSize); + quint16 platform_id = qt_getUShort(names + i*NameRecordSize); + quint16 encoding_id = qt_getUShort(names + 2 + i*NameRecordSize); + quint16 language_id = qt_getUShort(names + 4 + i*NameRecordSize); + quint16 name_id = qt_getUShort(names + 6 + i*NameRecordSize); PlatformIdType *idType = nullptr; int *id = nullptr; @@ -888,8 +872,8 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes) continue; } - quint16 length = getUShort(names + 8 + i*NameRecordSize); - quint16 offset = getUShort(names + 10 + i*NameRecordSize); + quint16 length = qt_getUShort(names + 8 + i*NameRecordSize); + quint16 offset = qt_getUShort(names + 10 + i*NameRecordSize); if (DWORD(string_offset + offset + length) > bytes) continue; @@ -916,8 +900,8 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes) if (idStatus[i] == NotFound) continue; int id = ids[i]; - quint16 length = getUShort(names + 8 + id * NameRecordSize); - quint16 offset = getUShort(names + 10 + id * NameRecordSize); + quint16 length = qt_getUShort(names + 8 + id * NameRecordSize); + quint16 offset = qt_getUShort(names + 10 + id * NameRecordSize); const unsigned char *string = table + string_offset + offset; strings[i] = readName(idStatus[i] != Apple, string, length); } @@ -931,7 +915,7 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes) } // namespace -QString getEnglishName(const QString &familyName, bool includeStyle = false) +QString qt_getEnglishName(const QString &familyName, bool includeStyle) { QString i18n_name; QString faceName = familyName; @@ -970,7 +954,7 @@ QString getEnglishName(const QString &familyName, bool includeStyle = false) goto error; { - const FontNames names = getCanonicalFontNames(table, bytes); + const FontNames names = qt_getCanonicalFontNames(table, bytes); i18n_name = names.name; if (includeStyle) i18n_name += QLatin1Char(' ') + names.style; @@ -985,16 +969,63 @@ error: return i18n_name; } -static bool addFontToDatabase(const QString &familyName, const QString &styleName, uchar charSet, +// Note this duplicates parts of qt_getEnglishName, we should try to unify the two functions. +FontNames qt_getCanonicalFontNames(const LOGFONT &lf) +{ + FontNames fontNames; + HDC hdc = GetDC(0); + HFONT hfont = CreateFontIndirect(&lf); + + if (!hfont) { + ReleaseDC(0, hdc); + return fontNames; + } + + HGDIOBJ oldobj = SelectObject(hdc, hfont); + + // get the name table + QByteArray table; + const DWORD name_tag = MAKE_TAG('n', 'a', 'm', 'e'); + DWORD bytes = GetFontData(hdc, name_tag, 0, 0, 0); + if (bytes != GDI_ERROR) { + table.resize(bytes); + + if (GetFontData(hdc, name_tag, 0, table.data(), bytes) != GDI_ERROR) + fontNames = qt_getCanonicalFontNames(reinterpret_cast(table.constData()), bytes); + } + + SelectObject(hdc, oldobj); + DeleteObject(hfont); + ReleaseDC(0, hdc); + + return fontNames; +} + +static QChar *createFontFile(const QString &faceName) +{ + QChar *faceNamePtr = nullptr; + if (!faceName.isEmpty()) { + const int nameLength = qMin(faceName.length(), LF_FACESIZE - 1); + faceNamePtr = new QChar[nameLength + 1]; + memcpy(faceNamePtr, faceName.utf16(), sizeof(wchar_t) * nameLength); + faceNamePtr[nameLength] = 0; + } + return faceNamePtr; +} + +static bool addFontToDatabase(QString familyName, + QString styleName, + const LOGFONT &logFont, const TEXTMETRIC *textmetric, const FONTSIGNATURE *signature, - int type, - bool registerAlias) + int type) { // the "@family" fonts are just the same as "family". Ignore them. if (familyName.isEmpty() || familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QLatin1String("WST_"))) return false; + uchar charSet = logFont.lfCharSet; + static const int SMOOTH_SCALABLE = 0xffff; const QString foundryName; // No such concept. const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH); @@ -1023,10 +1054,24 @@ static bool addFontToDatabase(const QString &familyName, const QString &styleNam qCDebug(lcQpaFonts) << message; } #endif - QString englishName; - if (registerAlias && ttf && localizedName(familyName)) - englishName = getEnglishName(familyName); + QString faceName; + + QString subFamilyName; + QString subFamilyStyle; + if (ttf) { + // Look-up names registered in the font + FontNames canonicalNames = qt_getCanonicalFontNames(logFont); + if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) + englishName = canonicalNames.name; + if (!canonicalNames.preferredName.isEmpty()) { + subFamilyName = familyName; + subFamilyStyle = styleName; + faceName = familyName; // Remember the original name for later lookups + familyName = canonicalNames.preferredName; + styleName = canonicalNames.preferredStyle; + } + } QSupportedWritingSystems writingSystems; if (type & TRUETYPE_FONTTYPE) { @@ -1054,32 +1099,36 @@ static bool addFontToDatabase(const QString &familyName, const QString &styleNam } QPlatformFontDatabase::registerFont(familyName, styleName, foundryName, weight, - style, stretch, antialias, scalable, size, fixed, writingSystems, 0); + style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName)); + // add fonts windows can generate for us: if (weight <= QFont::DemiBold && styleName.isEmpty()) QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, - style, stretch, antialias, scalable, size, fixed, writingSystems, 0); + style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName)); if (style != QFont::StyleItalic && styleName.isEmpty()) QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight, - QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, 0); + QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName)); if (weight <= QFont::DemiBold && style != QFont::StyleItalic && styleName.isEmpty()) QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, - QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, 0); + QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName)); - if (!englishName.isEmpty()) + if (!subFamilyName.isEmpty() && familyName != subFamilyName) { + QPlatformFontDatabase::registerFont(subFamilyName, subFamilyStyle, foundryName, weight, + style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName)); + } + + if (!englishName.isEmpty() && englishName != familyName) QPlatformFontDatabase::registerAliasToFontFamily(familyName, englishName); return true; } static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric, - DWORD type, LPARAM lParam) + DWORD type, LPARAM) { const ENUMLOGFONTEX *f = reinterpret_cast(logFont); const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName); const QString styleName = QString::fromWCharArray(f->elfStyle); - const uchar charSet = f->elfLogFont.lfCharSet; - const bool registerAlias = bool(lParam); // NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according // to the documentation is identical to a TEXTMETRIC except for the last four @@ -1087,13 +1136,13 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t const FONTSIGNATURE *signature = Q_NULLPTR; if (type & TRUETYPE_FONTTYPE) signature = &reinterpret_cast(textmetric)->ntmFontSig; - addFontToDatabase(familyName, styleName, charSet, textmetric, signature, type, registerAlias); + addFontToDatabase(familyName, styleName, *logFont, textmetric, signature, type); // keep on enumerating return 1; } -void QWindowsFontDatabase::populateFamily(const QString &familyName, bool registerAlias) +void QWindowsFontDatabase::populateFamily(const QString &familyName) { qCDebug(lcQpaFonts) << familyName; if (familyName.size() >= LF_FACESIZE) { @@ -1106,29 +1155,12 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName, bool regist familyName.toWCharArray(lf.lfFaceName); lf.lfFaceName[familyName.size()] = 0; lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, storeFont, LPARAM(registerAlias), 0); + EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0); ReleaseDC(0, dummy); } -void QWindowsFontDatabase::populateFamily(const QString &familyName) -{ - populateFamily(familyName, false); -} - -namespace { -// Context for enumerating system fonts, records whether the default font has been encountered, -// which is normally not enumerated by EnumFontFamiliesEx(). -struct PopulateFamiliesContext -{ - PopulateFamiliesContext(const QString &f) : systemDefaultFont(f), seenSystemDefaultFont(false) {} - - QString systemDefaultFont; - bool seenSystemDefaultFont; -}; -} // namespace - -static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric, - DWORD, LPARAM lparam) +static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *, + DWORD, LPARAM) { // the "@family" fonts are just the same as "family". Ignore them. const ENUMLOGFONTEX *f = reinterpret_cast(logFont); @@ -1136,22 +1168,6 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) { const QString faceName = QString::fromWCharArray(faceNameW); QPlatformFontDatabase::registerFontFamily(faceName); - PopulateFamiliesContext *context = reinterpret_cast(lparam); - if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont) - context->seenSystemDefaultFont = true; - - // Register current font's english name as alias - const bool ttf = textmetric->tmPitchAndFamily & TMPF_TRUETYPE; - if (ttf && localizedName(faceName)) { - const QString englishName = getEnglishName(faceName); - if (!englishName.isEmpty()) { - QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName); - // Check whether the system default font name is an alias of the current font family name, - // as on Chinese Windows, where the system font "SimSun" is an alias to a font registered under a local name - if (!context->seenSystemDefaultFont && englishName == context->systemDefaultFont) - context->seenSystemDefaultFont = true; - } - } } return 1; // continue } @@ -1164,12 +1180,10 @@ void QWindowsFontDatabase::populateFontDatabase() lf.lfCharSet = DEFAULT_CHARSET; lf.lfFaceName[0] = 0; lf.lfPitchAndFamily = 0; - PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family()); - EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, reinterpret_cast(&context), 0); + EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0); ReleaseDC(0, dummy); // Work around EnumFontFamiliesEx() not listing the system font. - if (!context.seenSystemDefaultFont) - QPlatformFontDatabase::registerFontFamily(context.systemDefaultFont); + QPlatformFontDatabase::registerFontFamily(QWindowsFontDatabase::systemDefaultFont().family()); } typedef QSharedPointer QWindowsFontEngineDataPtr; @@ -1228,7 +1242,8 @@ QFontEngineMulti *QWindowsFontDatabase::fontEngineMulti(QFontEngine *fontEngine, QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef, void *handle) { - QFontEngine *fe = QWindowsFontDatabase::createEngine(fontDef, + const QString faceName(static_cast(handle)); + QFontEngine *fe = QWindowsFontDatabase::createEngine(fontDef, faceName, defaultVerticalDPI(), sharedFontData()); qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef << fe << handle; @@ -1282,7 +1297,7 @@ QT_WARNING_POP request.hintingPreference = hintingPreference; request.stretch = QFont::Unstretched; - fontEngine = QWindowsFontDatabase::createEngine(request, + fontEngine = QWindowsFontDatabase::createEngine(request, QString(), defaultVerticalDPI(), sharedFontData()); @@ -1461,7 +1476,7 @@ static void getFamiliesAndSignatures(const QByteArray &fontData, getFontTable(data, font, MAKE_TAG('n', 'a', 'm', 'e'), &table, &length); if (!table) continue; - FontNames names = getCanonicalFontNames(table, length); + FontNames names = qt_getCanonicalFontNames(table, length); if (names.name.isEmpty()) continue; @@ -1523,8 +1538,8 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, TEXTMETRIC textMetrics; GetTextMetrics(hdc, &textMetrics); - addFontToDatabase(familyName, styleName, lf.lfCharSet, &textMetrics, &signatures.at(j), - TRUETYPE_FONTTYPE, true); + addFontToDatabase(familyName, styleName, lf, &textMetrics, &signatures.at(j), + TRUETYPE_FONTTYPE); SelectObject(hdc, oldobj); DeleteObject(hfont); @@ -1550,7 +1565,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, for (int j = 0; j < families.count(); ++j) { const QString familyName = families.at(j).name; familyNames << familyName; - populateFamily(familyName, true); + populateFamily(familyName); } } @@ -1571,8 +1586,10 @@ void QWindowsFontDatabase::removeApplicationFonts() m_applicationFonts.clear(); } -void QWindowsFontDatabase::releaseHandle(void * /* handle */) +void QWindowsFontDatabase::releaseHandle(void *handle) { + const QChar *faceName = reinterpret_cast(handle); + delete[] faceName; } QString QWindowsFontDatabase::fontDir() const @@ -1663,7 +1680,7 @@ static const char *kr_tryFonts[] = { static const char **tryFonts = 0; -LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request) +LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request, const QString &faceName) { LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); @@ -1738,7 +1755,9 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request) lf.lfPitchAndFamily = DEFAULT_PITCH | hint; - QString fam = request.family; + QString fam = faceName; + if (fam.isEmpty()) + fam = request.family; if (Q_UNLIKELY(fam.size() >= LF_FACESIZE)) { qCritical("%s: Family name '%s' is too long.", __FUNCTION__, qPrintable(fam)); fam.truncate(LF_FACESIZE - 1); @@ -1837,13 +1856,13 @@ QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFon } -QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, +QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const QString &faceName, int dpi, const QSharedPointer &data) { QFontEngine *fe = 0; - LOGFONT lf = fontDefToLOGFONT(request); + LOGFONT lf = fontDefToLOGFONT(request, faceName); const bool preferClearTypeAA = lf.lfQuality == CLEARTYPE_QUALITY; if (request.stretch != 100) { diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp index 4d973bbf17..df84198862 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp @@ -100,9 +100,6 @@ static FontFile * createFontFile(const QString &fileName, int index) return fontFile; } -extern bool localizedName(const QString &name); -extern QString getEnglishName(const QString &familyName, bool includeStyle = false); - namespace { struct FontKey { @@ -162,19 +159,20 @@ static const FontKey *findFontKey(const QString &name, int *indexIn = Q_NULLPTR) return Q_NULLPTR; } -static bool addFontToDatabase(const QString &faceName, - const QString &styleName, +static bool addFontToDatabase(QString familyName, + QString styleName, const QString &fullName, - uchar charSet, + const LOGFONT &logFont, const TEXTMETRIC *textmetric, const FONTSIGNATURE *signature, - int type, - bool registerAlias) + int type) { // the "@family" fonts are just the same as "family". Ignore them. - if (faceName.isEmpty() || faceName.at(0) == QLatin1Char('@') || faceName.startsWith(QLatin1String("WST_"))) + if (familyName.isEmpty() || familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QLatin1String("WST_"))) return false; + uchar charSet = logFont.lfCharSet; + static const int SMOOTH_SCALABLE = 0xffff; const QString foundryName; // No such concept. const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH); @@ -190,7 +188,7 @@ static bool addFontToDatabase(const QString &faceName, if (lcQpaFonts().isDebugEnabled()) { QString message; QTextStream str(&message); - str << __FUNCTION__ << ' ' << faceName << "::" << fullName << ' ' << charSet << " TTF=" << ttf; + str << __FUNCTION__ << ' ' << familyName << "::" << fullName << ' ' << charSet << " TTF=" << ttf; if (type & DEVICE_FONTTYPE) str << " DEVICE"; if (type & RASTER_FONTTYPE) @@ -205,8 +203,22 @@ static bool addFontToDatabase(const QString &faceName, #endif QString englishName; - if (registerAlias & ttf && localizedName(faceName)) - englishName = getEnglishName(faceName); + QString faceName = familyName; + + QString subFamilyName; + QString subFamilyStyle; + if (ttf) { + // Look-up names registered in the font + FontNames canonicalNames = qt_getCanonicalFontNames(logFont); + if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) + englishName = canonicalNames.name; + if (!canonicalNames.preferredName.isEmpty()) { + subFamilyName = familyName; + subFamilyStyle = styleName; + familyName = canonicalNames.preferredName; + styleName = canonicalNames.preferredStyle; + } + } QSupportedWritingSystems writingSystems; if (type & TRUETYPE_FONTTYPE) { @@ -243,12 +255,10 @@ static bool addFontToDatabase(const QString &faceName, && systemLocale.language() != QLocale::English && styleName != QLatin1String("Italic") && styleName != QLatin1String("Bold")) { - key = findFontKey(getEnglishName(fullName, true), &index); + key = findFontKey(qt_getEnglishName(fullName, true), &index); } if (!key) key = findFontKey(faceName, &index); - if (!key && !registerAlias && englishName.isEmpty() && localizedName(faceName)) - englishName = getEnglishName(faceName); if (!key && !englishName.isEmpty()) key = findFontKey(englishName, &index); if (!key) @@ -261,24 +271,29 @@ static bool addFontToDatabase(const QString &faceName, if (!QDir::isAbsolutePath(value)) value.prepend(QFile::decodeName(qgetenv("windir") + "\\Fonts\\")); - QPlatformFontDatabase::registerFont(faceName, styleName, foundryName, weight, style, stretch, + QPlatformFontDatabase::registerFont(familyName, styleName, foundryName, weight, style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(value, index)); // add fonts windows can generate for us: if (weight <= QFont::DemiBold && styleName.isEmpty()) - QPlatformFontDatabase::registerFont(faceName, QString(), foundryName, QFont::Bold, style, stretch, + QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(value, index)); if (style != QFont::StyleItalic && styleName.isEmpty()) - QPlatformFontDatabase::registerFont(faceName, QString(), foundryName, weight, QFont::StyleItalic, stretch, + QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight, QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(value, index)); if (weight <= QFont::DemiBold && style != QFont::StyleItalic && styleName.isEmpty()) - QPlatformFontDatabase::registerFont(faceName, QString(), foundryName, QFont::Bold, QFont::StyleItalic, stretch, + QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(value, index)); - if (!englishName.isEmpty()) - QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName); + if (!subFamilyName.isEmpty() && familyName != subFamilyName) { + QPlatformFontDatabase::registerFont(subFamilyName, subFamilyStyle, foundryName, weight, + style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(value, index)); + } + + if (!englishName.isEmpty() && englishName != familyName) + QPlatformFontDatabase::registerAliasToFontFamily(familyName, englishName); return true; } @@ -290,7 +305,6 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t const QString faceName = QString::fromWCharArray(f->elfLogFont.lfFaceName); const QString styleName = QString::fromWCharArray(f->elfStyle); const QString fullName = QString::fromWCharArray(f->elfFullName); - const uchar charSet = f->elfLogFont.lfCharSet; // NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according // to the documentation is identical to a TEXTMETRIC except for the last four @@ -298,7 +312,7 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t const FONTSIGNATURE *signature = Q_NULLPTR; if (type & TRUETYPE_FONTTYPE) signature = &reinterpret_cast(textmetric)->ntmFontSig; - addFontToDatabase(faceName, styleName, fullName, charSet, textmetric, signature, type, false); + addFontToDatabase(faceName, styleName, fullName, *logFont, textmetric, signature, type); // keep on enumerating return 1; @@ -321,30 +335,19 @@ void QWindowsFontDatabaseFT::populateFamily(const QString &familyName) } HDC dummy = GetDC(0); LOGFONT lf; - lf.lfCharSet = DEFAULT_CHARSET; + memset(&lf, 0, sizeof(LOGFONT)); familyName.toWCharArray(lf.lfFaceName); lf.lfFaceName[familyName.size()] = 0; + lf.lfCharSet = DEFAULT_CHARSET; lf.lfPitchAndFamily = 0; EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0); ReleaseDC(0, dummy); } -namespace { -// Context for enumerating system fonts, records whether the default font has been -// encountered, which is normally not enumerated. -struct PopulateFamiliesContext -{ - PopulateFamiliesContext(const QString &f) : systemDefaultFont(f), seenSystemDefaultFont(false) {} - - QString systemDefaultFont; - bool seenSystemDefaultFont; -}; -} // namespace - // Delayed population of font families static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric, - DWORD, LPARAM lparam) + DWORD, LPARAM) { const ENUMLOGFONTEX *f = reinterpret_cast(logFont); // the "@family" fonts are just the same as "family". Ignore them. @@ -356,27 +359,11 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE const FontKey *key = findFontKey(faceName); if (!key) { key = findFontKey(QString::fromWCharArray(f->elfFullName)); - if (!key && ttf && localizedName(faceName)) - key = findFontKey(getEnglishName(faceName)); + if (!key && ttf && qt_localizedName(faceName)) + key = findFontKey(qt_getEnglishName(faceName)); } - if (key) { + if (key) QPlatformFontDatabase::registerFontFamily(faceName); - PopulateFamiliesContext *context = reinterpret_cast(lparam); - if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont) - context->seenSystemDefaultFont = true; - - // Register current font's english name as alias - if (ttf && localizedName(faceName)) { - const QString englishName = getEnglishName(faceName); - if (!englishName.isEmpty()) { - QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName); - // Check whether the system default font name is an alias of the current font family name, - // as on Chinese Windows, where the system font "SimSun" is an alias to a font registered under a local name - if (!context->seenSystemDefaultFont && englishName == context->systemDefaultFont) - context->seenSystemDefaultFont = true; - } - } - } } return 1; // continue } @@ -388,12 +375,10 @@ void QWindowsFontDatabaseFT::populateFontDatabase() lf.lfCharSet = DEFAULT_CHARSET; lf.lfFaceName[0] = 0; lf.lfPitchAndFamily = 0; - PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family()); - EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, reinterpret_cast(&context), 0); + EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0); ReleaseDC(0, dummy); // Work around EnumFontFamiliesEx() not listing the system font - if (!context.seenSystemDefaultFont) - QPlatformFontDatabase::registerFontFamily(context.systemDefaultFont); + QPlatformFontDatabase::registerFontFamily(QWindowsFontDatabase::systemDefaultFont().family()); } QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, void *handle) diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h index b7ebfc033f..325f522335 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h @@ -112,7 +112,7 @@ public: static QFont systemDefaultFont(); - static QFontEngine *createEngine(const QFontDef &request, + static QFontEngine *createEngine(const QFontDef &request, const QString &faceName, int dpi, const QSharedPointer &data); @@ -120,7 +120,7 @@ public: static QFont LOGFONT_to_QFont(const LOGFONT& lf, int verticalDPI = 0); static qreal fontSmoothingGamma(); - static LOGFONT fontDefToLOGFONT(const QFontDef &fontDef); + static LOGFONT fontDefToLOGFONT(const QFontDef &fontDef, const QString &faceName); static QStringList extraTryFontsForFamily(const QString &family); static QString familyForStyleHint(QFont::StyleHint styleHint); @@ -133,7 +133,6 @@ public: static QString readRegistryString(HKEY parentHandle, const wchar_t *keyPath, const wchar_t *keyName); private: - void populateFamily(const QString &familyName, bool registerAlias); void removeApplicationFonts(); struct WinApplicationFont { @@ -157,6 +156,26 @@ private: QDebug operator<<(QDebug, const QFontDef &def); #endif +inline quint16 qt_getUShort(const unsigned char *p) +{ + quint16 val; + val = *p++ << 8; + val |= *p; + + return val; +} + +struct FontNames { + QString name; // e.g. "DejaVu Sans Condensed" + QString style; // e.g. "Italic" + QString preferredName; // e.g. "DejaVu Sans" + QString preferredStyle; // e.g. "Condensed Italic" +}; + +bool qt_localizedName(const QString &name); +QString qt_getEnglishName(const QString &familyName, bool includeStyle = false); +FontNames qt_getCanonicalFontNames(const LOGFONT &lf); + QT_END_NAMESPACE #endif // QWINDOWSFONTDATABASE_H diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp index 9fc6fec915..0cd473e020 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp @@ -97,15 +97,6 @@ static void resolveGetCharWidthI() ptrGetCharWidthI = (PtrGetCharWidthI)QSystemLibrary::resolve(QStringLiteral("gdi32"), "GetCharWidthI"); } -static inline quint16 getUShort(unsigned char *p) -{ - quint16 val; - val = *p++ << 8; - val |= *p; - - return val; -} - // general font engine QFixed QWindowsFontEngine::lineThickness() const @@ -912,7 +903,7 @@ int QWindowsFontEngine::synthesized() const SelectObject(hdc, hfont); uchar data[4]; GetFontData(hdc, HEAD, 44, &data, 4); - USHORT macStyle = getUShort(data); + USHORT macStyle = qt_getUShort(data); if (tm.tmItalic && !(macStyle & 2)) synthesized_flags = SynthesizedItalic; if (fontDef.stretch != 100 && ttf) @@ -1192,9 +1183,10 @@ QFontEngine *QWindowsFontEngine::cloneWithSize(qreal pixelSize) const if (!uniqueFamilyName.isEmpty()) request.family = uniqueFamilyName; request.pixelSize = pixelSize; + const QString faceName = QString::fromWCharArray(m_logfont.lfFaceName); QFontEngine *fontEngine = - QWindowsFontDatabase::createEngine(request, + QWindowsFontDatabase::createEngine(request, faceName, QWindowsFontDatabase::defaultVerticalDPI(), m_fontEngineData); if (fontEngine) { @@ -1257,7 +1249,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at) #ifndef QT_NO_DIRECTWRITE if (fontEngine->type() == QFontEngine::DirectWrite) { QWindowsFontEngineDirectWrite *fe = static_cast(fontEngine); - lf = QWindowsFontDatabase::fontDefToLOGFONT(fe->fontDef); + lf = QWindowsFontDatabase::fontDefToLOGFONT(fe->fontDef, QString()); data = fe->fontEngineData(); } else diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp index 69d2e12778..c4ff937a0b 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp @@ -1037,7 +1037,7 @@ public: if (fontFace) return fontFace; - LOGFONT lf = QWindowsFontDatabase::fontDefToLOGFONT(fontDef); + LOGFONT lf = QWindowsFontDatabase::fontDefToLOGFONT(fontDef, QString()); // Get substitute name static const char keyC[] = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes"; -- cgit v1.2.3 From 7e9aca683abf1360e3d20dfebdd937b2594c94b2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 18 Nov 2016 09:50:22 +0100 Subject: De-duplicate the systemsemaphore entry Change-Id: Id015cfe60956d899bbb58597b88204738578b7fe Reviewed-by: Oswald Buddenhagen --- src/corelib/configure.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index e7eb5fe482..76b6612a5d 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -372,11 +372,6 @@ "condition": "tests.syslog", "output": [ "privateConfig" ] }, - "systemsemaphore": { - "label": "Enable QSystemSemaphore", - "condition": "config.android || config.win32 || tests.ipc_sysv || tests.ipc_posix", - "output": [ { "type": "define", "negative": true, "name": "QT_NO_SYSTEMSEMAPHORE" } ] - }, "threadsafe-cloexec": { "label": "Threadsafe pipe creation", "condition": "tests.cloexec", @@ -407,6 +402,7 @@ "label": "QSystemSemaphore", "purpose": "Provides a general counting system semaphore.", "section": "Kernel", + "condition": "config.android || config.win32 || tests.ipc_sysv || tests.ipc_posix", "output": [ "publicFeature", "feature" ] }, "xmlstream": { -- cgit v1.2.3 From fd9e5d90333c385ad191a289b2e95e918c58b242 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 22 Nov 2016 10:13:41 +0100 Subject: Clean up iconv configuration Turn iconv off if ICU is being used (in line with codecs.pri) and get rid of the DEFINES += GNU_LIBICONV in the pri file. Change-Id: I6fbca975498adbb3e67f913ae9b1dd5cc53ee8da Reviewed-by: Oswald Buddenhagen --- src/corelib/codecs/codecs.pri | 6 +----- src/corelib/codecs/qiconvcodec.cpp | 14 +++++++------- src/corelib/codecs/qiconvcodec_p.h | 4 +--- src/corelib/codecs/qtextcodec.cpp | 6 +++--- src/corelib/configure.json | 8 ++++---- src/corelib/global/qconfig-bootstrapped.h | 1 + 6 files changed, 17 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri index 4fa778d042..dc8974d13f 100644 --- a/src/corelib/codecs/codecs.pri +++ b/src/corelib/codecs/codecs.pri @@ -43,12 +43,8 @@ qtConfig(icu) { qtConfig(iconv) { HEADERS += codecs/qiconvcodec_p.h SOURCES += codecs/qiconvcodec.cpp - qtConfig(gnu-libiconv) { - DEFINES += GNU_LIBICONV + qtConfig(gnu-libiconv): \ QMAKE_USE_PRIVATE += iconv - } else: qtConfig(sun-libiconv) { - DEFINES += GNU_LIBICONV - } } win32 { diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 845155dce0..8961d01eee 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -37,7 +37,9 @@ ** ****************************************************************************/ -#ifndef QT_NO_ICONV +#include + +QT_REQUIRE_CONFIG(iconv); #include "qiconvcodec_p.h" #include "qtextcodec_p.h" @@ -221,7 +223,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState IconvState *state = *pstate; size_t inBytesLeft = len; // best case assumption, each byte is converted into one UTF-16 character, plus 2 bytes for the BOM -#ifdef GNU_LIBICONV +#if !QT_CONFIG(posix_libiconv) // GNU doesn't disagree with POSIX :/ const char *inBytes = chars; #else @@ -320,7 +322,7 @@ static bool setByteOrder(iconv_t cd) size_t outBytesLeft = sizeof buf; size_t inBytesLeft = sizeof bom; -#if defined(GNU_LIBICONV) +#if !QT_CONFIG(posix_libiconv) const char **inBytesPtr = const_cast(&inBytes); #else char **inBytesPtr = &inBytes; @@ -342,7 +344,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt char *outBytes; size_t inBytesLeft; -#if defined(GNU_LIBICONV) +#if !QT_CONFIG(posix_libiconv) const char **inBytesPtr = const_cast(&inBytes); #else char **inBytesPtr = &inBytes; @@ -472,7 +474,7 @@ iconv_t QIconvCodec::createIconv_t(const char *to, const char *from) const init(); iconv_t cd = (iconv_t) -1; -#if defined(__GLIBC__) || defined(GNU_LIBICONV) || defined(Q_OS_QNX) +#if defined(__GLIBC__) || !QT_CONFIG(posix_libiconv) || defined(Q_OS_QNX) #if defined(Q_OS_QNX) // on QNX the default locale is UTF-8, and an empty string will cause iconv_open to fail static const char empty_codeset[] = "UTF-8"; @@ -562,5 +564,3 @@ iconv_t QIconvCodec::createIconv_t(const char *to, const char *from) const } QT_END_NAMESPACE - -#endif /* #ifndef QT_NO_ICONV */ diff --git a/src/corelib/codecs/qiconvcodec_p.h b/src/corelib/codecs/qiconvcodec_p.h index 238351bc81..d99e72f635 100644 --- a/src/corelib/codecs/qiconvcodec_p.h +++ b/src/corelib/codecs/qiconvcodec_p.h @@ -54,7 +54,7 @@ #include #include "qtextcodec.h" -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED) +QT_REQUIRE_CONFIG(iconv); #ifdef Q_OS_MAC typedef void * iconv_t; @@ -100,6 +100,4 @@ public: QT_END_NAMESPACE -#endif // Q_OS_UNIX && !QT_NO_ICONV && !QT_BOOTSTRAPPED - #endif // QICONVCODEC_P_H diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 5098ac4242..0c9036aadf 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -61,7 +61,7 @@ #if defined(QT_USE_ICU) #include "qicucodec_p.h" #else -#if !defined(QT_NO_ICONV) +#if QT_CONFIG(iconv) # include "qiconvcodec_p.h" #endif #ifdef Q_OS_WIN @@ -184,7 +184,7 @@ static QTextCodec *setupLocaleMapper() if (charset) locale = QTextCodec::codecForName(charset); #endif -#if !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED) +#if QT_CONFIG(iconv) if (!locale) { // no builtin codec for the locale found, let's try using iconv (void) new QIconvCodec(); @@ -286,7 +286,7 @@ static void setup() (void)new QBig5Codec; (void)new QBig5hkscsCodec; # endif // !QT_NO_BIG_CODECS && !Q_OS_INTEGRITY -#if !defined(QT_NO_ICONV) +#if QT_CONFIG(iconv) (void) new QIconvCodec; #endif #if defined(Q_OS_WIN32) diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 76b6612a5d..5017f4652a 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -245,21 +245,21 @@ "label": "iconv", "purpose": "Provides internationalization on Unix.", "section": "Internationalization", - "condition": "features.posix-libiconv || features.sun-libiconv || features.gnu-libiconv", + "condition": "!features.icu && (features.posix-libiconv || features.sun-libiconv || features.gnu-libiconv)", "output": [ "privateFeature", "feature" ] }, "posix-libiconv": { "label": "POSIX iconv", "enable": "input.iconv == 'posix'", "disable": "input.iconv == 'sun' || input.iconv == 'gnu' || input.iconv == 'no'", - "condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && tests.posix-iconv" + "condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && tests.posix-iconv", + "output": [ "privateFeature" ] }, "sun-libiconv": { "label": "SUN iconv", "enable": "input.iconv == 'sun'", "disable": "input.iconv == 'posix' || input.iconv == 'gnu' || input.iconv == 'no'", - "condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && !features.posix-libiconv && tests.sun-iconv", - "output": [ "privateFeature", "publicQtConfig" ] + "condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && !features.posix-libiconv && tests.sun-iconv" }, "gnu-libiconv": { "label": "GNU iconv", diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 3b86e94cdd..4629a57485 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -68,6 +68,7 @@ #define QT_CRYPTOGRAPHICHASH_ONLY_SHA1 #define QT_NO_DATASTREAM +#define QT_FEATURE_iconv -1 #define QT_NO_LIBRARY #define QT_FEATURE_library -1 #define QT_NO_QOBJECT -- cgit v1.2.3 From 5d9413ab3574dd65fb9380bed88caa22d3e5dc92 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 22 Nov 2016 10:14:07 +0100 Subject: Remove Mac specific code paths from qiconvcodec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code is dead, as the codec is never used on macOS. Change-Id: I86138f1c95e5564256b4d592f0044e83658def93 Reviewed-by: Morten Johan Sørvig Reviewed-by: Oswald Buddenhagen --- src/corelib/codecs/qiconvcodec.cpp | 42 +------------------------------------- src/corelib/codecs/qiconvcodec_p.h | 4 ---- 2 files changed, 1 insertion(+), 45 deletions(-) (limited to 'src') diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 8961d01eee..e4fb359f2c 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -64,7 +64,7 @@ QT_REQUIRE_CONFIG(iconv); #elif defined(Q_OS_AIX) # define NO_BOM # define UTF16 "UCS-2" -#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) +#elif defined(Q_OS_FREEBSD) # define NO_BOM # if Q_BYTE_ORDER == Q_BIG_ENDIAN # define UTF16 "UTF-16BE" @@ -75,19 +75,6 @@ QT_REQUIRE_CONFIG(iconv); # define UTF16 "UTF-16" #endif -#if defined(Q_OS_MAC) -#ifndef GNU_LIBICONV -#define GNU_LIBICONV -#endif -typedef iconv_t (*Ptr_iconv_open) (const char*, const char*); -typedef size_t (*Ptr_iconv) (iconv_t, const char **, size_t *, char **, size_t *); -typedef int (*Ptr_iconv_close) (iconv_t); - -static Ptr_iconv_open ptr_iconv_open = 0; -static Ptr_iconv ptr_iconv = 0; -static Ptr_iconv_close ptr_iconv_close = 0; -#endif - QT_BEGIN_NAMESPACE QIconvCodec::QIconvCodec() @@ -105,33 +92,6 @@ void QIconvCodec::init() const fprintf(stderr, "QIconvCodec::convertToUnicode: internal error, UTF-16 codec not found\n"); utf16Codec = reinterpret_cast(~0); } -#if defined(Q_OS_MAC) - if (ptr_iconv_open == 0) { - QLibrary libiconv(QLatin1String("/usr/lib/libiconv")); - libiconv.setLoadHints(QLibrary::ExportExternalSymbolsHint); - - ptr_iconv_open = reinterpret_cast(libiconv.resolve("libiconv_open")); - if (!ptr_iconv_open) - ptr_iconv_open = reinterpret_cast(libiconv.resolve("iconv_open")); - ptr_iconv = reinterpret_cast(libiconv.resolve("libiconv")); - if (!ptr_iconv) - ptr_iconv = reinterpret_cast(libiconv.resolve("iconv")); - ptr_iconv_close = reinterpret_cast(libiconv.resolve("libiconv_close")); - if (!ptr_iconv_close) - ptr_iconv_close = reinterpret_cast(libiconv.resolve("iconv_close")); - - Q_ASSERT_X(ptr_iconv_open && ptr_iconv && ptr_iconv_close, - "QIconvCodec::QIconvCodec()", - "internal error, could not resolve the iconv functions"); - -# undef iconv_open -# define iconv_open ptr_iconv_open -# undef iconv -# define iconv ptr_iconv -# undef iconv_close -# define iconv_close ptr_iconv_close - } -#endif } QIconvCodec::~QIconvCodec() diff --git a/src/corelib/codecs/qiconvcodec_p.h b/src/corelib/codecs/qiconvcodec_p.h index d99e72f635..9b8500538b 100644 --- a/src/corelib/codecs/qiconvcodec_p.h +++ b/src/corelib/codecs/qiconvcodec_p.h @@ -56,11 +56,7 @@ QT_REQUIRE_CONFIG(iconv); -#ifdef Q_OS_MAC -typedef void * iconv_t; -#else #include -#endif QT_BEGIN_NAMESPACE -- cgit v1.2.3 From f17605777b06fb451935e8cbd38b23842dff68d1 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 14 Nov 2016 10:12:37 +0000 Subject: Revert "Revert "Deduplication fetchTransformed"" qdrawhelper.cpp is now compiled without PCH, and changes blocked by the ICE can be reinstated. This reverts commit cd9de59177ccbeb7fdfacf8716af7bb20112c880. Task-number: QTBUG-56817 Change-Id: I8d674768d16b3705598bfe5d08ed98376c97a478 Reviewed-by: Simon Hausmann --- src/gui/painting/qdrawhelper.cpp | 185 ++++++++++----------------------------- 1 file changed, 48 insertions(+), 137 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index fe1ff6603d..656b04fdf3 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -836,7 +836,10 @@ static const uint *QT_FASTCALL convertGrayscale8FromARGB32PM(uint *buffer, const } template static -uint QT_FASTCALL fetchPixel(const uchar *src, int index); +uint QT_FASTCALL fetchPixel(const uchar *, int) +{ + Q_UNREACHABLE(); +} template <> inline uint QT_FASTCALL fetchPixel(const uchar *src, int index) @@ -1554,92 +1557,11 @@ static const QRgba64 *QT_FASTCALL fetchUntransformed64(QRgba64 *buffer, const Op } } -// blendType is either BlendTransformed or BlendTransformedTiled -template -static const uint *QT_FASTCALL fetchTransformedARGB32PM(uint *buffer, const Operator *, const QSpanData *data, - int y, int x, int length) -{ - int image_width = data->texture.width; - int image_height = data->texture.height; - - const qreal cx = x + qreal(0.5); - const qreal cy = y + qreal(0.5); - - const uint *end = buffer + length; - uint *b = buffer; - if (data->fast_matrix) { - // The increment pr x in the scanline - int fdx = (int)(data->m11 * fixed_scale); - int fdy = (int)(data->m12 * fixed_scale); - - int fx = int((data->m21 * cy - + data->m11 * cx + data->dx) * fixed_scale); - int fy = int((data->m22 * cy - + data->m12 * cx + data->dy) * fixed_scale); - - while (b < end) { - int px = fx >> 16; - int py = fy >> 16; - - if (blendType == BlendTransformedTiled) { - px %= image_width; - py %= image_height; - if (px < 0) px += image_width; - if (py < 0) py += image_height; - } else { - px = qBound(0, px, image_width - 1); - py = qBound(0, py, image_height - 1); - } - *b = reinterpret_cast(data->texture.scanLine(py))[px]; - - fx += fdx; - fy += fdy; - ++b; - } - } else { - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - qreal fx = data->m21 * cy + data->m11 * cx + data->dx; - qreal fy = data->m22 * cy + data->m12 * cx + data->dy; - qreal fw = data->m23 * cy + data->m13 * cx + data->m33; - - while (b < end) { - const qreal iw = fw == 0 ? 1 : 1 / fw; - const qreal tx = fx * iw; - const qreal ty = fy * iw; - int px = int(tx) - (tx < 0); - int py = int(ty) - (ty < 0); - - if (blendType == BlendTransformedTiled) { - px %= image_width; - py %= image_height; - if (px < 0) px += image_width; - if (py < 0) py += image_height; - } else { - px = qBound(0, px, image_width - 1); - py = qBound(0, py, image_height - 1); - } - *b = reinterpret_cast(data->texture.scanLine(py))[px]; - - fx += fdx; - fy += fdy; - fw += fdw; - //force increment to avoid /0 - if (!fw) { - fw += fdw; - } - ++b; - } - } - return buffer; -} - -template /* either BlendTransformed or BlendTransformedTiled */ +template static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { + Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled); int image_width = data->texture.width; int image_height = data->texture.height; @@ -1647,9 +1569,12 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const qreal cy = y + qreal(0.5); const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; - FetchPixelFunc fetch = qFetchPixel[layout->bpp]; + if (bpp != QPixelLayout::BPPNone) // Like this to not ICE on GCC 5.3.1 + Q_ASSERT(layout->bpp == bpp); + // When templated 'fetch' should be inlined at compile time: + const FetchPixelFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : fetchPixel; - const uint *end = buffer + length; + uint *const end = buffer + length; uint *b = buffer; if (data->fast_matrix) { // The increment pr x in the scanline @@ -2585,12 +2510,17 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c } // blendType = BlendTransformedBilinear or BlendTransformedBilinearTiled -template +template static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; const QVector *clut = data->texture.colorTable; + if (bpp != QPixelLayout::BPPNone) // Like this to not ICE on GCC 5.3.1 + Q_ASSERT(layout->bpp == bpp); + // When templated 'fetch' should be inlined at compile time: + const FetchPixelsFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixels[layout->bpp] : fetchPixels; + const FetchPixelFunc fetch1 = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : fetchPixel; int image_width = data->texture.width; int image_height = data->texture.height; @@ -2628,7 +2558,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper // The idea is first to do the interpolation between the row s1 and the row s2 // into an intermediate buffer, then we interpolate between two pixel of this buffer. - FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; // +1 for the last pixel to interpolate with, and +1 for rounding errors. uint buf1[buffer_size + 2]; uint buf2[buffer_size + 2]; @@ -2717,7 +2646,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper fx += fdx; } } else { - FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint buf1[buffer_size]; uint buf2[buffer_size]; uint *b = buffer; @@ -2728,19 +2656,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper int x1 = (fx >> 16); int x2; fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); - - if (layout->bpp == QPixelLayout::BPP32) { - buf1[i * 2 + 0] = ((const uint*)s1)[x1]; - buf1[i * 2 + 1] = ((const uint*)s1)[x2]; - buf2[i * 2 + 0] = ((const uint*)s2)[x1]; - buf2[i * 2 + 1] = ((const uint*)s2)[x2]; - } else { - buf1[i * 2 + 0] = fetch(s1, x1); - buf1[i * 2 + 1] = fetch(s1, x2); - buf2[i * 2 + 0] = fetch(s2, x1); - buf2[i * 2 + 1] = fetch(s2, x2); - } - + buf1[i * 2 + 0] = fetch1(s1, x1); + buf1[i * 2 + 1] = fetch1(s1, x2); + buf2[i * 2 + 0] = fetch1(s2, x1); + buf2[i * 2 + 1] = fetch1(s2, x2); fx += fdx; } layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0); @@ -2770,7 +2689,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper } } } else { //rotation - FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint buf1[buffer_size]; uint buf2[buffer_size]; uint *b = buffer; @@ -2789,19 +2707,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); - - if (layout->bpp == QPixelLayout::BPP32) { - buf1[i * 2 + 0] = ((const uint*)s1)[x1]; - buf1[i * 2 + 1] = ((const uint*)s1)[x2]; - buf2[i * 2 + 0] = ((const uint*)s2)[x1]; - buf2[i * 2 + 1] = ((const uint*)s2)[x2]; - } else { - buf1[i * 2 + 0] = fetch(s1, x1); - buf1[i * 2 + 1] = fetch(s1, x2); - buf2[i * 2 + 0] = fetch(s2, x1); - buf2[i * 2 + 1] = fetch(s2, x2); - } - + buf1[i * 2 + 0] = fetch1(s1, x1); + buf1[i * 2 + 1] = fetch1(s1, x2); + buf2[i * 2 + 0] = fetch1(s2, x1); + buf2[i * 2 + 1] = fetch1(s2, x2); fx += fdx; fy += fdy; } @@ -2848,7 +2757,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper qreal fy = data->m22 * cy + data->m12 * cx + data->dy; qreal fw = data->m23 * cy + data->m13 * cx + data->m33; - FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint buf1[buffer_size]; uint buf2[buffer_size]; uint *b = buffer; @@ -2876,18 +2784,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); - - if (layout->bpp == QPixelLayout::BPP32) { - buf1[i * 2 + 0] = ((const uint*)s1)[x1]; - buf1[i * 2 + 1] = ((const uint*)s1)[x2]; - buf2[i * 2 + 0] = ((const uint*)s2)[x1]; - buf2[i * 2 + 1] = ((const uint*)s2)[x2]; - } else { - buf1[i * 2 + 0] = fetch(s1, x1); - buf1[i * 2 + 1] = fetch(s1, x2); - buf2[i * 2 + 0] = fetch(s2, x1); - buf2[i * 2 + 1] = fetch(s2, x2); - } + buf1[i * 2 + 0] = fetch1(s1, x1); + buf1[i * 2 + 1] = fetch1(s1, x2); + buf2[i * 2 + 0] = fetch1(s2, x1); + buf2[i * 2 + 1] = fetch1(s2, x2); fx += fdx; fy += fdy; @@ -3293,23 +3193,32 @@ static SourceFetchProc sourceFetchUntransformed[QImage::NImageFormats] = { }; static const SourceFetchProc sourceFetchGeneric[NBlendTypes] = { - fetchUntransformed, // Untransformed - fetchUntransformed, // Tiled - fetchTransformed, // Transformed - fetchTransformed, // TransformedTiled - fetchTransformedBilinear, // Bilinear - fetchTransformedBilinear // BilinearTiled + fetchUntransformed, // Untransformed + fetchUntransformed, // Tiled + fetchTransformed, // Transformed + fetchTransformed, // TransformedTiled + fetchTransformedBilinear, // TransformedBilinear + fetchTransformedBilinear // TransformedBilinearTiled }; static SourceFetchProc sourceFetchARGB32PM[NBlendTypes] = { fetchUntransformedARGB32PM, // Untransformed fetchUntransformedARGB32PM, // Tiled - fetchTransformedARGB32PM, // Transformed - fetchTransformedARGB32PM, // TransformedTiled + fetchTransformed, // Transformed + fetchTransformed, // TransformedTiled fetchTransformedBilinearARGB32PM, // Bilinear fetchTransformedBilinearARGB32PM // BilinearTiled }; +static SourceFetchProc sourceFetchAny32[NBlendTypes] = { + fetchUntransformed, // Untransformed + fetchUntransformed, // Tiled + fetchTransformed, // Transformed + fetchTransformed, // TransformedTiled + fetchTransformedBilinear, // TransformedBilinear + fetchTransformedBilinear // TransformedBilinearTiled +}; + static const SourceFetchProc64 sourceFetchGeneric64[NBlendTypes] = { fetchUntransformed64, // Untransformed fetchUntransformed64, // Tiled @@ -3325,6 +3234,8 @@ static inline SourceFetchProc getSourceFetch(TextureBlendType blendType, QImage: return sourceFetchARGB32PM[blendType]; if (blendType == BlendUntransformed || blendType == BlendTiled) return sourceFetchUntransformed[format]; + if (qPixelLayouts[format].bpp == QPixelLayout::BPP32) + return sourceFetchAny32[blendType]; return sourceFetchGeneric[blendType]; } -- cgit v1.2.3 From 04b276b0f5dd265b27dd6ca54fda15a4a64a40df Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 18 Nov 2016 13:02:59 +0100 Subject: Remove last traces of MeeGo Change-Id: I5242f1dfcfccf9811398e717b90196e6228d1dc5 Reviewed-by: Laszlo Agocs Reviewed-by: Oswald Buddenhagen --- src/gui/opengl/opengl.pri | 1 - src/gui/opengl/qopenglshadercache_meego_p.h | 450 --------------------- src/gui/opengl/qopenglshadercache_p.h | 5 - src/network/ssl/qsslsocket.cpp | 2 +- .../gl2paintengineex/qglshadercache_meego_p.h | 450 --------------------- src/opengl/gl2paintengineex/qglshadercache_p.h | 5 - src/opengl/opengl.pro | 3 +- src/tools/uic/qclass_lib_map.h | 6 - 8 files changed, 2 insertions(+), 920 deletions(-) delete mode 100644 src/gui/opengl/qopenglshadercache_meego_p.h delete mode 100644 src/opengl/gl2paintengineex/qglshadercache_meego_p.h (limited to 'src') diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index 712cf144e0..1a1022b3a7 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -24,7 +24,6 @@ qtConfig(opengl) { opengl/qopenglcustomshaderstage_p.h \ opengl/qopengltextureglyphcache_p.h \ opengl/qopenglshadercache_p.h \ - opengl/qopenglshadercache_meego_p.h \ opengl/qopenglversionfunctions.h \ opengl/qopenglversionfunctionsfactory_p.h \ opengl/qopenglvertexarrayobject.h \ diff --git a/src/gui/opengl/qopenglshadercache_meego_p.h b/src/gui/opengl/qopenglshadercache_meego_p.h deleted file mode 100644 index 0892e1a2a1..0000000000 --- a/src/gui/opengl/qopenglshadercache_meego_p.h +++ /dev/null @@ -1,450 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QOPENGLSHADERCACHE_MEEGO_P_H -#define QOPENGLSHADERCACHE_MEEGO_P_H - -#include - -#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2) - -#include -#include -#include - -#ifndef QT_BOOTSTRAPPED -# include -#endif -#if defined(QT_DEBUG) || defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE_TRACE) -# include -#endif - -/* - This cache stores internal Qt shader programs in shared memory. - - This header file is ugly on purpose and can only be included once. It is only to be used - for the internal shader cache, not as a generic cache for anyone's shaders. - - The cache stores either ShaderCacheMaxEntries shader programs or ShaderCacheDataSize kilobytes - of shader programs, whatever limit is reached first. - - The layout of the cache is as outlined in the CachedShaders struct. After some - integers, an array of headers is reserved, then comes the space for the actual binaries. - - Shader Programs are identified by the md5sum of their frag and vertex shader source code. - - Shader Programs are never removed. The cache never shrinks or re-shuffles. This is done - on purpose to ensure minimum amount of locking, no alignment problems and very few write - operations. - - Note: Locking the shader cache could be expensive, because the entire system might hang. - That's why the cache is immutable to minimize the time we need to keep it locked. - - Why is it Meego specific? - - First, the size is chosen so that it fits to generic meego usage. Second, on Meego, there's - always at least one Qt application active (the launcher), so the cache will never be destroyed. - Only when the last Qt app exits, the cache dies, which should only be when someone kills the - X11 server. And last but not least it was only tested with Meego's SGX driver. - - There's a small tool in src/opengl/util/meego that dumps the contents of the cache. - */ - -// anonymous namespace, prevent exporting of the private symbols -namespace -{ - -struct CachedShaderHeader -{ - /* the index in the data[] member of CachedShaders */ - int index; - /* the size of the binary shader */ - GLsizei size; - /* the format of the binary shader */ - GLenum format; - /* the md5sum of the frag+vertex shaders */ - char md5Sum[16]; -}; - -enum -{ - /* The maximum amount of shader programs the cache can hold */ - ShaderCacheMaxEntries = 20 -}; - -typedef CachedShaderHeader CachedShaderHeaders[ShaderCacheMaxEntries]; - -enum -{ - // ShaderCacheDataSize is 20k minus the other data members of CachedShaders - ShaderCacheDataSize = 1024 * ShaderCacheMaxEntries - sizeof(CachedShaderHeaders) - 2 * sizeof(int) -}; - -struct CachedShaders -{ - /* How much space is still available in the cache */ - inline int availableSize() const { return ShaderCacheDataSize - dataSize; } - - /* The current amount of cached shaders */ - int shaderCount; - - /* The current amount (in bytes) of cached data */ - int dataSize; - - /* The headers describing the shaders */ - CachedShaderHeaders headers; - - /* The actual binary data of the shader programs */ - char data[ShaderCacheDataSize]; -}; - -//#define QT_DEBUG_SHADER_CACHE -#ifdef QT_DEBUG_SHADER_CACHE -static QDebug shaderCacheDebug() -{ - return QDebug(QtDebugMsg); -} -#else -static inline QNoDebug shaderCacheDebug() { return QNoDebug(); } -#endif - -class ShaderCacheSharedMemory -{ -public: - ShaderCacheSharedMemory() - : shm(QLatin1String("qt_gles2_shadercache_" QT_VERSION_STR)) - { - // we need a system semaphore here, since cache creation and initialization must be atomic - QSystemSemaphore attachSemaphore(QLatin1String("qt_gles2_shadercache_mutex_" QT_VERSION_STR), 1); - - if (!attachSemaphore.acquire()) { - shaderCacheDebug() << "Unable to require shader cache semaphore:" << attachSemaphore.errorString(); - return; - } - - if (shm.attach()) { - // success! - shaderCacheDebug() << "Attached to shader cache"; - } else { - - // no cache exists - create and initialize it - if (shm.create(sizeof(CachedShaders))) { - shaderCacheDebug() << "Created new shader cache"; - initializeCache(); - } else { - shaderCacheDebug() << "Unable to create shader cache:" << shm.errorString(); - } - } - - attachSemaphore.release(); - } - - inline bool isAttached() const { return shm.isAttached(); } - - inline bool lock() { return shm.lock(); } - inline bool unlock() { return shm.unlock(); } - inline void *data() { return shm.data(); } - inline QString errorString() { return shm.errorString(); } - - ~ShaderCacheSharedMemory() - { - if (!shm.detach()) - shaderCacheDebug() << "Unable to detach shader cache" << shm.errorString(); - } - -private: - void initializeCache() - { - // no need to lock the shared memory since we're already protected by the - // attach system semaphore. - - void *data = shm.data(); - Q_ASSERT(data); - - memset(data, 0, sizeof(CachedShaders)); - } - - QSharedMemory shm; -}; - -class ShaderCacheLocker -{ -public: - inline ShaderCacheLocker(ShaderCacheSharedMemory *cache) - : shm(cache->lock() ? cache : (ShaderCacheSharedMemory *)0) - { - if (!shm) - shaderCacheDebug() << "Unable to lock shader cache" << cache->errorString(); - } - - inline bool isLocked() const { return shm; } - - inline ~ShaderCacheLocker() - { - if (!shm) - return; - if (!shm->unlock()) - shaderCacheDebug() << "Unable to unlock shader cache" << shm->errorString(); - } - -private: - ShaderCacheSharedMemory *shm; -}; - -#ifdef QT_BOOTSTRAPPED -} // end namespace -#else - -static void traceCacheOverflow(const char *message) -{ -#if defined(QT_DEBUG) || defined (QT_MEEGO_EXPERIMENTAL_SHADERCACHE_TRACE) - openlog(qPrintable(QCoreApplication::applicationName()), LOG_PID | LOG_ODELAY, LOG_USER); - syslog(LOG_DEBUG, message); - closelog(); -#endif - shaderCacheDebug() << message; -} - -Q_GLOBAL_STATIC(ShaderCacheSharedMemory, shaderCacheSharedMemory) - -/* - Finds the index of the shader program identified by md5Sum in the cache. - Note: Does NOT lock the cache for reading, the cache must already be locked! - - Returns -1 when no shader was found. - */ -static int qt_cache_index_unlocked(const QByteArray &md5Sum, CachedShaders *cache) -{ - for (int i = 0; i < cache->shaderCount; ++i) { - if (qstrncmp(md5Sum.constData(), cache->headers[i].md5Sum, 16) == 0) { - return i; - } - } - return -1; -} - -/* Returns the index of the shader identified by md5Sum */ -static int qt_cache_index(const QByteArray &md5Sum) -{ - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - Q_ASSERT(md5Sum.length() == 16); - - ShaderCacheLocker locker(shm); - if (!locker.isLocked()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast(data); - - return qt_cache_index_unlocked(md5Sum, cache); -} - -/* Loads the cached shader at index \a shaderIndex into \a program - * Note: Since the cache is immutable, this operation doesn't lock the shared memory. - */ -static bool qt_cached_shader(QOpenGLShaderProgram *program, QOpenGLContext *ctx, int shaderIndex) -{ - Q_ASSERT(shaderIndex >= 0 && shaderIndex <= ShaderCacheMaxEntries); - Q_ASSERT(program); - - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast(data); - - shaderCacheDebug() << "fetching cached shader at index" << shaderIndex - << "dataIndex" << cache->headers[shaderIndex].index - << "size" << cache->headers[shaderIndex].size - << "format" << cache->headers[shaderIndex].format; - - // call program->programId first, since that resolves the glProgramBinaryOES symbol - GLuint programId = program->programId(); - glProgramBinaryOES(programId, cache->headers[shaderIndex].format, - cache->data + cache->headers[shaderIndex].index, - cache->headers[shaderIndex].size); - - return true; -} - -/* Stores the shader program in the cache. Returns false if there's an error with the cache, or - if the cache is too small to hold the shader. */ -static bool qt_cache_shader(const QOpenGLShaderProgram *shader, QOpenGLContext *ctx, const QByteArray &md5Sum) -{ - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast(data); - - ShaderCacheLocker locker(shm); - if (!locker.isLocked()) - return false; - - int cacheIdx = cache->shaderCount; - if (cacheIdx >= ShaderCacheMaxEntries) { - traceCacheOverflow("Qt OpenGL shader cache index overflow!"); - return false; - } - - // now that we have the lock on the shared memory, make sure no one - // inserted the shader already while we were unlocked - if (qt_cache_index_unlocked(md5Sum, cache) != -1) - return true; // already cached - - shaderCacheDebug() << "Caching shader at index" << cacheIdx; - - GLint binaryLength = 0; - glGetProgramiv(shader->programId(), GL_PROGRAM_BINARY_LENGTH_OES, &binaryLength); - - if (!binaryLength) { - shaderCacheDebug() << "Unable to determine binary shader size!"; - return false; - } - - if (binaryLength > cache->availableSize()) { - traceCacheOverflow("Qt OpenGL shader cache data overflow!"); - return false; - } - - GLsizei size = 0; - GLenum format = 0; - glGetProgramBinaryOES(shader->programId(), binaryLength, &size, &format, - cache->data + cache->dataSize); - - if (!size) { - shaderCacheDebug() << "Unable to get binary shader!"; - return false; - } - - cache->headers[cacheIdx].index = cache->dataSize; - cache->dataSize += binaryLength; - ++cache->shaderCount; - cache->headers[cacheIdx].size = binaryLength; - cache->headers[cacheIdx].format = format; - - memcpy(cache->headers[cacheIdx].md5Sum, md5Sum.constData(), 16); - - shaderCacheDebug() << "cached shader size" << size - << "format" << format - << "binarySize" << binaryLength - << "cache index" << cacheIdx - << "data index" << cache->headers[cacheIdx].index; - - return true; -} - -} // namespace - -QT_BEGIN_NAMESPACE - - -class CachedShader -{ -public: - CachedShader(const QByteArray &fragSource, const QByteArray &vertexSource) - : cacheIdx(-1) - { - QCryptographicHash md5Hash(QCryptographicHash::Md5); - - md5Hash.addData(fragSource); - md5Hash.addData(vertexSource); - - md5Sum = md5Hash.result(); - } - - bool isCached() - { - return cacheIndex() != -1; - } - - int cacheIndex() - { - if (cacheIdx != -1) - return cacheIdx; - cacheIdx = qt_cache_index(md5Sum); - return cacheIdx; - } - - bool load(QOpenGLShaderProgram *program, QOpenGLContext *ctx) - { - if (cacheIndex() == -1) - return false; - return qt_cached_shader(program, ctx, cacheIdx); - } - - bool store(QOpenGLShaderProgram *program, QOpenGLContext *ctx) - { - return qt_cache_shader(program, ctx, md5Sum); - } - -private: - QByteArray md5Sum; - int cacheIdx; -}; - - -QT_END_NAMESPACE - -#endif - -#endif -#endif diff --git a/src/gui/opengl/qopenglshadercache_p.h b/src/gui/opengl/qopenglshadercache_p.h index b4d1d64721..0f730602b0 100644 --- a/src/gui/opengl/qopenglshadercache_p.h +++ b/src/gui/opengl/qopenglshadercache_p.h @@ -53,10 +53,6 @@ #include -#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2) -# include "qopenglshadercache_meego_p.h" -#else - QT_BEGIN_NAMESPACE @@ -88,4 +84,3 @@ public: QT_END_NAMESPACE #endif -#endif diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 29e1f32815..2fc779b257 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2643,7 +2643,7 @@ bool QSslSocketPrivate::rootCertOnDemandLoadingSupported() */ QList QSslSocketPrivate::unixRootCertDirectories() { - return QList() << "/etc/ssl/certs/" // (K)ubuntu, OpenSUSE, Mandriva, MeeGo ... + return QList() << "/etc/ssl/certs/" // (K)ubuntu, OpenSUSE, Mandriva ... << "/usr/lib/ssl/certs/" // Gentoo, Mandrake << "/usr/share/ssl/" // Centos, Redhat, SuSE << "/usr/local/ssl/" // Normal OpenSSL Tarball diff --git a/src/opengl/gl2paintengineex/qglshadercache_meego_p.h b/src/opengl/gl2paintengineex/qglshadercache_meego_p.h deleted file mode 100644 index de75d5ae8c..0000000000 --- a/src/opengl/gl2paintengineex/qglshadercache_meego_p.h +++ /dev/null @@ -1,450 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QGLSHADERCACHE_MEEGO_P_H -#define QGLSHADERCACHE_MEEGO_P_H - -#include - -#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2) - -#include -#include -#include - -#ifndef QT_BOOTSTRAPPED -# include -#endif -#if defined(QT_DEBUG) || defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE_TRACE) -# include -#endif - -/* - This cache stores internal Qt shader programs in shared memory. - - This header file is ugly on purpose and can only be included once. It is only to be used - for the internal shader cache, not as a generic cache for anyone's shaders. - - The cache stores either ShaderCacheMaxEntries shader programs or ShaderCacheDataSize kilobytes - of shader programs, whatever limit is reached first. - - The layout of the cache is as outlined in the CachedShaders struct. After some - integers, an array of headers is reserved, then comes the space for the actual binaries. - - Shader Programs are identified by the md5sum of their frag and vertex shader source code. - - Shader Programs are never removed. The cache never shrinks or re-shuffles. This is done - on purpose to ensure minimum amount of locking, no alignment problems and very few write - operations. - - Note: Locking the shader cache could be expensive, because the entire system might hang. - That's why the cache is immutable to minimize the time we need to keep it locked. - - Why is it Meego specific? - - First, the size is chosen so that it fits to generic meego usage. Second, on Meego, there's - always at least one Qt application active (the launcher), so the cache will never be destroyed. - Only when the last Qt app exits, the cache dies, which should only be when someone kills the - X11 server. And last but not least it was only tested with Meego's SGX driver. - - There's a small tool in src/opengl/util/meego that dumps the contents of the cache. - */ - -// anonymous namespace, prevent exporting of the private symbols -namespace -{ - -struct CachedShaderHeader -{ - /* the index in the data[] member of CachedShaders */ - int index; - /* the size of the binary shader */ - GLsizei size; - /* the format of the binary shader */ - GLenum format; - /* the md5sum of the frag+vertex shaders */ - char md5Sum[16]; -}; - -enum -{ - /* The maximum amount of shader programs the cache can hold */ - ShaderCacheMaxEntries = 20 -}; - -typedef CachedShaderHeader CachedShaderHeaders[ShaderCacheMaxEntries]; - -enum -{ - // ShaderCacheDataSize is 20k minus the other data members of CachedShaders - ShaderCacheDataSize = 1024 * ShaderCacheMaxEntries - sizeof(CachedShaderHeaders) - 2 * sizeof(int) -}; - -struct CachedShaders -{ - /* How much space is still available in the cache */ - inline int availableSize() const { return ShaderCacheDataSize - dataSize; } - - /* The current amount of cached shaders */ - int shaderCount; - - /* The current amount (in bytes) of cached data */ - int dataSize; - - /* The headers describing the shaders */ - CachedShaderHeaders headers; - - /* The actual binary data of the shader programs */ - char data[ShaderCacheDataSize]; -}; - -//#define QT_DEBUG_SHADER_CACHE -#ifdef QT_DEBUG_SHADER_CACHE -static QDebug shaderCacheDebug() -{ - return QDebug(QtDebugMsg); -} -#else -static inline QNoDebug shaderCacheDebug() { return QNoDebug(); } -#endif - -class ShaderCacheSharedMemory -{ -public: - ShaderCacheSharedMemory() - : shm(QLatin1String("qt_gles2_shadercache_" QT_VERSION_STR)) - { - // we need a system semaphore here, since cache creation and initialization must be atomic - QSystemSemaphore attachSemaphore(QLatin1String("qt_gles2_shadercache_mutex_" QT_VERSION_STR), 1); - - if (!attachSemaphore.acquire()) { - shaderCacheDebug() << "Unable to require shader cache semaphore:" << attachSemaphore.errorString(); - return; - } - - if (shm.attach()) { - // success! - shaderCacheDebug() << "Attached to shader cache"; - } else { - - // no cache exists - create and initialize it - if (shm.create(sizeof(CachedShaders))) { - shaderCacheDebug() << "Created new shader cache"; - initializeCache(); - } else { - shaderCacheDebug() << "Unable to create shader cache:" << shm.errorString(); - } - } - - attachSemaphore.release(); - } - - inline bool isAttached() const { return shm.isAttached(); } - - inline bool lock() { return shm.lock(); } - inline bool unlock() { return shm.unlock(); } - inline void *data() { return shm.data(); } - inline QString errorString() { return shm.errorString(); } - - ~ShaderCacheSharedMemory() - { - if (!shm.detach()) - shaderCacheDebug() << "Unable to detach shader cache" << shm.errorString(); - } - -private: - void initializeCache() - { - // no need to lock the shared memory since we're already protected by the - // attach system semaphore. - - void *data = shm.data(); - Q_ASSERT(data); - - memset(data, 0, sizeof(CachedShaders)); - } - - QSharedMemory shm; -}; - -class ShaderCacheLocker -{ -public: - inline ShaderCacheLocker(ShaderCacheSharedMemory *cache) - : shm(cache->lock() ? cache : (ShaderCacheSharedMemory *)0) - { - if (!shm) - shaderCacheDebug() << "Unable to lock shader cache" << cache->errorString(); - } - - inline bool isLocked() const { return shm; } - - inline ~ShaderCacheLocker() - { - if (!shm) - return; - if (!shm->unlock()) - shaderCacheDebug() << "Unable to unlock shader cache" << shm->errorString(); - } - -private: - ShaderCacheSharedMemory *shm; -}; - -#ifdef QT_BOOTSTRAPPED -} // end namespace -#else - -static void traceCacheOverflow(const char *message) -{ -#if defined(QT_DEBUG) || defined (QT_MEEGO_EXPERIMENTAL_SHADERCACHE_TRACE) - openlog(qPrintable(QCoreApplication::applicationName()), LOG_PID | LOG_ODELAY, LOG_USER); - syslog(LOG_DEBUG, message); - closelog(); -#endif - shaderCacheDebug() << message; -} - -Q_GLOBAL_STATIC(ShaderCacheSharedMemory, shaderCacheSharedMemory) - -/* - Finds the index of the shader program identified by md5Sum in the cache. - Note: Does NOT lock the cache for reading, the cache must already be locked! - - Returns -1 when no shader was found. - */ -static int qt_cache_index_unlocked(const QByteArray &md5Sum, CachedShaders *cache) -{ - for (int i = 0; i < cache->shaderCount; ++i) { - if (qstrncmp(md5Sum.constData(), cache->headers[i].md5Sum, 16) == 0) { - return i; - } - } - return -1; -} - -/* Returns the index of the shader identified by md5Sum */ -static int qt_cache_index(const QByteArray &md5Sum) -{ - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - Q_ASSERT(md5Sum.length() == 16); - - ShaderCacheLocker locker(shm); - if (!locker.isLocked()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast(data); - - return qt_cache_index_unlocked(md5Sum, cache); -} - -/* Loads the cached shader at index \a shaderIndex into \a program - * Note: Since the cache is immutable, this operation doesn't lock the shared memory. - */ -static bool qt_cached_shader(QGLShaderProgram *program, const QGLContext *ctx, int shaderIndex) -{ - Q_ASSERT(shaderIndex >= 0 && shaderIndex <= ShaderCacheMaxEntries); - Q_ASSERT(program); - - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast(data); - - shaderCacheDebug() << "fetching cached shader at index" << shaderIndex - << "dataIndex" << cache->headers[shaderIndex].index - << "size" << cache->headers[shaderIndex].size - << "format" << cache->headers[shaderIndex].format; - - // call program->programId first, since that resolves the glProgramBinaryOES symbol - GLuint programId = program->programId(); - glProgramBinaryOES(programId, cache->headers[shaderIndex].format, - cache->data + cache->headers[shaderIndex].index, - cache->headers[shaderIndex].size); - - return true; -} - -/* Stores the shader program in the cache. Returns false if there's an error with the cache, or - if the cache is too small to hold the shader. */ -static bool qt_cache_shader(const QGLShaderProgram *shader, const QGLContext *ctx, const QByteArray &md5Sum) -{ - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast(data); - - ShaderCacheLocker locker(shm); - if (!locker.isLocked()) - return false; - - int cacheIdx = cache->shaderCount; - if (cacheIdx >= ShaderCacheMaxEntries) { - traceCacheOverflow("Qt OpenGL shader cache index overflow!"); - return false; - } - - // now that we have the lock on the shared memory, make sure no one - // inserted the shader already while we were unlocked - if (qt_cache_index_unlocked(md5Sum, cache) != -1) - return true; // already cached - - shaderCacheDebug() << "Caching shader at index" << cacheIdx; - - GLint binaryLength = 0; - glGetProgramiv(shader->programId(), GL_PROGRAM_BINARY_LENGTH_OES, &binaryLength); - - if (!binaryLength) { - shaderCacheDebug() << "Unable to determine binary shader size!"; - return false; - } - - if (binaryLength > cache->availableSize()) { - traceCacheOverflow("Qt OpenGL shader cache data overflow!"); - return false; - } - - GLsizei size = 0; - GLenum format = 0; - glGetProgramBinaryOES(shader->programId(), binaryLength, &size, &format, - cache->data + cache->dataSize); - - if (!size) { - shaderCacheDebug() << "Unable to get binary shader!"; - return false; - } - - cache->headers[cacheIdx].index = cache->dataSize; - cache->dataSize += binaryLength; - ++cache->shaderCount; - cache->headers[cacheIdx].size = binaryLength; - cache->headers[cacheIdx].format = format; - - memcpy(cache->headers[cacheIdx].md5Sum, md5Sum.constData(), 16); - - shaderCacheDebug() << "cached shader size" << size - << "format" << format - << "binarySize" << binaryLength - << "cache index" << cacheIdx - << "data index" << cache->headers[cacheIdx].index; - - return true; -} - -} // namespace - -QT_BEGIN_NAMESPACE - - -class CachedShader -{ -public: - CachedShader(const QByteArray &fragSource, const QByteArray &vertexSource) - : cacheIdx(-1) - { - QCryptographicHash md5Hash(QCryptographicHash::Md5); - - md5Hash.addData(fragSource); - md5Hash.addData(vertexSource); - - md5Sum = md5Hash.result(); - } - - bool isCached() - { - return cacheIndex() != -1; - } - - int cacheIndex() - { - if (cacheIdx != -1) - return cacheIdx; - cacheIdx = qt_cache_index(md5Sum); - return cacheIdx; - } - - bool load(QGLShaderProgram *program, const QGLContext *ctx) - { - if (cacheIndex() == -1) - return false; - return qt_cached_shader(program, ctx, cacheIdx); - } - - bool store(QGLShaderProgram *program, const QGLContext *ctx) - { - return qt_cache_shader(program, ctx, md5Sum); - } - -private: - QByteArray md5Sum; - int cacheIdx; -}; - - -QT_END_NAMESPACE - -#endif - -#endif -#endif diff --git a/src/opengl/gl2paintengineex/qglshadercache_p.h b/src/opengl/gl2paintengineex/qglshadercache_p.h index e2ac3f85d7..4204e3e256 100644 --- a/src/opengl/gl2paintengineex/qglshadercache_p.h +++ b/src/opengl/gl2paintengineex/qglshadercache_p.h @@ -53,10 +53,6 @@ #include -#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2) -# include "qglshadercache_meego_p.h" -#else - QT_BEGIN_NAMESPACE @@ -88,4 +84,3 @@ public: QT_END_NAMESPACE #endif -#endif diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 25de6ad670..718a886809 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -41,8 +41,7 @@ HEADERS += qglshaderprogram.h \ gl2paintengineex/qglengineshadersource_p.h \ gl2paintengineex/qglcustomshaderstage_p.h \ gl2paintengineex/qtextureglyphcache_gl_p.h \ - gl2paintengineex/qglshadercache_p.h \ - gl2paintengineex/qglshadercache_meego_p.h + gl2paintengineex/qglshadercache_p.h SOURCES += qglshaderprogram.cpp \ qgraphicsshadereffect.cpp \ diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index 930a648d57..810b326b30 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -440,12 +440,6 @@ QT_CLASS_LIB(QXmlResultItems, QtXmlPatterns, qxmlresultitems.h) QT_CLASS_LIB(QXmlSchema, QtXmlPatterns, qxmlschema.h) QT_CLASS_LIB(QXmlSchemaValidator, QtXmlPatterns, qxmlschemavalidator.h) QT_CLASS_LIB(QXmlSerializer, QtXmlPatterns, qxmlserializer.h) -QT_CLASS_LIB(QMeeGoFenceSync, QtMeeGoGraphicsSystemHelper, qmeegofencesync.h) -QT_CLASS_LIB(QMeeGoGraphicsSystemHelper, QtMeeGoGraphicsSystemHelper, qmeegographicssystemhelper.h) -QT_CLASS_LIB(QMeeGoLivePixmap, QtMeeGoGraphicsSystemHelper, qmeegolivepixmap.h) -QT_CLASS_LIB(QMeeGoOverlayWidget, QtMeeGoGraphicsSystemHelper, qmeegooverlaywidget.h) -QT_CLASS_LIB(QMeeGoRuntime, QtMeeGoGraphicsSystemHelper, qmeegoruntime.h) -QT_CLASS_LIB(QMeeGoSwitchEvent, QtMeeGoGraphicsSystemHelper, qmeegoswitchevent.h) QT_CLASS_LIB(QAxBase, ActiveQt, qaxbase.h) QT_CLASS_LIB(QAxObject, ActiveQt, qaxobject.h) QT_CLASS_LIB(QAxScriptEngine, ActiveQt, qaxscript.h) -- cgit v1.2.3 From 389b4ec28b6bb402d3575ff9c648ef878257ea84 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 22 Nov 2016 15:45:36 +0100 Subject: Windows QPA: Do not send key events for mouse-synthesized app commands Sending key events in addition causes applications to respond twice to for example the back / forward extra mouse buttons. Suppress the keypress by checking on the device. This is in line with the other platforms, which do not send keypresses either. Native event filters will still be able to listen for WM_APPCOMMAND. Task-number: QTBUG-48117 Task-number: QTBUG-57198 Change-Id: I219e17244087663f06ab2c5a8cf4b880c3655700 Reviewed-by: Andy Shaw --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 60361e436d..a52ae7c2a9 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -861,6 +861,9 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd, bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, const MSG &msg) { #if defined(WM_APPCOMMAND) + // QTBUG-57198, do not send mouse-synthesized commands as key events in addition + if (GET_DEVICE_LPARAM(msg.lParam) == FAPPCOMMAND_MOUSE) + return false; const int cmd = GET_APPCOMMAND_LPARAM(msg.lParam); const int dwKeys = GET_KEYSTATE_LPARAM(msg.lParam); int state = 0; -- cgit v1.2.3 From 60054b5940b19f4dd9780e63da1e2dce45baf131 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 2 Nov 2016 13:58:54 +0100 Subject: QSettings: Replace deprecated Win32 SHGetSpecialFolderPath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SHGetSpecialFolderPath is declared 'unsupported' by Microsoft, and has problems with non-ASCII characters. Replace it by the newer SHGetKnownFolderPath. Task-number: QTBUG-50570 Change-Id: I8b2dfa10fa5dc30e6c3be094a2ba8d7c3504f2ca GPush-Base: 4d181bd93234a3747b520d10417825a0147bfeb1 Reviewed-by: Jan Arve Sæther --- src/corelib/io/qsettings.cpp | 71 ++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 47108d057b..480a777457 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -97,14 +97,6 @@ using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Storage; #endif -#ifndef CSIDL_COMMON_APPDATA -#define CSIDL_COMMON_APPDATA 0x0023 // All Users\Application Data -#endif - -#ifndef CSIDL_APPDATA -#define CSIDL_APPDATA 0x001a // \Application Data -#endif - #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID) #define Q_XDG_PLATFORM #endif @@ -959,31 +951,34 @@ void QConfFileSettingsPrivate::initAccess() } #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) -static QString windowsConfigPath(int type) +static QString windowsConfigPath(const KNOWNFOLDERID &type) { QString result; - wchar_t path[MAX_PATH]; - if (SHGetSpecialFolderPath(0, path, type, false)) + PWSTR path = nullptr; + if (SHGetKnownFolderPath(type, KF_FLAG_DONT_VERIFY, NULL, &path) == S_OK) { result = QString::fromWCharArray(path); + CoTaskMemFree(path); + } if (result.isEmpty()) { - switch (type) { - case CSIDL_COMMON_APPDATA: + if (type == FOLDERID_ProgramData) { result = QLatin1String("C:\\temp\\qt-common"); - break; - case CSIDL_APPDATA: + } else if (type == FOLDERID_RoamingAppData) { result = QLatin1String("C:\\temp\\qt-user"); - break; - default: - ; } } return result; } #elif defined(Q_OS_WINRT) // Q_OS_WIN && !Q_OS_WINRT -static QString windowsConfigPath(int type) + +enum ConfigPathType { + ConfigPath_CommonAppData, + ConfigPath_UserAppData +}; + +static QString windowsConfigPath(ConfigPathType type) { static QString result; while (result.isEmpty()) { @@ -1006,12 +1001,10 @@ static QString windowsConfigPath(int type) } switch (type) { - case CSIDL_COMMON_APPDATA: + case ConfigPath_CommonAppData: return result + QLatin1String("\\qt-common"); - case CSIDL_APPDATA: + case ConfigPath_UserAppData: return result + QLatin1String("\\qt-user"); - default: - break; } return result; } @@ -1068,10 +1061,18 @@ static void initDefaultPaths(QMutexLocker *locker) Windows registry and the Mac CFPreferences.) */ #ifdef Q_OS_WIN + +# ifdef Q_OS_WINRT + const QString roamingAppDataFolder = windowsConfigPath(ConfigPath_UserAppData); + const QString programDataFolder = windowsConfigPath(ConfigPath_CommonAppData); +# else + const QString roamingAppDataFolder = windowsConfigPath(FOLDERID_RoamingAppData); + const QString programDataFolder = windowsConfigPath(FOLDERID_ProgramData); +# endif pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), - windowsConfigPath(CSIDL_APPDATA) + QDir::separator()); + roamingAppDataFolder + QDir::separator()); pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), - windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator()); + programDataFolder + QDir::separator()); #else const QString userPath = make_user_path(); pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath); @@ -2231,20 +2232,20 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, On Windows, the following files are used: \list 1 - \li \c{CSIDL_APPDATA\MySoft\Star Runner.ini} - \li \c{CSIDL_APPDATA\MySoft.ini} - \li \c{CSIDL_COMMON_APPDATA\MySoft\Star Runner.ini} - \li \c{CSIDL_COMMON_APPDATA\MySoft.ini} + \li \c{FOLDERID_RoamingAppData\MySoft\Star Runner.ini} + \li \c{FOLDERID_RoamingAppData\MySoft.ini} + \li \c{FOLDERID_ProgramData\MySoft\Star Runner.ini} + \li \c{FOLDERID_ProgramData\MySoft.ini} \endlist - The identifiers prefixed by \c{CSIDL_} are special item ID lists to be passed - to the Win32 API function \c{SHGetSpecialFolderPath()} to obtain the + The identifiers prefixed by \c{FOLDERID_} are special item ID lists to be passed + to the Win32 API function \c{SHGetKnownFolderPath()} to obtain the corresponding path. - \c{CSIDL_APPDATA} usually points to \tt{C:\\Users\\\e{User Name}\\AppData\\Roaming}, + \c{FOLDERID_RoamingAppData} usually points to \tt{C:\\Users\\\e{User Name}\\AppData\\Roaming}, also shown by the environment variable \c{%APPDATA%}. - \c{CSIDL_COMMON_APPDATA} usually points to \tt{C:\\ProgramData}. + \c{FOLDERID_ProgramData} usually points to \tt{C:\\ProgramData}. If the file format is IniFormat, this is "Settings/MySoft/Star Runner.ini" in the application's home directory. @@ -3348,8 +3349,8 @@ void QSettings::setUserIniPath(const QString &dir) \table \header \li Platform \li Format \li Scope \li Path - \row \li{1,2} Windows \li{1,2} IniFormat \li UserScope \li \c CSIDL_APPDATA - \row \li SystemScope \li \c CSIDL_COMMON_APPDATA + \row \li{1,2} Windows \li{1,2} IniFormat \li UserScope \li \c FOLDERID_RoamingAppData + \row \li SystemScope \li \c FOLDERID_ProgramData \row \li{1,2} Unix \li{1,2} NativeFormat, IniFormat \li UserScope \li \c $HOME/.config \row \li SystemScope \li \c /etc/xdg \row \li{1,2} Qt for Embedded Linux \li{1,2} NativeFormat, IniFormat \li UserScope \li \c $HOME/Settings -- cgit v1.2.3 From d3ab4a1ce7cd0fe6539d592138a8119dd51d818f Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 16 Nov 2016 13:11:43 +0100 Subject: _q_networkSessionClosed - disconnect the correct object We have: ... auto networkSession = getNetworkSession(); ... getNetworkSession() can return non-null pointer even if networkSessionStrongRef is null: ... if (networkSessionStrongRef) return networkSessionStrongRef; return networkSessionWeakRef.toStrongRef(); .... We check the result: if (networkSession) { // here we disconnect signals } But we should use the same networkSession when disconnecting, not start using networkSessionStrongRef suddenly, since it can be null. Task-number: QTBUG-57110 Change-Id: I96babb42c2182e741e6eabaf7d1abb88869861f4 Reviewed-by: Jesus Fernandez Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- src/network/access/qnetworkaccessmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index b649aba4a8..57d110ed94 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1599,7 +1599,7 @@ void QNetworkAccessManagerPrivate::_q_networkSessionClosed() QObject::disconnect(networkSession.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed())); QObject::disconnect(networkSession.data(), SIGNAL(stateChanged(QNetworkSession::State)), q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State))); - QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(error(QNetworkSession::SessionError)), + QObject::disconnect(networkSession.data(), SIGNAL(error(QNetworkSession::SessionError)), q, SLOT(_q_networkSessionFailed(QNetworkSession::SessionError))); networkSessionStrongRef.clear(); -- cgit v1.2.3 From a4bd635b33d08a4b58fb4db8cefd1e0535fb95eb Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 21 Nov 2016 17:05:49 +0100 Subject: Typo fix in QDateTime::toString() documentation Text that should simply have been naming days of the week used Qt::Sunday rather than the simple day name. Change-Id: I64a3cdacd854c1c9c0fbf2d11826555086d674f4 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 3e29b55666..5f5023e8b5 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3611,7 +3611,7 @@ QString QDateTime::toString(Qt::DateFormat format) const \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses the system locale to localize the name, i.e. QLocale::system(). \row \li dddd - \li the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). + \li the long localized day name (e.g. 'Monday' to 'Sunday'). Uses the system locale to localize the name, i.e. QLocale::system(). \row \li M \li the month as number without a leading zero (1-12) \row \li MM \li the month as number with a leading zero (01-12) -- cgit v1.2.3 From 0aa3de46cacacdb83efe1d5e5b2506560c93c9ff Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 7 Nov 2016 10:09:06 +0100 Subject: Fix two leaky uses of realloc() If it fails, we get NULL back but haven't free()d the old pointer; saving the NULL return over the old pointer forgets it, leaking the memory it pointed to. This is particularly severe in the JSON parser's grow(), where reading a very large JSON document can lead to the last successful realloc() in a doubling pattern being very large indeed; the subsequent failure will leak this very last allocation. Only worth checking for, however, when the subsequent code takes care to handle failure: in most cases, if realloc() fails, we're about to crash anyway. Change-Id: Icd3a503f169be224f0a058c58e8b7c82a3241ae7 Reviewed-by: Marc Mutz Reviewed-by: Anton Kudryavtsev --- src/corelib/json/qjsonparser.cpp | 5 +++-- src/corelib/json/qjsonparser_p.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp index c7b16d5ec9..a23741a85c 100644 --- a/src/corelib/json/qjsonparser.cpp +++ b/src/corelib/json/qjsonparser.cpp @@ -491,9 +491,10 @@ namespace { memcpy(newValues, data, size*sizeof(QJsonPrivate::Value)); data = newValues; } else { - data = static_cast(realloc(data, alloc*sizeof(QJsonPrivate::Value))); - if (!data) + void *newValues = realloc(data, alloc * sizeof(QJsonPrivate::Value)); + if (!newValues) return false; + data = static_cast(newValues); } return true; } diff --git a/src/corelib/json/qjsonparser_p.h b/src/corelib/json/qjsonparser_p.h index 82a7899a51..b17d75fb3a 100644 --- a/src/corelib/json/qjsonparser_p.h +++ b/src/corelib/json/qjsonparser_p.h @@ -101,11 +101,12 @@ private: inline int reserveSpace(int space) { if (current + space >= dataLength) { dataLength = 2*dataLength + space; - data = (char *)realloc(data, dataLength); - if (!data) { + char *newData = (char *)realloc(data, dataLength); + if (!newData) { lastError = QJsonParseError::DocumentTooLarge; return -1; } + data = newData; } int pos = current; current += space; -- cgit v1.2.3 From 7c41ced98c3cb5484069c14c45733d3129e7945a Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 2 Feb 2016 17:35:09 +0100 Subject: QDateTimeParser: introduce at least some encapsulation Shuffled its parts to make clear which bits are public, private and protected. QDateTimeEditPrivate makes rather heavy use of the last. Change-Id: Ic5f9d0c5cc85f02e57d3f31e9ac31a17428c5311 Reviewed-by: Timur Pocheptsov --- src/corelib/tools/qdatetimeparser_p.h | 81 ++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index 90c6a8acba..0ac7532aed 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -97,14 +97,6 @@ public: none.zeroesAdded = 0; } virtual ~QDateTimeParser() {} - enum AmPmFinder { - Neither = -1, - AM = 0, - PM = 1, - PossibleAM = 2, - PossiblePM = 3, - PossibleBoth = 4 - }; enum Section { NoSection = 0x00000, @@ -180,62 +172,75 @@ public: #ifndef QT_NO_DATESTRING StateNode parse(QString &input, int &cursorPosition, const QDateTime ¤tValue, bool fixup) const; #endif - int sectionMaxSize(int index) const; - int sectionSize(int index) const; - int sectionMaxSize(Section s, int count) const; - int sectionPos(int index) const; - int sectionPos(const SectionNode &sn) const; - - const SectionNode §ionNode(int index) const; - Section sectionType(int index) const; - QString sectionText(int sectionIndex) const; - QString sectionText(const QString &text, int sectionIndex, int index) const; - int getDigit(const QDateTime &dt, int index) const; - bool setDigit(QDateTime &t, int index, int newval) const; - int parseSection(const QDateTime ¤tValue, int sectionIndex, QString &txt, int &cursorPosition, - int index, QDateTimeParser::State &state, int *used = 0) const; - int absoluteMax(int index, const QDateTime &value = QDateTime()) const; - int absoluteMin(int index) const; bool parseFormat(const QString &format); #ifndef QT_NO_DATESTRING bool fromString(const QString &text, QDate *date, QTime *time) const; #endif + enum FieldInfoFlag { + Numeric = 0x01, + FixedWidth = 0x02, + AllowPartial = 0x04, + Fraction = 0x08 + }; + Q_DECLARE_FLAGS(FieldInfo, FieldInfoFlag) + + FieldInfo fieldInfo(int index) const; + + void setDefaultLocale(const QLocale &loc) { defaultLocale = loc; } + virtual QString displayText() const { return text; } + +private: + int sectionMaxSize(Section s, int count) const; + QString sectionText(const QString &text, int sectionIndex, int index) const; + int parseSection(const QDateTime ¤tValue, int sectionIndex, QString &txt, int &cursorPosition, + int index, QDateTimeParser::State &state, int *used = 0) const; #ifndef QT_NO_TEXTDATE int findMonth(const QString &str1, int monthstart, int sectionIndex, QString *monthName = 0, int *used = 0) const; int findDay(const QString &str1, int intDaystart, int sectionIndex, QString *dayName = 0, int *used = 0) const; #endif + + enum AmPmFinder { + Neither = -1, + AM = 0, + PM = 1, + PossibleAM = 2, + PossiblePM = 3, + PossibleBoth = 4 + }; AmPmFinder findAmPm(QString &str, int index, int *used = 0) const; bool potentialValue(const QString &str, int min, int max, int index, const QDateTime ¤tValue, int insert) const; - bool skipToNextSection(int section, const QDateTime ¤t, const QString §ionText) const; - QString stateName(State s) const; +protected: // for the benefit of QDateTimeEditPrivate + int sectionSize(int index) const; + int sectionMaxSize(int index) const; + int sectionPos(int index) const; + int sectionPos(const SectionNode &sn) const; - enum FieldInfoFlag { - Numeric = 0x01, - FixedWidth = 0x02, - AllowPartial = 0x04, - Fraction = 0x08 - }; - Q_DECLARE_FLAGS(FieldInfo, FieldInfoFlag) + const SectionNode §ionNode(int index) const; + Section sectionType(int index) const; + QString sectionText(int sectionIndex) const; + int getDigit(const QDateTime &dt, int index) const; + bool setDigit(QDateTime &t, int index, int newval) const; - FieldInfo fieldInfo(int index) const; + int absoluteMax(int index, const QDateTime &value = QDateTime()) const; + int absoluteMin(int index) const; - void setDefaultLocale(const QLocale &loc) { defaultLocale = loc; } + bool skipToNextSection(int section, const QDateTime ¤t, const QString §ionText) const; + QString stateName(State s) const; virtual QDateTime getMinimum() const; virtual QDateTime getMaximum() const; virtual int cursorPosition() const { return -1; } - virtual QString displayText() const { return text; } virtual QString getAmPmText(AmPm ap, Case cs) const; virtual QLocale locale() const { return defaultLocale; } mutable int currentSectionIndex; Sections display; /* - This stores the stores the most recently selected day. + This stores the most recently selected day. It is useful when considering the following scenario: 1. Date is: 31/01/2000 @@ -255,9 +260,7 @@ public: QString displayFormat; QLocale defaultLocale; QVariant::Type parserType; - bool fixday; - Qt::TimeSpec spec; // spec if used by QDateTimeEdit Context context; }; -- cgit v1.2.3 From dc4c647137257fc7d3081db5d52f722c754e7dcb Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 21 Nov 2016 15:44:36 +0100 Subject: Clean up the resource reading code Instead of doing the conversion from the big-endian data by hand, let's use the convenience functions from qendian.h. Change-Id: If3966ca94428afabb1f5c922967fb9970f976622 Reviewed-by: hjk --- src/corelib/io/qresource.cpp | 69 +++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 72042e1600..febf22639c 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -49,6 +49,7 @@ #include "qdatetime.h" #include "qbytearray.h" #include "qstringlist.h" +#include "qendian.h" #include #include #include "private/qabstractfileengine_p.h" @@ -606,11 +607,9 @@ inline uint QResourceRoot::hash(int node) const if(!node) //root return 0; const int offset = findOffset(node); - int name_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) + - (tree[offset+2] << 8) + (tree[offset+3] << 0); + qint32 name_offset = qFromBigEndian(tree + offset); name_offset += 2; //jump past name length - return (names[name_offset+0] << 24) + (names[name_offset+1] << 16) + - (names[name_offset+2] << 8) + (names[name_offset+3] << 0); + return qFromBigEndian(names + name_offset); } inline QString QResourceRoot::name(int node) const { @@ -619,10 +618,8 @@ inline QString QResourceRoot::name(int node) const const int offset = findOffset(node); QString ret; - int name_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) + - (tree[offset+2] << 8) + (tree[offset+3] << 0); - const short name_length = (names[name_offset+0] << 8) + - (names[name_offset+1] << 0); + qint32 name_offset = qFromBigEndian(tree + offset); + const qint16 name_length = qFromBigEndian(names + name_offset); name_offset += 2; name_offset += 4; //jump past hash @@ -662,10 +659,8 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const return 0; //the root node is always first - int child_count = (tree[6] << 24) + (tree[7] << 16) + - (tree[8] << 8) + (tree[9] << 0); - int child = (tree[10] << 24) + (tree[11] << 16) + - (tree[12] << 8) + (tree[13] << 0); + qint32 child_count = qFromBigEndian(tree + 6); + qint32 child = qFromBigEndian(tree + 10); //now iterate up the tree int node = -1; @@ -711,18 +706,15 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const #endif offset += 4; //jump past name - const short flags = (tree[offset+0] << 8) + - (tree[offset+1] << 0); + const qint16 flags = qFromBigEndian(tree + offset); offset += 2; if(!splitter.hasNext()) { if(!(flags & Directory)) { - const short country = (tree[offset+0] << 8) + - (tree[offset+1] << 0); + const qint16 country = qFromBigEndian(tree + offset); offset += 2; - const short language = (tree[offset+0] << 8) + - (tree[offset+1] << 0); + const qint16 language = qFromBigEndian(tree + offset); offset += 2; #ifdef DEBUG_RESOURCE_MATCH qDebug() << " " << "LOCALE" << country << language; @@ -749,11 +741,9 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const if(!(flags & Directory)) return -1; - child_count = (tree[offset+0] << 24) + (tree[offset+1] << 16) + - (tree[offset+2] << 8) + (tree[offset+3] << 0); + child_count = qFromBigEndian(tree + offset); offset += 4; - child = (tree[offset+0] << 24) + (tree[offset+1] << 16) + - (tree[offset+2] << 8) + (tree[offset+3] << 0); + child = qFromBigEndian(tree + offset); break; } } @@ -771,7 +761,7 @@ short QResourceRoot::flags(int node) const if(node == -1) return 0; const int offset = findOffset(node) + 4; //jump past name - return (tree[offset+0] << 8) + (tree[offset+1] << 0); + return qFromBigEndian(tree + offset); } const uchar *QResourceRoot::data(int node, qint64 *size) const { @@ -781,16 +771,14 @@ const uchar *QResourceRoot::data(int node, qint64 *size) const } int offset = findOffset(node) + 4; //jump past name - const short flags = (tree[offset+0] << 8) + (tree[offset+1] << 0); + const qint16 flags = qFromBigEndian(tree + offset); offset += 2; offset += 4; //jump past locale if(!(flags & Directory)) { - const int data_offset = (tree[offset+0] << 24) + (tree[offset+1] << 16) + - (tree[offset+2] << 8) + (tree[offset+3] << 0); - const uint data_length = (payloads[data_offset+0] << 24) + (payloads[data_offset+1] << 16) + - (payloads[data_offset+2] << 8) + (payloads[data_offset+3] << 0); + const qint32 data_offset = qFromBigEndian(tree + offset); + const quint32 data_length = qFromBigEndian(payloads + data_offset); const uchar *ret = payloads+data_offset+4; *size = data_length; return ret; @@ -806,10 +794,7 @@ QDateTime QResourceRoot::lastModified(int node) const const int offset = findOffset(node) + 14; - const quint64 timeStamp = (quint64(tree[offset+0]) << 56) + (quint64(tree[offset+1]) << 48) + - (quint64(tree[offset+2]) << 40) + (quint64(tree[offset+3]) << 32) + - (quint64(tree[offset+4]) << 24) + (quint64(tree[offset+5]) << 16) + - (quint64(tree[offset+6]) << 8) + (quint64(tree[offset+7])); + const quint64 timeStamp = qFromBigEndian(tree + offset); if (timeStamp == 0) return QDateTime(); @@ -822,16 +807,14 @@ QStringList QResourceRoot::children(int node) const return QStringList(); int offset = findOffset(node) + 4; //jump past name - const short flags = (tree[offset+0] << 8) + (tree[offset+1] << 0); + const qint16 flags = qFromBigEndian(tree + offset); offset += 2; QStringList ret; if(flags & Directory) { - const int child_count = (tree[offset+0] << 24) + (tree[offset+1] << 16) + - (tree[offset+2] << 8) + (tree[offset+3] << 0); + const qint32 child_count = qFromBigEndian(tree + offset); offset += 4; - const int child_off = (tree[offset+0] << 24) + (tree[offset+1] << 16) + - (tree[offset+2] << 8) + (tree[offset+3] << 0); + const qint32 child_off = qFromBigEndian(tree + offset); ret.reserve(child_count); for(int i = child_off; i < child_off+child_count; ++i) ret << name(i); @@ -935,20 +918,16 @@ public: } offset += 4; - const int version = (b[offset+0] << 24) + (b[offset+1] << 16) + - (b[offset+2] << 8) + (b[offset+3] << 0); + const int version = qFromBigEndian(b + offset); offset += 4; - const int tree_offset = (b[offset+0] << 24) + (b[offset+1] << 16) + - (b[offset+2] << 8) + (b[offset+3] << 0); + const int tree_offset = qFromBigEndian(b + offset); offset += 4; - const int data_offset = (b[offset+0] << 24) + (b[offset+1] << 16) + - (b[offset+2] << 8) + (b[offset+3] << 0); + const int data_offset = qFromBigEndian(b + offset); offset += 4; - const int name_offset = (b[offset+0] << 24) + (b[offset+1] << 16) + - (b[offset+2] << 8) + (b[offset+3] << 0); + const int name_offset = qFromBigEndian(b + offset); offset += 4; // Some sanity checking for sizes. This is _not_ a security measure. -- cgit v1.2.3 From 34be7dc9d09c45a5e47a13716ee4db70f95dabcf Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 23 Nov 2016 11:50:35 +0100 Subject: Optimize fontdatabase fallbacksForFamily Short-cut the case-insensitive string comparison when lengths doesn't match. This reduces the time spend in ucstricmp from 8% during start-up of the textedit example, to under 1%. Change-Id: Ib3a92900b330453289ec9eff4830dfac6a9a5da2 Reviewed-by: Thiago Macieira --- src/gui/text/qfontdatabase.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index d2da24ca94..5145385fdc 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -406,9 +406,14 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) return foundries[count++]; } +static inline bool equalsCaseInsensitive(const QString &a, const QString &b) +{ + return a.size() == b.size() && a.compare(b, Qt::CaseInsensitive) == 0; +} + bool QtFontFamily::matchesFamilyName(const QString &familyName) const { - return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive); + return equalsCaseInsensitive(name, familyName) || aliases.contains(familyName, Qt::CaseInsensitive); } void QtFontFamily::ensurePopulated() -- cgit v1.2.3 From 4f896ba34e0f56e492da19c6d1353ac4ba4c7b2e Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Wed, 23 Nov 2016 11:39:31 +0100 Subject: ICC: Fix MySQL driver build In function `QMYSQLDriver::formatValue(QSqlField const&, bool) const': qsql_mysql.cpp:1569: undefined reference to `QString::operator=( QLatin1String) Change-Id: I56104cdd53fdc083670510f24b735cf05948f156 Reviewed-by: Samuel Gaist Reviewed-by: Milian Wolff Reviewed-by: Thiago Macieira --- src/sql/drivers/mysql/qsql_mysql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index c26c03ad07..4e86a0bd4e 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -1566,7 +1566,7 @@ QString QMYSQLDriver::formatValue(const QSqlField &field, bool trimStrings) cons Q_D(const QMYSQLDriver); QString r; if (field.isNull()) { - r = QLatin1String("NULL"); + r = QStringLiteral("NULL"); } else { switch(field.type()) { case QVariant::Double: -- cgit v1.2.3 From 72ed34b792f5acca5e0ada3b3d753b7a16274ff6 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 17 Nov 2016 13:23:47 +0100 Subject: Don't set platform specific QT_NO_FOO defines in qglobal.h They should be enabled/disabled through the configuration system. Remove some unused defines, and move one define from qglobal.h to a proper feature definition in Qt Gui. Change-Id: Ie8d5bff9712ba745af60b42ceca3f0440bed2706 Reviewed-by: Thiago Macieira --- src/corelib/configure.json | 8 ++++++- src/corelib/global/qglobal.h | 26 ---------------------- src/gui/configure.json | 7 ++++++ src/network/configure.json | 2 ++ .../services/genericunix/qgenericunixservices.cpp | 3 ++- 5 files changed, 18 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 5017f4652a..0d1954c3a8 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -396,13 +396,17 @@ "label": "QSharedMemory", "purpose": "Provides access to a shared memory segment.", "section": "Kernel", + "condition": "!config.vxworks", "output": [ "publicFeature", "feature" ] }, "systemsemaphore": { "label": "QSystemSemaphore", "purpose": "Provides a general counting system semaphore.", "section": "Kernel", - "condition": "config.android || config.win32 || tests.ipc_sysv || tests.ipc_posix", + "condition": [ + "!config.integrity && !config.vxworks", + "config.android || config.win32 || tests.ipc_sysv || tests.ipc_posix" + ], "output": [ "publicFeature", "feature" ] }, "xmlstream": { @@ -442,6 +446,7 @@ "label": "QProcess", "purpose": "Supports external process invocation.", "section": "File I/O", + "condition": "!config.winrt && !config.uikit && !config.integrity && !config.vxworks", "output": [ "publicFeature", "feature" ] }, "temporaryfile": { @@ -466,6 +471,7 @@ "label": "QFileSystemWatcher", "purpose": "Provides an interface for monitoring files and directories for modifications.", "section": "File I/O", + "condition": "!config.winrt", "output": [ "publicFeature", "feature" ] }, "filesystemiterator": { diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 99be82f8c3..1737f58c87 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -619,32 +619,6 @@ private: class QDataStream; -#if defined(Q_OS_VXWORKS) -# define QT_NO_CRASHHANDLER // no popen -# define QT_NO_PROCESS // no exec*, no fork -# define QT_NO_SHAREDMEMORY // only POSIX, no SysV and in the end... -# define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space -#endif - -#if defined(Q_OS_WINRT) -# define QT_NO_FILESYSTEMWATCHER -# define QT_NO_NETWORKPROXY -# define QT_NO_PROCESS -# define QT_NO_SOCKETNOTIFIER -# define QT_NO_SOCKS5 -#endif - -#if defined(QT_PLATFORM_UIKIT) -# define QT_NO_PROCESS -#endif - -#if defined(Q_OS_INTEGRITY) -# define QT_NO_CRASHHANDLER // no popen -# define QT_NO_PROCESS // no exec*, no fork -# define QT_NO_SYSTEMSEMAPHORE // not needed at all in a single AddressSpace -# define QT_NO_MULTIPROCESS // no system -#endif - inline void qt_noop(void) {} /* These wrap try/catch so we can switch off exceptions later. diff --git a/src/gui/configure.json b/src/gui/configure.json index 6fba8173b4..1f5011617c 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -964,6 +964,13 @@ "section": "Utilities", "condition": "features.properties", "output": [ "publicFeature", "feature" ] + }, + "multiprocess": { + "label": "Multi process", + "description": "Provides support for detecting the desktop environment, launching external processes and opening URLs.", + "section": "Utilities", + "condition": "!config.integrity", + "output": [ "privateFeature" ] } }, diff --git a/src/network/configure.json b/src/network/configure.json index 30a1c39c0c..1e08aa7c49 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -207,12 +207,14 @@ "label": "QNetworkProxy", "purpose": "Provides network proxy support.", "section": "Networking", + "condition": "!config.winrt", "output": [ "publicFeature", "feature" ] }, "socks5": { "label": "SOCKS5", "purpose": "Provides SOCKS5 support in QNetworkProxy.", "section": "Networking", + "condition": "!config.winrt", "output": [ "publicFeature", "feature" ] }, "networkinterface": { diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 5242f00193..a24ab82057 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qgenericunixservices_p.h" +#include #include #include @@ -48,7 +49,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_MULTIPROCESS +#if QT_CONFIG(multiprocess) enum { debug = 0 }; -- cgit v1.2.3 From 0861c2176c6dc1c69b733c1a843c2db5ec8ea786 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 18 Nov 2016 13:39:32 +0100 Subject: Use harfbuzz feature to check for HarfBuzz instead of defining a special macro for it. Change-Id: I715380717f7d871571f663be30b73f7d95d83d71 Reviewed-by: Konstantin Ritt --- src/gui/text/qfontengine.cpp | 10 +++++----- src/gui/text/qharfbuzzng_p.h | 3 +++ src/gui/text/qtextengine.cpp | 19 ++++++++++--------- src/gui/text/qtextengine_p.h | 2 +- src/gui/text/text.pri | 4 +--- 5 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 74ea8d15b7..a7d7185a7e 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -53,7 +53,7 @@ #include #include -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) # include "qharfbuzzng_p.h" # include #endif @@ -93,7 +93,7 @@ static inline bool qSafeFromBigEndian(const uchar *source, const uchar *end, T * // Harfbuzz helper functions -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) Q_GLOBAL_STATIC_WITH_ARGS(bool, useHarfbuzzNG,(qgetenv("QT_HARFBUZZ") != "old")) bool qt_useHarfbuzzNG() @@ -296,7 +296,7 @@ QFixed QFontEngine::underlinePosition() const void *QFontEngine::harfbuzzFont() const { Q_ASSERT(type() != QFontEngine::Multi); -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (qt_useHarfbuzzNG()) return hb_qt_font_get_for_engine(const_cast(this)); #endif @@ -331,7 +331,7 @@ void *QFontEngine::harfbuzzFont() const void *QFontEngine::harfbuzzFace() const { Q_ASSERT(type() != QFontEngine::Multi); -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (qt_useHarfbuzzNG()) return hb_qt_face_get_for_engine(const_cast(this)); #endif @@ -363,7 +363,7 @@ bool QFontEngine::supportsScript(QChar::Script script) const return true; } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (qt_useHarfbuzzNG()) { #if defined(Q_OS_DARWIN) // in AAT fonts, 'gsub' table is effectively replaced by 'mort'/'morx' table diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h index 95a21eedb6..fabf222bae 100644 --- a/src/gui/text/qharfbuzzng_p.h +++ b/src/gui/text/qharfbuzzng_p.h @@ -53,6 +53,9 @@ // #include + +QT_REQUIRE_CONFIG(harfbuzz); + #include #include diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 742b01dd1f..67cafa53fe 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -37,6 +37,7 @@ ** ****************************************************************************/ +#include #include "qdebug.h" #include "qtextformat.h" #include "qtextformat_p.h" @@ -837,7 +838,7 @@ enum JustificationClass { Justification_Arabic_Kashida = 13 // User-inserted Kashida(U+0640) }; -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) /* Adds an inter character justification opportunity after the number or letter @@ -916,7 +917,7 @@ static inline void qt_getJustificationOpportunities(const ushort *string, int le qt_getDefaultJustificationOpportunities(string, length, g, log_clusters, spaceAs); } -#endif // QT_ENABLE_HARFBUZZ_NG +#endif // harfbuzz // shape all the items that intersect with the line, taking tab widths into account to find out what text actually fits in the line. @@ -950,7 +951,7 @@ void QTextEngine::shapeLine(const QScriptLine &line) } } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) extern bool qt_useHarfbuzzNG(); // defined in qfontengine.cpp #endif @@ -1063,7 +1064,7 @@ void QTextEngine::shapeText(int item) const letterSpacing *= font.d->dpi / qt_defaultDpiY(); } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (Q_LIKELY(qt_useHarfbuzzNG())) si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0); else @@ -1079,7 +1080,7 @@ void QTextEngine::shapeText(int item) const QGlyphLayout glyphs = shapedGlyphs(&si); -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (Q_LIKELY(qt_useHarfbuzzNG())) qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si)); #endif @@ -1119,7 +1120,7 @@ void QTextEngine::shapeText(int item) const si.width += glyphs.advances[i] * !glyphs.attributes[i].dontPrint; } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) QT_BEGIN_INCLUDE_NAMESPACE @@ -1313,7 +1314,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, return glyphs_shaped; } -#endif // QT_ENABLE_HARFBUZZ_NG +#endif // harfbuzz QT_BEGIN_INCLUDE_NAMESPACE @@ -1669,7 +1670,7 @@ void QTextEngine::itemize() const analysis->flags = QScriptAnalysis::None; break; } -#ifndef QT_ENABLE_HARFBUZZ_NG +#if !QT_CONFIG(harfbuzz) analysis->script = hbscript_to_script(script_to_hbscript(analysis->script)); #endif ++uc; @@ -1678,7 +1679,7 @@ void QTextEngine::itemize() const if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) { (analysis-1)->flags = QScriptAnalysis::LineOrParagraphSeparator; // to exclude it from width } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) analysis = scriptAnalysis.data(); if (qt_useHarfbuzzNG()) { // ### pretend HB-old behavior for now diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 160e9ce490..f49e2638f5 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -649,7 +649,7 @@ private: void setBoundary(int strPos) const; void addRequiredBoundaries() const; void shapeText(int item) const; -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) int shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index a15793ec2f..efd041a5af 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -78,9 +78,7 @@ SOURCES += \ HEADERS += \ text/qplatformfontdatabase.h -qtConfig(harfbuzz)|qtConfig(system-harfbuzz) { - DEFINES += QT_ENABLE_HARFBUZZ_NG - +qtConfig(harfbuzz) { QMAKE_USE_PRIVATE += harfbuzz SOURCES += text/qharfbuzzng.cpp -- cgit v1.2.3 From 5bd2d6afec935a9eb4cf39af830f450f89f7202a Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 24 Nov 2016 10:54:03 +0200 Subject: Remove nokia reference in example mimetype Change-Id: I45c01fd57171f4ba6ea195d7ad3ae988a1797acb Reviewed-by: Oswald Buddenhagen Reviewed-by: David Faure --- src/corelib/mimetypes/qmimedatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 5c272d420b..91b50494d0 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -257,7 +257,7 @@ bool QMimeDatabasePrivate::inherits(const QString &mime, const QString &parent) \code - + Qt qmake Profile -- cgit v1.2.3 From 600c5a7e1bb59f97205e0a50ccc05937a31b9480 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 15 Nov 2016 14:43:45 +0100 Subject: Document third-party code in Cocoa QPA plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2c30f5da25c83d6129403cb9b745a2f17fd6fd9e Reviewed-by: Topi Reiniö --- src/plugins/platforms/cocoa/COCOA_LICENSE.txt | 29 +++++++++++++++++++++++++ src/plugins/platforms/cocoa/qt_attribution.json | 13 +++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/plugins/platforms/cocoa/COCOA_LICENSE.txt create mode 100644 src/plugins/platforms/cocoa/qt_attribution.json (limited to 'src') diff --git a/src/plugins/platforms/cocoa/COCOA_LICENSE.txt b/src/plugins/platforms/cocoa/COCOA_LICENSE.txt new file mode 100644 index 0000000000..8c08f48528 --- /dev/null +++ b/src/plugins/platforms/cocoa/COCOA_LICENSE.txt @@ -0,0 +1,29 @@ +Copyright (c) 2007-2008, Apple, Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of Apple, Inc. nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/plugins/platforms/cocoa/qt_attribution.json b/src/plugins/platforms/cocoa/qt_attribution.json new file mode 100644 index 0000000000..37c0937f29 --- /dev/null +++ b/src/plugins/platforms/cocoa/qt_attribution.json @@ -0,0 +1,13 @@ +{ + "Id": "cocoa-platform-plugin", + "Name": "Cocoa Platform Plugin", + "QDocModule": "qtgui", + "QtUsage": "Code used in the Qt Platform Abstraction (QPA) for macOS.", + "Files": "qcocoaapplication.h qcocoaapplication.mm qcocoaapplicationdelegate.h qcocoaapplicationdelegate.mm qcocoaeventdispatcher.h qcocoaeventdispatcher.mm qcocoaintrospection.h qcocoaintrospection.mm qcocoasystemtrayicon.mm qmacdefines_mac.h", + + "Description": "Allows Qt to integrate into Apple's Cocoa API.", + "LicenseId": "BSD-3-Clause", + "License": "BSD 3-clause \"New\" or \"Revised\" License", + "LicenseFile": "COCOA_LICENSE.txt", + "Copyright": "Copyright (c) 2007-2008, Apple, Inc." +} -- cgit v1.2.3 From 5cd4001bf2a7f0894c6ac269860e833b02df6cde Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Fri, 25 Nov 2016 13:12:54 +0300 Subject: Use separate Qt5Config.cmake inside build directory Qt5Config restricts search paths of Qt components to ${_qt5_install_prefix} to prevent accidentally using system Qt modules in case of restricted Qt configuration. However this does not work properly when Qt is used without installation, in particular when building cmake-based QtWebKit as a Qt submodule, because ${_qt5_install_prefix} resolves to QtBase and does not contain components from other modules. This patch changes search path from ${_qt5_install_prefix} to all qt5 subdirectories. Change-Id: Icf01a256097710889573ad69d847b9c3bffa1449 Reviewed-by: Kevin Funk Reviewed-by: Oswald Buddenhagen --- src/corelib/Qt5Config.cmake.in | 12 +++++++++--- src/corelib/Qt5ModuleLocation.cmake.in | 15 +++++++++++++++ src/corelib/Qt5ModuleLocationForInstall.cmake.in | 4 ++++ src/corelib/corelib.pro | 21 +++++++++++++++++++-- 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 src/corelib/Qt5ModuleLocation.cmake.in create mode 100644 src/corelib/Qt5ModuleLocationForInstall.cmake.in (limited to 'src') diff --git a/src/corelib/Qt5Config.cmake.in b/src/corelib/Qt5Config.cmake.in index a872d0e917..75b53485b7 100644 --- a/src/corelib/Qt5Config.cmake.in +++ b/src/corelib/Qt5Config.cmake.in @@ -22,18 +22,24 @@ get_filename_component(_qt5_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/..\" ABSO set(_Qt5_NOTFOUND_MESSAGE) +include(${CMAKE_CURRENT_LIST_DIR}/Qt5ModuleLocation.cmake) + foreach(module ${Qt5_FIND_COMPONENTS}) find_package(Qt5${module} ${_Qt5_FIND_PARTS_QUIET} ${_Qt5_FIND_PARTS_REQUIRED} - PATHS \"${_qt5_install_prefix}\" NO_DEFAULT_PATH + PATHS ${_qt5_module_paths} NO_DEFAULT_PATH ) if (NOT Qt5${module}_FOUND) + string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY) + if (Qt5_FIND_REQUIRED_${module}) - set(_Qt5_NOTFOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_qt5_install_prefix}/Qt5${module}/Qt5${module}Config.cmake\\\"\\n\") + set(_Qt5_NOTFOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_expected_module_location}\\\"\\n\") elseif(NOT Qt5_FIND_QUIETLY) - message(WARNING \"Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_qt5_install_prefix}/Qt5${module}/Qt5${module}Config.cmake\\\"\") + message(WARNING \"Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_expected_module_location}\\\"\") endif() + + unset(_expected_module_location) endif() endforeach() diff --git a/src/corelib/Qt5ModuleLocation.cmake.in b/src/corelib/Qt5ModuleLocation.cmake.in new file mode 100644 index 0000000000..5065ada56e --- /dev/null +++ b/src/corelib/Qt5ModuleLocation.cmake.in @@ -0,0 +1,15 @@ +!!IF !isEmpty(_QMAKE_SUPER_CACHE_) +get_filename_component(_qt5_root_dir \"${CMAKE_CURRENT_LIST_DIR}/../../../..\" ABSOLUTE) + +file(GLOB qtmodules ${_qt5_root_dir} "${_qt5_root_dir}/*") +foreach(qtmodule ${qtmodules}) + if(IS_DIRECTORY ${qtmodule}) + list(APPEND _qt5_module_paths ${qtmodule}) + endif() +endforeach() +!!ELSE +set(_qt5_root_dir ${_qt5_install_prefix}) +set(_qt5_module_paths ${_qt5_install_prefix}) +!!ENDIF + +set(_qt5_module_location_template ${_qt5_root_dir}) diff --git a/src/corelib/Qt5ModuleLocationForInstall.cmake.in b/src/corelib/Qt5ModuleLocationForInstall.cmake.in new file mode 100644 index 0000000000..e401b1fe34 --- /dev/null +++ b/src/corelib/Qt5ModuleLocationForInstall.cmake.in @@ -0,0 +1,4 @@ +set(_qt5_root_dir ${_qt5_install_prefix}) +set(_qt5_module_paths ${_qt5_install_prefix}) + +set(_qt5_module_location_template ${_qt5_install_prefix}/Qt5@module@/Qt5@module@Config.cmake) diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 616a9641a1..0bd7c9b99d 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -93,6 +93,12 @@ ctest_macros_file.CONFIG = verbatim cmake_umbrella_config_file.input = $$PWD/Qt5Config.cmake.in cmake_umbrella_config_file.output = $$DESTDIR/cmake/Qt5/Qt5Config.cmake +cmake_umbrella_config_module_location.input = $$PWD/Qt5ModuleLocation.cmake.in +cmake_umbrella_config_module_location.output = $$DESTDIR/cmake/Qt5/Qt5ModuleLocation.cmake + +cmake_umbrella_config_module_location_for_install.input = $$PWD/Qt5ModuleLocationForInstall.cmake.in +cmake_umbrella_config_module_location_for_install.output = $$DESTDIR/cmake/install/Qt5/Qt5ModuleLocation.cmake + cmake_umbrella_config_version_file.input = $$PWD/../../mkspecs/features/data/cmake/Qt5ConfigVersion.cmake.in cmake_umbrella_config_version_file.output = $$DESTDIR/cmake/Qt5/Qt5ConfigVersion.cmake @@ -119,10 +125,21 @@ contains(CMAKE_INSTALL_DATA_DIR, "^\\.\\./.*"):!isEmpty(CMAKE_INSTALL_DATA_DIR) cmake_extras_mkspec_dir_for_install.input = $$PWD/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in cmake_extras_mkspec_dir_for_install.output = $$DESTDIR/cmake/install/Qt5Core/Qt5CoreConfigExtrasMkspecDir.cmake -cmake_qt5_umbrella_module_files.files = $$cmake_umbrella_config_file.output $$cmake_umbrella_config_version_file.output +cmake_qt5_umbrella_module_files.files = \ + $$cmake_umbrella_config_file.output \ + $$cmake_umbrella_config_version_file.output \ + $$cmake_umbrella_config_module_location_for_install.output + cmake_qt5_umbrella_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5 -QMAKE_SUBSTITUTES += ctest_macros_file cmake_umbrella_config_file cmake_umbrella_config_version_file cmake_extras_mkspec_dir cmake_extras_mkspec_dir_for_install +QMAKE_SUBSTITUTES += \ + ctest_macros_file \ + cmake_umbrella_config_file \ + cmake_umbrella_config_module_location \ + cmake_umbrella_config_module_location_for_install \ + cmake_umbrella_config_version_file \ + cmake_extras_mkspec_dir \ + cmake_extras_mkspec_dir_for_install ctest_qt5_module_files.files += $$ctest_macros_file.output $$cmake_extras_mkspec_dir_for_install.output -- cgit v1.2.3 From 40c9e9dc5f31a4063a71e90208b5bf976977b054 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 Nov 2016 15:39:57 -0800 Subject: Add a macros for disabling deprecated declaration warnings This is the only warning we disable in a lot of places in Qt 5.8 source code. If other warnings become common, we can add macros for them too. Change-Id: Iaeecaffe26af4535b416fffd1489d1968e29c52a Reviewed-by: Oswald Buddenhagen Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qcompilerdetection.h | 6 ++++++ src/corelib/tools/qalgorithms.h | 3 +-- src/gui/image/qimage.h | 3 +-- src/testlib/qxctestlogger.mm | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index d1d5373146..d978c141a4 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1273,6 +1273,7 @@ # define QT_WARNING_DISABLE_INTEL(number) __pragma(warning(disable: number)) # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_GCC(text) +# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_INTEL(1786) #elif defined(Q_CC_INTEL) /* icc: Intel compiler on Linux or OS X */ # define QT_WARNING_PUSH QT_DO_PRAGMA(warning(push)) @@ -1281,6 +1282,7 @@ # define QT_WARNING_DISABLE_MSVC(number) # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_GCC(text) +# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_INTEL(1786) #elif defined(Q_CC_MSVC) && _MSC_VER >= 1500 && !defined(Q_CC_CLANG) # undef QT_DO_PRAGMA /* not needed */ # define QT_WARNING_PUSH __pragma(warning(push)) @@ -1289,6 +1291,7 @@ # define QT_WARNING_DISABLE_INTEL(number) # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_GCC(text) +# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_MSVC(4996) #elif defined(Q_CC_CLANG) # define QT_WARNING_PUSH QT_DO_PRAGMA(clang diagnostic push) # define QT_WARNING_POP QT_DO_PRAGMA(clang diagnostic pop) @@ -1296,6 +1299,7 @@ # define QT_WARNING_DISABLE_GCC(text) # define QT_WARNING_DISABLE_INTEL(number) # define QT_WARNING_DISABLE_MSVC(number) +# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") #elif defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) # define QT_WARNING_PUSH QT_DO_PRAGMA(GCC diagnostic push) # define QT_WARNING_POP QT_DO_PRAGMA(GCC diagnostic pop) @@ -1303,6 +1307,7 @@ # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_INTEL(number) # define QT_WARNING_DISABLE_MSVC(number) +# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") #else // All other compilers, GCC < 4.6 and MSVC < 2008 # define QT_WARNING_DISABLE_GCC(text) # define QT_WARNING_PUSH @@ -1311,6 +1316,7 @@ # define QT_WARNING_DISABLE_MSVC(number) # define QT_WARNING_DISABLE_CLANG(text) # define QT_WARNING_DISABLE_GCC(text) +# define QT_WARNING_DISABLE_DEPRECATED #endif /* diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 38753a6726..303374b06d 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -48,8 +48,7 @@ QT_BEGIN_NAMESPACE QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") -QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") +QT_WARNING_DISABLE_DEPRECATED /* Warning: The contents of QAlgorithmsPrivate is not a part of the public Qt API diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 91aaf673d0..fd2298561e 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -381,8 +381,7 @@ inline void QImage::setPixelColor(const QPoint &pt, const QColor &c) { setPixelC #if QT_DEPRECATED_SINCE(5, 0) QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") -QT_WARNING_DISABLE_MSVC(4996) +QT_WARNING_DISABLE_DEPRECATED inline QString QImage::text(const char* key, const char* lang) const { diff --git a/src/testlib/qxctestlogger.mm b/src/testlib/qxctestlogger.mm index ffabe88db2..62fd73070f 100644 --- a/src/testlib/qxctestlogger.mm +++ b/src/testlib/qxctestlogger.mm @@ -66,7 +66,7 @@ QT_WARNING_PUSH // Ignore XCTestProbe deprecation -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") +QT_WARNING_DISABLE_DEPRECATED // --------------------------------------------------------- -- cgit v1.2.3 From 277208c169e94ebb8eb1a1c9bd46a844f50aa5f9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 Nov 2016 15:41:18 -0800 Subject: moc: disable deprecated warnings in generated code Code generated by moc very often calls deprecated functions, like deprecated slots, signals and property getters and setters. There's no way around that unless the class in question is willing to break binary compatibility, so those warnings are actually harmless. Change-Id: Iaeecaffe26af4535b416fffd1489d1a98ef8b34a Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/moc.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 3bd87e1f01..89bf2bd6a1 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1002,12 +1002,17 @@ void Moc::generate(FILE *out) fprintf(out, "#endif\n\n"); fprintf(out, "QT_BEGIN_MOC_NAMESPACE\n"); + fprintf(out, "QT_WARNING_PUSH\n"); + fprintf(out, "QT_WARNING_DISABLE_DEPRECATED\n"); + fputs("", out); for (i = 0; i < classList.size(); ++i) { Generator generator(&classList[i], metaTypes, knownQObjectClasses, knownGadgets, out); generator.generateCode(); } + fputs("", out); + fprintf(out, "QT_WARNING_POP\n"); fprintf(out, "QT_END_MOC_NAMESPACE\n"); } -- cgit v1.2.3 From 7eb4be9db89d40ea2cc090e7a562bdd588708607 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Sun, 13 Nov 2016 16:19:55 +0300 Subject: QStringRef: de-duplicate lastIndexOf code Change-Id: Id6d804b2ab4c9c763d7ec9cb66c255ed0b4f785d Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 77 ++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 4262899e02..eef375fe72 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -3260,6 +3260,23 @@ static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *nee return -1; } +static inline int lastIndexOfHelper( + const QStringRef &haystack, int from, const QStringRef &needle, Qt::CaseSensitivity cs) +{ + return lastIndexOfHelper(reinterpret_cast(haystack.unicode()), from, + reinterpret_cast(needle.unicode()), needle.size(), cs); +} + +static inline int lastIndexOfHelper( + const QStringRef &haystack, int from, QLatin1String needle, Qt::CaseSensitivity cs) +{ + const int size = needle.size(); + QVarLengthArray s(size); + qt_from_latin1(s.data(), needle.latin1(), size); + return lastIndexOfHelper(reinterpret_cast(haystack.unicode()), from, + s.data(), size, cs); +} + /*! Returns the index position of the last occurrence of the string \a str in this string, searching backward from index position \a @@ -9816,6 +9833,27 @@ int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const return qt_last_index_of(unicode(), size(), ch, from, cs); } +template +static int last_index_of_impl(const QStringRef &haystack, int from, const T &needle, Qt::CaseSensitivity cs) +{ + const int sl = needle.size(); + if (sl == 1) + return haystack.lastIndexOf(needle.at(0), from, cs); + + const int l = haystack.size(); + if (from < 0) + from += l; + int delta = l - sl; + if (from == l && sl == 0) + return from; + if (uint(from) >= uint(l) || delta < 0) + return -1; + if (from > delta) + from = delta; + + return lastIndexOfHelper(haystack, from, needle, cs); +} + /*! \since 4.8 \overload lastIndexOf() @@ -9833,25 +9871,7 @@ int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const */ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const { - const int sl = str.size(); - if (sl == 1) - return lastIndexOf(str.at(0), from, cs); - - const int l = size(); - if (from < 0) - from += l; - int delta = l - sl; - if (from == l && sl == 0) - return from; - if (uint(from) >= uint(l) || delta < 0) - return -1; - if (from > delta) - from = delta; - - QVarLengthArray s(sl); - qt_from_latin1(s.data(), str.latin1(), sl); - - return lastIndexOfHelper(reinterpret_cast(unicode()), from, s.data(), sl, cs); + return last_index_of_impl(*this, from, str, cs); } /*! @@ -9871,24 +9891,7 @@ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) */ int QStringRef::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const { - const int sl = str.size(); - if (sl == 1) - return lastIndexOf(str.at(0), from, cs); - - const int l = size(); - if (from < 0) - from += l; - int delta = l - sl; - if (from == l && sl == 0) - return from; - if (uint(from) >= uint(l) || delta < 0) - return -1; - if (from > delta) - from = delta; - - return lastIndexOfHelper(reinterpret_cast(unicode()), from, - reinterpret_cast(str.unicode()), - str.size(), cs); + return last_index_of_impl(*this, from, str, cs); } /*! -- cgit v1.2.3