From 57f38bc49d43140f3b04e625a47eb1e6de8d2ae3 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 4 Jun 2019 14:29:14 +0200 Subject: [PATCH 01/17] Do not "fixify" the content of extra compiler input variables twice MakefileGenerator::initOutPaths should only do that: init out paths. It's not supposed to modify the content of input variables for extra compilers. Those get "fixed" in MakefileGenerator::init below the "do the path fixifying" comment. The first "fixifying" would turn an absolute path in SOURCES (input variable for the moc_source extra compiler) into a path relative to the output directory. The second "fixifying" would mess everything up. Fixes: QTBUG-76097 Change-Id: I8c50ef33d097dba4a1db76144c70b0677beffb6c Reviewed-by: Kai Koehne --- qmake/generators/makefile.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index f3ca192ab2..f911f81020 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -199,7 +199,6 @@ MakefileGenerator::initOutPaths() ProStringList &inputs = project->values((*it2).toKey()); for (ProStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { QString finp = fileFixify((*input).toQString(), FileFixifyFromOutdir); - *input = ProString(finp); QString path = replaceExtraCompilerVariables(tmp_out, finp, QString(), NoShell); path = Option::normalizePath(path); int slash = path.lastIndexOf('/'); From b3cc9403c4f7814d3e14915fdacee42b3a805073 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 20 May 2019 17:40:12 +0200 Subject: [PATCH 02/17] QTextMarkdownWriter: write fenced code blocks with language declaration MD4C now makes it possible to detect indented and fenced code blocks: https://github.com/mity/md4c/issues/81 Fenced code blocks have the advantages of being easier to write by hand, and having an "info string" following the opening fence, which is commonly used to declare the language. Also, the HTML parser now recognizes tags of the form
which is one convention for declaring the programming language
(as opposed to human language, for which the lang attribute would be used):
https://stackoverflow.com/questions/5134242/semantics-standards-and-using-the-lang-attribute-for-source-code-in-markup
So it's possible to read HTML and write markdown without losing this information.

It's also possible to read markdown with any type of code block:
fenced with ``` or ~~~, or indented, and rewrite it the same way.

Change-Id: I33c2bf7d7b66c8f3ba5bdd41ab32572f09349c47
Reviewed-by: Gatis Paeglis 
---
 src/gui/text/qtextformat.cpp                  |  3 +
 src/gui/text/qtextformat.h                    |  1 +
 src/gui/text/qtexthtmlparser.cpp              |  4 ++
 src/gui/text/qtextmarkdownimporter.cpp        |  8 ++-
 src/gui/text/qtextmarkdownimporter_p.h        |  1 +
 src/gui/text/qtextmarkdownwriter.cpp          | 68 ++++++++++++++++---
 src/gui/text/qtextmarkdownwriter_p.h          |  5 +-
 .../qtextmarkdownwriter/data/blockquotes.md   | 52 ++++++++++----
 .../tst_qtextmarkdownwriter.cpp               |  3 +
 9 files changed, 119 insertions(+), 26 deletions(-)

diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 644dd5558d..090c6cc4ce 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -564,6 +564,9 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
     \value BlockTrailingHorizontalRulerWidth The width of a horizontal ruler element.
     \value HeadingLevel     The level of a heading, for example 1 corresponds to an HTML H1 tag; otherwise 0.
                             This enum value has been added in Qt 5.12.
+    \value BlockCodeFence   The character that was used in the "fences" around a Markdown code block.
+                            If the code block was indented rather than fenced, the block should not have this property.
+                            This enum value has been added in Qt 5.14.
 
     \value BlockQuoteLevel  The depth of nested quoting on this block: 1 means the block is a top-level block quote.
                             Blocks that are not block quotes should not have this property.
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index 4f534fb65d..a91461dcae 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -178,6 +178,7 @@ public:
         HeadingLevel = 0x1070,
         BlockQuoteLevel = 0x1080,
         BlockCodeLanguage = 0x1090,
+        BlockCodeFence = 0x1091,
         BlockMarker = 0x10A0,
 
         // character properties
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 49ee6394ee..642f0893b4 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1635,6 +1635,10 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes)
                 else if (key == QLatin1String("type"))
                     linkType = value;
                 break;
+            case Html_pre:
+                if (key == QLatin1String("class") && value.startsWith(QLatin1String("language-")))
+                    node->blockFormat.setProperty(QTextFormat::BlockCodeLanguage, value.mid(9));
+                break;
             default:
                 break;
         }
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp
index 223eb01e55..8a9bb3953c 100644
--- a/src/gui/text/qtextmarkdownimporter.cpp
+++ b/src/gui/text/qtextmarkdownimporter.cpp
@@ -165,12 +165,13 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
         MD_BLOCK_CODE_DETAIL *detail = static_cast(det);
         m_codeBlock = true;
         m_blockCodeLanguage = QLatin1String(detail->lang.text, int(detail->lang.size));
+        m_blockCodeFence = detail->fence_char;
         QString info = QLatin1String(detail->info.text, int(detail->info.size));
         m_needsInsertBlock = true;
         if (m_blockQuoteDepth)
-            qCDebug(lcMD, "CODE lang '%s' info '%s' inside QUOTE %d", qPrintable(m_blockCodeLanguage), qPrintable(info), m_blockQuoteDepth);
+            qCDebug(lcMD, "CODE lang '%s' info '%s' fenced with '%c' inside QUOTE %d", qPrintable(m_blockCodeLanguage), qPrintable(info), m_blockCodeFence, m_blockQuoteDepth);
         else
-            qCDebug(lcMD, "CODE lang '%s' info '%s'", qPrintable(m_blockCodeLanguage), qPrintable(info));
+            qCDebug(lcMD, "CODE lang '%s' info '%s' fenced with '%c'", qPrintable(m_blockCodeLanguage), qPrintable(info), m_blockCodeFence);
     } break;
     case MD_BLOCK_H: {
         MD_BLOCK_H_DETAIL *detail = static_cast(det);
@@ -326,6 +327,7 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail)
     case MD_BLOCK_CODE: {
         m_codeBlock = false;
         m_blockCodeLanguage.clear();
+        m_blockCodeFence = 0;
         if (m_blockQuoteDepth)
             qCDebug(lcMD, "CODE ended inside QUOTE %d", m_blockQuoteDepth);
         else
@@ -540,6 +542,8 @@ void QTextMarkdownImporter::insertBlock()
     }
     if (m_codeBlock) {
         blockFormat.setProperty(QTextFormat::BlockCodeLanguage, m_blockCodeLanguage);
+        if (m_blockCodeFence)
+            blockFormat.setProperty(QTextFormat::BlockCodeFence, QString(QLatin1Char(m_blockCodeFence)));
         charFormat.setFont(m_monoFont);
     } else {
         blockFormat.setTopMargin(m_paragraphMargin);
diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h
index fdce74483b..1b8c2ca354 100644
--- a/src/gui/text/qtextmarkdownimporter_p.h
+++ b/src/gui/text/qtextmarkdownimporter_p.h
@@ -124,6 +124,7 @@ private:
     int m_tableCol = -1; // because relative cell movements (e.g. m_cursor->movePosition(QTextCursor::NextCell)) don't work
     int m_paragraphMargin = 0;
     int m_blockType = 0;
+    char m_blockCodeFence = 0;
     Features m_features;
     QTextImageFormat m_imageFormat;
     QTextListFormat m_listFormat;
diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp
index 58e0c86b95..f351c8d20b 100644
--- a/src/gui/text/qtextmarkdownwriter.cpp
+++ b/src/gui/text/qtextmarkdownwriter.cpp
@@ -134,6 +134,24 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame)
             writeFrame(iterator.currentFrame());
         else { // no frame, it's a block
             QTextBlock block = iterator.currentBlock();
+            // Look ahead and detect some cases when we should
+            // suppress needless blank lines, when there will be a big change in block format
+            bool nextIsDifferent = false;
+            bool ending = false;
+            {
+                QTextFrame::iterator next = iterator;
+                ++next;
+                if (next.atEnd()) {
+                    nextIsDifferent = true;
+                    ending = true;
+                } else {
+                    QTextBlockFormat format = iterator.currentBlock().blockFormat();
+                    QTextBlockFormat nextFormat = next.currentBlock().blockFormat();
+                    if (nextFormat.indent() != format.indent() ||
+                            nextFormat.property(QTextFormat::BlockCodeLanguage) != format.property(QTextFormat::BlockCodeLanguage))
+                        nextIsDifferent = true;
+                }
+            }
             if (table) {
                 QTextTableCell cell = table->cellAt(block.position());
                 if (tableRow < cell.row()) {
@@ -150,7 +168,7 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame)
                 if (lastWasList)
                     m_stream << Newline;
             }
-            int endingCol = writeBlock(block, !table, table && tableRow == 0);
+            int endingCol = writeBlock(block, !table, table && tableRow == 0, nextIsDifferent);
             m_doubleNewlineWritten = false;
             if (table) {
                 QTextTableCell cell = table->cellAt(block.position());
@@ -162,11 +180,19 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame)
                     m_stream << QString(paddingLen, Space);
                 for (int col = cell.column(); col < spanEndCol; ++col)
                     m_stream << "|";
-            } else if (block.textList() || block.blockFormat().hasProperty(QTextFormat::BlockCodeLanguage)) {
+            } else if (m_fencedCodeBlock && ending) {
+                m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space)
+                         << m_codeBlockFence << Newline << Newline;
+                m_codeBlockFence.clear();
+            } else if (m_indentedCodeBlock && nextIsDifferent) {
                 m_stream << Newline;
             } else if (endingCol > 0) {
-                m_stream << Newline << Newline;
-                m_doubleNewlineWritten = true;
+                if (block.textList() || block.blockFormat().hasProperty(QTextFormat::BlockCodeLanguage)) {
+                    m_stream << Newline;
+                } else {
+                    m_stream << Newline << Newline;
+                    m_doubleNewlineWritten = true;
+                }
             }
             lastWasList = block.textList();
         }
@@ -259,11 +285,13 @@ static void maybeEscapeFirstChar(QString &s)
     }
 }
 
-int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ignoreFormat)
+int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ignoreFormat, bool ignoreEmpty)
 {
+    if (block.text().isEmpty() && ignoreEmpty)
+        return 0;
     const int ColumnLimit = 80;
     QTextBlockFormat blockFmt = block.blockFormat();
-    bool indentedCodeBlock = false;
+    bool missedBlankCodeBlockLine = false;
     if (block.textList()) { // it's a list-item
         auto fmt = block.textList()->format();
         const int listLevel = fmt.indent();
@@ -324,7 +352,28 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
     } else if (blockFmt.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) {
         m_stream << "- - -\n"; // unambiguous horizontal rule, not an underline under a heading
         return 0;
+    } else if (blockFmt.hasProperty(QTextFormat::BlockCodeFence) || blockFmt.stringProperty(QTextFormat::BlockCodeLanguage).length() > 0) {
+        // It's important to preserve blank lines in code blocks.  But blank lines in code blocks
+        // inside block quotes are getting preserved anyway (along with the "> " prefix).
+        if (!blockFmt.hasProperty(QTextFormat::BlockQuoteLevel))
+            missedBlankCodeBlockLine = true; // only if we don't get any fragments below
+        if (!m_fencedCodeBlock) {
+            QString fenceChar = blockFmt.stringProperty(QTextFormat::BlockCodeFence);
+            if (fenceChar.isEmpty())
+                fenceChar = QLatin1String("`");
+            m_codeBlockFence = QString(3, fenceChar.at(0));
+            // A block quote can contain an indented code block, but not vice-versa.
+            m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space) << m_codeBlockFence
+                     << Space << blockFmt.stringProperty(QTextFormat::BlockCodeLanguage) << Newline;
+            m_fencedCodeBlock = true;
+        }
     } else if (!blockFmt.indent()) {
+        if (m_fencedCodeBlock) {
+            m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space)
+                     << m_codeBlockFence << Newline;
+            m_fencedCodeBlock = false;
+            m_codeBlockFence.clear();
+        }
         m_wrappedLineIndent = 0;
         m_linePrefix.clear();
         if (blockFmt.hasProperty(QTextFormat::BlockQuoteLevel)) {
@@ -337,7 +386,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
         if (blockFmt.hasProperty(QTextFormat::BlockCodeLanguage)) {
             // A block quote can contain an indented code block, but not vice-versa.
             m_linePrefix += QString(4, Space);
-            indentedCodeBlock = true;
+            m_indentedCodeBlock = true;
         }
     }
     if (blockFmt.headingLevel())
@@ -358,6 +407,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
     bool strikeOut = false;
     QString backticks(Backtick);
     for (QTextBlock::Iterator frag = block.begin(); !frag.atEnd(); ++frag) {
+        missedBlankCodeBlockLine = false;
         QString fragmentText = frag.fragment().text();
         while (fragmentText.endsWith(Newline))
             fragmentText.chop(1);
@@ -401,7 +451,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
             bool monoFrag = fontInfo.fixedPitch();
             QString markers;
             if (!ignoreFormat) {
-                if (monoFrag != mono && !indentedCodeBlock) {
+                if (monoFrag != mono && !m_indentedCodeBlock && !m_fencedCodeBlock) {
                     if (monoFrag)
                         backticks = QString(adjacentBackticksCount(fragmentText) + 1, Backtick);
                     markers += backticks;
@@ -501,6 +551,8 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
         m_stream << "~~";
         col += 2;
     }
+    if (missedBlankCodeBlockLine)
+        m_stream << Newline;
     return col;
 }
 
diff --git a/src/gui/text/qtextmarkdownwriter_p.h b/src/gui/text/qtextmarkdownwriter_p.h
index 96ceb445cd..90310250ac 100644
--- a/src/gui/text/qtextmarkdownwriter_p.h
+++ b/src/gui/text/qtextmarkdownwriter_p.h
@@ -67,7 +67,7 @@ public:
     bool writeAll(const QTextDocument *document);
     void writeTable(const QAbstractItemModel *table);
 
-    int writeBlock(const QTextBlock &block, bool table, bool ignoreFormat);
+    int writeBlock(const QTextBlock &block, bool table, bool ignoreFormat, bool ignoreEmpty);
     void writeFrame(const QTextFrame *frame);
 
 private:
@@ -82,9 +82,12 @@ private:
     QTextDocument::MarkdownFeatures m_features;
     QMap m_listInfo;
     QString m_linePrefix;
+    QString m_codeBlockFence;
     int m_wrappedLineIndent = 0;
     int m_lastListIndent = 1;
     bool m_doubleNewlineWritten = false;
+    bool m_indentedCodeBlock = false;
+    bool m_fencedCodeBlock = false;
 };
 
 QT_END_NAMESPACE
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md
index 44c198fdc5..6336d0219f 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md
@@ -20,21 +20,43 @@ MacFarlane writes:
 > equivalent sample of Markdown. Here is a sample of AsciiDoc from the AsciiDoc
 > manual:
 
->     1. List item one.
->     +
->     List item one continued with a second paragraph followed by an
->     Indented block.
->     +
->     .................
->     $ ls *.sh
->     $ mv *.sh ~/tmp
->     .................
->     +
->     List item continued with a third paragraph.
->     
->     2. List item two continued with an open block.
->     ...
->     
+> ``` AsciiDoc
+> 1. List item one.
+> +
+> List item one continued with a second paragraph followed by an
+> Indented block.
+> +
+> .................
+> $ ls *.sh
+> $ mv *.sh ~/tmp
+> .................
+> +
+> List item continued with a third paragraph.
+> 
+> 2. List item two continued with an open block.
+> ...
+> ```
 The quotation includes an embedded quotation and a code quotation and ends with
 an ellipsis due to being incomplete.
 
+Now let's have an indented code block:
+
+    #include 
+    
+    int main(void)
+    {
+        printf("# hello markdown\n");
+        return 0;
+    }
+
+and end with a fenced code block:
+~~~ pseudocode
+#include 
+#include 
+
+a block {
+    a statement;
+    another statement;
+}
+~~~
+
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
index 1935e58dec..8d38cbb18a 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
@@ -419,6 +419,9 @@ void tst_QTextMarkdownWriter::fromHtml_data()
     QTest::newRow("image") <<
         "\"foo\"" <<
         "![foo](/url \"title\")\n\n";
+    QTest::newRow("code") <<
+        "
\n#include \"foo.h\"\n\nblock {\n    statement();\n}\n\n
" << + "``` pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n```\n\n"; // TODO // QTest::newRow("escaped number and paren after double newline") << // "

(The first sentence of this paragraph is a line, the next paragraph has a number

13) but that's not part of an ordered list" << From 29e3a4dfeaf5d4924eaa68824fb21998de687809 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 5 Jun 2019 12:58:54 +0200 Subject: [PATCH 03/17] Fix warnings & deprs in tst_qcoreapplication and tst_qguiapplication It's perhaps best to ensure that functions we are deprecating shall no longer be used in tests. Also, fix the "0 as nullptr" warnings. Change-Id: I2f22c9b9482e80fa120bcd728ec269198a36678f Reviewed-by: Richard Moe Gustavsen --- .../qcoreapplication/tst_qcoreapplication.cpp | 2 +- .../qguiapplication/qguiapplication.pro | 1 + .../qguiapplication/tst_qguiapplication.cpp | 50 +++++++++---------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 6adb393ddd..d68cefc807 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -611,7 +611,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() TestApplication app(argc, argv); ProcessEventsAlwaysSendsPostedEventsObject object; - QTime t; + QElapsedTimer t; t.start(); int i = 1; do { diff --git a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro index 895c2a0307..34b75a8397 100644 --- a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro +++ b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro @@ -6,6 +6,7 @@ INCLUDEPATH += $$CORE_TEST_PATH TARGET = tst_qguiapplication QT += gui-private +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050E00 SOURCES += tst_qguiapplication.cpp RESOURCES = tst_qguiapplication.qrc diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 09fec89de4..5ee25677bf 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -184,7 +184,7 @@ void tst_QGuiApplication::windowIcon() class DummyWindow : public QWindow { public: - DummyWindow() : m_focusObject(0) {} + DummyWindow() : m_focusObject(nullptr) {} virtual QObject *focusObject() const { @@ -204,7 +204,7 @@ public: void tst_QGuiApplication::focusObject() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) QSKIP("QWindow::requestActivate() is not supported."); @@ -271,15 +271,15 @@ void tst_QGuiApplication::focusObject() void tst_QGuiApplication::allWindows() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); QWindow *window1 = new QWindow; QWindow *window2 = new QWindow(window1); QVERIFY(app.allWindows().contains(window1)); QVERIFY(app.allWindows().contains(window2)); QCOMPARE(app.allWindows().count(), 2); delete window1; - window1 = 0; - window2 = 0; + window1 = nullptr; + window2 = nullptr; QVERIFY(!app.allWindows().contains(window2)); QVERIFY(!app.allWindows().contains(window1)); QCOMPARE(app.allWindows().count(), 0); @@ -288,15 +288,15 @@ void tst_QGuiApplication::allWindows() void tst_QGuiApplication::topLevelWindows() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); QWindow *window1 = new QWindow; QWindow *window2 = new QWindow(window1); QVERIFY(app.topLevelWindows().contains(window1)); QVERIFY(!app.topLevelWindows().contains(window2)); QCOMPARE(app.topLevelWindows().count(), 1); delete window1; - window1 = 0; - window2 = 0; + window1 = nullptr; + window2 = nullptr; QVERIFY(!app.topLevelWindows().contains(window2)); QVERIFY(!app.topLevelWindows().contains(window1)); QCOMPARE(app.topLevelWindows().count(), 0); @@ -306,7 +306,7 @@ class ShowCloseShowWindow : public QWindow { Q_OBJECT public: - ShowCloseShowWindow(bool showAgain, QWindow *parent = 0) + ShowCloseShowWindow(bool showAgain, QWindow *parent = nullptr) : QWindow(parent), showAgain(showAgain) { QTimer::singleShot(0, this, SLOT(doClose())); @@ -331,7 +331,7 @@ private: void tst_QGuiApplication::abortQuitOnShow() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); QScopedPointer window1(new ShowCloseShowWindow(false)); @@ -366,7 +366,7 @@ protected: } public: - FocusChangeWindow() : QWindow(), windowDuringFocusAboutToChange(0), windowDuringFocusOut(0) {} + FocusChangeWindow() : QWindow(), windowDuringFocusAboutToChange(nullptr), windowDuringFocusOut(nullptr) {} QWindow *windowDuringFocusAboutToChange; QWindow *windowDuringFocusOut; @@ -378,7 +378,7 @@ void tst_QGuiApplication::changeFocusWindow() QSKIP("WinRt does not support multiple native windows."); #endif int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) QSKIP("QWindow::requestActivate() is not supported."); @@ -430,7 +430,7 @@ void tst_QGuiApplication::changeFocusWindow() void tst_QGuiApplication::keyboardModifiers() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); QScopedPointer window(new QWindow); @@ -564,7 +564,7 @@ public: int leaves; int enters; - inline explicit BlockableWindow(QWindow *parent = 0) + inline explicit BlockableWindow(QWindow *parent = nullptr) : QWindow(parent), blocked(false), leaves(0), enters(0) {} bool event(QEvent *e) @@ -601,7 +601,7 @@ void tst_QGuiApplication::modalWindow() QSKIP("WinRt does not support multiple native windows."); #endif int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); int x = screenGeometry.left() + spacing; @@ -654,7 +654,7 @@ void tst_QGuiApplication::modalWindow() window2->show(); QVERIFY(QTest::qWaitForWindowExposed(window1.data())); QVERIFY(QTest::qWaitForWindowExposed(window2.data())); - QCOMPARE(app.modalWindow(), static_cast(0)); + QCOMPARE(app.modalWindow(), static_cast(nullptr)); QCOMPARE(window1->blocked, 0); QCOMPARE(childWindow1->blocked, 0); QCOMPARE(window2->blocked, 0); @@ -698,7 +698,7 @@ void tst_QGuiApplication::modalWindow() // everything is unblocked when applicationModalWindow1 is hidden applicationModalWindow1->hide(); - QCOMPARE(app.modalWindow(), static_cast(0)); + QCOMPARE(app.modalWindow(), static_cast(nullptr)); QCOMPARE(window1->blocked, 0); QCOMPARE(childWindow1->blocked, 0); // QTBUG-32242, blocked status needs to be set on children as well. QCOMPARE(window2->blocked, 0); @@ -750,7 +750,7 @@ void tst_QGuiApplication::modalWindow() // hide windowModalWindow2, windowModalWindow1 and window1 are unblocked windowModalWindow2->hide(); - QCOMPARE(app.modalWindow(), static_cast(0)); + QCOMPARE(app.modalWindow(), static_cast(nullptr)); QCOMPARE(window1->blocked, 0); QCOMPARE(window2->blocked, 0); QCOMPARE(windowModalWindow1->blocked, 0); @@ -815,7 +815,7 @@ void tst_QGuiApplication::modalWindow() // hide windowModalWindow1, everything is unblocked windowModalWindow1->hide(); - QCOMPARE(app.modalWindow(), static_cast(0)); + QCOMPARE(app.modalWindow(), static_cast(nullptr)); QCOMPARE(window1->blocked, 0); QCOMPARE(window2->blocked, 0); QCOMPARE(windowModalWindow1->blocked, 0); @@ -829,7 +829,7 @@ void tst_QGuiApplication::modalWindow() void tst_QGuiApplication::quitOnLastWindowClosed() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); QTimer timer; @@ -869,7 +869,7 @@ void tst_QGuiApplication::quitOnLastWindowClosed() void tst_QGuiApplication::quitOnLastWindowClosedMulti() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); QTimer timer; @@ -909,7 +909,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti() void tst_QGuiApplication::dontQuitOnLastWindowClosed() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); app.setQuitOnLastWindowClosed(false); QTimer timer; @@ -959,7 +959,7 @@ public: { if (key == "testplugin") return new TestPlugin; - return 0; + return nullptr; } }; @@ -1069,7 +1069,7 @@ void tst_QGuiApplication::testSetPaletteAttribute() QVERIFY(!QCoreApplication::testAttribute(Qt::AA_SetPalette)); QPalette palette; - palette.setColor(QPalette::Foreground, Qt::red); + palette.setColor(QPalette::WindowText, Qt::red); QGuiApplication::setPalette(palette); QVERIFY(QCoreApplication::testAttribute(Qt::AA_SetPalette)); @@ -1126,7 +1126,7 @@ void tst_QGuiApplication::settableStyleHints() int argc = 0; QScopedPointer app; if (appInstance) - app.reset(new QGuiApplication(argc, 0)); + app.reset(new QGuiApplication(argc, nullptr)); const int keyboardInputInterval = 555; QGuiApplication::styleHints()->setKeyboardInputInterval(keyboardInputInterval); From 548513a4bd050d3df0a85fed6e2d1a00ce06d2ab Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 27 May 2019 17:47:22 +0200 Subject: [PATCH 04/17] Separate out the time, zone, date code from corelib/tools/ We'll be adding calendar code here as well, and tools/ was getting rather crowded, so it looks like time to move out a reasonably coherent sub-bundle of it all. Change-Id: I7e8030f38c31aa307f519dd918a43fc44baa6aa1 Reviewed-by: Lars Knoll --- qmake/Makefile.unix | 4 +-- qmake/Makefile.win32 | 3 ++ src/corelib/corelib.pro | 1 + src/corelib/{tools => time}/qdatetime.cpp | 0 src/corelib/{tools => time}/qdatetime.h | 0 src/corelib/{tools => time}/qdatetime_p.h | 0 .../{tools => time}/qdatetimeparser.cpp | 0 .../{tools => time}/qdatetimeparser_p.h | 0 src/corelib/{tools => time}/qtimezone.cpp | 0 src/corelib/{tools => time}/qtimezone.h | 0 .../{tools => time}/qtimezoneprivate.cpp | 0 .../qtimezoneprivate_android.cpp | 0 .../{tools => time}/qtimezoneprivate_data_p.h | 0 .../{tools => time}/qtimezoneprivate_icu.cpp | 0 .../{tools => time}/qtimezoneprivate_mac.mm | 0 .../{tools => time}/qtimezoneprivate_p.h | 2 +- .../{tools => time}/qtimezoneprivate_tz.cpp | 3 +- .../{tools => time}/qtimezoneprivate_win.cpp | 0 src/corelib/time/time.pri | 34 +++++++++++++++++++ src/corelib/tools/qlocale.cpp | 2 +- src/corelib/tools/tools.pri | 30 ---------------- src/tools/bootstrap/bootstrap.pro | 2 +- tests/auto/corelib/corelib.pro | 1 + .../corelib/{tools => time}/qdate/.gitignore | 0 .../corelib/{tools => time}/qdate/qdate.pro | 0 .../{tools => time}/qdate/tst_qdate.cpp | 0 .../{tools => time}/qdatetime/.gitignore | 0 .../{tools => time}/qdatetime/BLACKLIST | 0 .../{tools => time}/qdatetime/qdatetime.pro | 0 .../qdatetime/tst_qdatetime.cpp | 0 .../qdatetime/tst_qdatetime_mac.mm | 0 .../corelib/{tools => time}/qtime/.gitignore | 0 .../corelib/{tools => time}/qtime/qtime.pro | 0 .../{tools => time}/qtime/tst_qtime.cpp | 0 .../{tools => time}/qtimezone/BLACKLIST | 0 .../{tools => time}/qtimezone/qtimezone.pro | 0 .../qtimezone/tst_qtimezone.cpp | 0 .../qtimezone/tst_qtimezone_darwin.mm | 0 tests/auto/corelib/time/time.pro | 6 ++++ tests/auto/corelib/tools/tools.pro | 4 --- tests/benchmarks/corelib/corelib.pro | 1 + .../corelib/{tools => time}/qdate/qdate.pro | 0 .../{tools => time}/qdate/tst_bench_qdate.cpp | 0 .../{tools => time}/qdatetime/main.cpp | 0 .../{tools => time}/qdatetime/qdatetime.pro | 0 .../{tools => time}/qtimezone/main.cpp | 0 .../{tools => time}/qtimezone/qtimezone.pro | 0 tests/benchmarks/corelib/time/time.pro | 5 +++ tests/benchmarks/corelib/tools/tools.pro | 2 -- util/locale_database/cldr2qtimezone.py | 4 +-- 50 files changed, 59 insertions(+), 45 deletions(-) rename src/corelib/{tools => time}/qdatetime.cpp (100%) rename src/corelib/{tools => time}/qdatetime.h (100%) rename src/corelib/{tools => time}/qdatetime_p.h (100%) rename src/corelib/{tools => time}/qdatetimeparser.cpp (100%) rename src/corelib/{tools => time}/qdatetimeparser_p.h (100%) rename src/corelib/{tools => time}/qtimezone.cpp (100%) rename src/corelib/{tools => time}/qtimezone.h (100%) rename src/corelib/{tools => time}/qtimezoneprivate.cpp (100%) rename src/corelib/{tools => time}/qtimezoneprivate_android.cpp (100%) rename src/corelib/{tools => time}/qtimezoneprivate_data_p.h (100%) rename src/corelib/{tools => time}/qtimezoneprivate_icu.cpp (100%) rename src/corelib/{tools => time}/qtimezoneprivate_mac.mm (100%) rename src/corelib/{tools => time}/qtimezoneprivate_p.h (99%) rename src/corelib/{tools => time}/qtimezoneprivate_tz.cpp (99%) rename src/corelib/{tools => time}/qtimezoneprivate_win.cpp (100%) create mode 100644 src/corelib/time/time.pri rename tests/auto/corelib/{tools => time}/qdate/.gitignore (100%) rename tests/auto/corelib/{tools => time}/qdate/qdate.pro (100%) rename tests/auto/corelib/{tools => time}/qdate/tst_qdate.cpp (100%) rename tests/auto/corelib/{tools => time}/qdatetime/.gitignore (100%) rename tests/auto/corelib/{tools => time}/qdatetime/BLACKLIST (100%) rename tests/auto/corelib/{tools => time}/qdatetime/qdatetime.pro (100%) rename tests/auto/corelib/{tools => time}/qdatetime/tst_qdatetime.cpp (100%) rename tests/auto/corelib/{tools => time}/qdatetime/tst_qdatetime_mac.mm (100%) rename tests/auto/corelib/{tools => time}/qtime/.gitignore (100%) rename tests/auto/corelib/{tools => time}/qtime/qtime.pro (100%) rename tests/auto/corelib/{tools => time}/qtime/tst_qtime.cpp (100%) rename tests/auto/corelib/{tools => time}/qtimezone/BLACKLIST (100%) rename tests/auto/corelib/{tools => time}/qtimezone/qtimezone.pro (100%) rename tests/auto/corelib/{tools => time}/qtimezone/tst_qtimezone.cpp (100%) rename tests/auto/corelib/{tools => time}/qtimezone/tst_qtimezone_darwin.mm (100%) create mode 100644 tests/auto/corelib/time/time.pro rename tests/benchmarks/corelib/{tools => time}/qdate/qdate.pro (100%) rename tests/benchmarks/corelib/{tools => time}/qdate/tst_bench_qdate.cpp (100%) rename tests/benchmarks/corelib/{tools => time}/qdatetime/main.cpp (100%) rename tests/benchmarks/corelib/{tools => time}/qdatetime/qdatetime.pro (100%) rename tests/benchmarks/corelib/{tools => time}/qtimezone/main.cpp (100%) rename tests/benchmarks/corelib/{tools => time}/qtimezone/qtimezone.pro (100%) create mode 100644 tests/benchmarks/corelib/time/time.pro diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 9898346dbe..069cb0f12d 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -105,12 +105,12 @@ DEPEND_SRC = \ $(SOURCE_PATH)/src/corelib/serialization/qtextstream.cpp \ $(SOURCE_PATH)/src/corelib/serialization/qxmlstream.cpp \ $(SOURCE_PATH)/src/corelib/serialization/qxmlutils.cpp \ + $(SOURCE_PATH)/src/corelib/time/qdatetime.cpp \ $(SOURCE_PATH)/src/corelib/tools/qarraydata.cpp \ $(SOURCE_PATH)/src/corelib/tools/qbitarray.cpp \ $(SOURCE_PATH)/src/corelib/tools/qbytearray.cpp\ $(SOURCE_PATH)/src/corelib/tools/qbytearraymatcher.cpp \ $(SOURCE_PATH)/src/corelib/tools/qcryptographichash.cpp \ - $(SOURCE_PATH)/src/corelib/tools/qdatetime.cpp \ $(SOURCE_PATH)/src/corelib/tools/qhash.cpp \ $(SOURCE_PATH)/src/corelib/tools/qlist.cpp \ $(SOURCE_PATH)/src/corelib/tools/qlocale.cpp \ @@ -425,7 +425,7 @@ quuid.o: $(SOURCE_PATH)/src/corelib/plugin/quuid.cpp qfileinfo.o: $(SOURCE_PATH)/src/corelib/io/qfileinfo.cpp $(CXX) -c -o $@ $(CXXFLAGS) $< -qdatetime.o: $(SOURCE_PATH)/src/corelib/tools/qdatetime.cpp +qdatetime.o: $(SOURCE_PATH)/src/corelib/time/qdatetime.cpp $(CXX) -c -o $@ $(CXXFLAGS) $< qstringlist.o: $(SOURCE_PATH)/src/corelib/tools/qstringlist.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 5fa49d2f7f..d300e49215 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -196,6 +196,9 @@ qmake_pch.obj: {$(SOURCE_PATH)\src\corelib\serialization}.cpp{}.obj:: $(CXX) $(CXXFLAGS) $< +{$(SOURCE_PATH)\src\corelib\time}.cpp{}.obj:: + $(CXX) $(CXXFLAGS) $< + {$(SOURCE_PATH)\src\corelib\tools}.cpp{}.obj:: $(CXX) $(CXXFLAGS) $< diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 6babbac8f5..521f840292 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -36,6 +36,7 @@ qtConfig(animation): include(animation/animation.pri) include(global/global.pri) include(thread/thread.pri) include(tools/tools.pri) +include(time/time.pri) include(io/io.pri) include(itemmodels/itemmodels.pri) include(plugin/plugin.pri) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/time/qdatetime.cpp similarity index 100% rename from src/corelib/tools/qdatetime.cpp rename to src/corelib/time/qdatetime.cpp diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/time/qdatetime.h similarity index 100% rename from src/corelib/tools/qdatetime.h rename to src/corelib/time/qdatetime.h diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/time/qdatetime_p.h similarity index 100% rename from src/corelib/tools/qdatetime_p.h rename to src/corelib/time/qdatetime_p.h diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp similarity index 100% rename from src/corelib/tools/qdatetimeparser.cpp rename to src/corelib/time/qdatetimeparser.cpp diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h similarity index 100% rename from src/corelib/tools/qdatetimeparser_p.h rename to src/corelib/time/qdatetimeparser_p.h diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/time/qtimezone.cpp similarity index 100% rename from src/corelib/tools/qtimezone.cpp rename to src/corelib/time/qtimezone.cpp diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/time/qtimezone.h similarity index 100% rename from src/corelib/tools/qtimezone.h rename to src/corelib/time/qtimezone.h diff --git a/src/corelib/tools/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp similarity index 100% rename from src/corelib/tools/qtimezoneprivate.cpp rename to src/corelib/time/qtimezoneprivate.cpp diff --git a/src/corelib/tools/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp similarity index 100% rename from src/corelib/tools/qtimezoneprivate_android.cpp rename to src/corelib/time/qtimezoneprivate_android.cpp diff --git a/src/corelib/tools/qtimezoneprivate_data_p.h b/src/corelib/time/qtimezoneprivate_data_p.h similarity index 100% rename from src/corelib/tools/qtimezoneprivate_data_p.h rename to src/corelib/time/qtimezoneprivate_data_p.h diff --git a/src/corelib/tools/qtimezoneprivate_icu.cpp b/src/corelib/time/qtimezoneprivate_icu.cpp similarity index 100% rename from src/corelib/tools/qtimezoneprivate_icu.cpp rename to src/corelib/time/qtimezoneprivate_icu.cpp diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/time/qtimezoneprivate_mac.mm similarity index 100% rename from src/corelib/tools/qtimezoneprivate_mac.mm rename to src/corelib/time/qtimezoneprivate_mac.mm diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/time/qtimezoneprivate_p.h similarity index 99% rename from src/corelib/tools/qtimezoneprivate_p.h rename to src/corelib/time/qtimezoneprivate_p.h index b5e9286f6a..5f6491ef81 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/time/qtimezoneprivate_p.h @@ -53,7 +53,7 @@ // #include "qtimezone.h" -#include "qlocale_p.h" +#include "private/qlocale_p.h" #include "qvector.h" #if QT_CONFIG(icu) diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp similarity index 99% rename from src/corelib/tools/qtimezoneprivate_tz.cpp rename to src/corelib/time/qtimezoneprivate_tz.cpp index f5440799ab..2c845b1bce 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -40,6 +40,7 @@ #include "qtimezone.h" #include "qtimezoneprivate_p.h" #include "qdatetime_p.h" // ### Qt 5.14: remove once YearRange is on QDateTime +#include "private/qlocale_tools_p.h" #include #include @@ -48,8 +49,6 @@ #include -#include "qlocale_tools_p.h" - #include QT_BEGIN_NAMESPACE diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp similarity index 100% rename from src/corelib/tools/qtimezoneprivate_win.cpp rename to src/corelib/time/qtimezoneprivate_win.cpp diff --git a/src/corelib/time/time.pri b/src/corelib/time/time.pri new file mode 100644 index 0000000000..bacb7e875d --- /dev/null +++ b/src/corelib/time/time.pri @@ -0,0 +1,34 @@ +# Qt time / date / zone / calendar module + +HEADERS += \ + time/qdatetime.h \ + time/qdatetime_p.h + +SOURCES += time/qdatetime.cpp + +qtConfig(timezone) { + HEADERS += \ + time/qtimezone.h \ + time/qtimezoneprivate_p.h \ + time/qtimezoneprivate_data_p.h + SOURCES += \ + time/qtimezone.cpp \ + time/qtimezoneprivate.cpp + !nacl:darwin: { + SOURCES += time/qtimezoneprivate_mac.mm + } else: android:!android-embedded: { + SOURCES += time/qtimezoneprivate_android.cpp + } else: unix: { + SOURCES += time/qtimezoneprivate_tz.cpp + qtConfig(icu): SOURCES += time/qtimezoneprivate_icu.cpp + } else: qtConfig(icu): { + SOURCES += time/qtimezoneprivate_icu.cpp + } else: win32: { + SOURCES += time/qtimezoneprivate_win.cpp + } +} + +qtConfig(datetimeparser) { + HEADERS += time/qdatetimeparser_p.h + SOURCES += time/qdatetimeparser.cpp +} diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index f6eaa53c3a..c8740e55f3 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -55,7 +55,7 @@ #include "qlocale_p.h" #include "qlocale_tools_p.h" #if QT_CONFIG(datetimeparser) -#include "qdatetimeparser_p.h" +#include "private/qdatetimeparser_p.h" #endif #include "qnamespace.h" #include "qdatetime.h" diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 5dcb6c9ee0..52eddd5d6b 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -20,8 +20,6 @@ HEADERS += \ tools/qcontainerfwd.h \ tools/qcontainertools_impl.h \ tools/qcryptographichash.h \ - tools/qdatetime.h \ - tools/qdatetime_p.h \ tools/qdoublescanprint_p.h \ tools/qeasingcurve.h \ tools/qfreelist_p.h \ @@ -86,7 +84,6 @@ SOURCES += \ tools/qbytearraymatcher.cpp \ tools/qcollator.cpp \ tools/qcryptographichash.cpp \ - tools/qdatetime.cpp \ tools/qeasingcurve.cpp \ tools/qfreelist.cpp \ tools/qhash.cpp \ @@ -154,33 +151,6 @@ qtConfig(icu) { SOURCES += tools/qcollator_posix.cpp } -qtConfig(timezone) { - HEADERS += \ - tools/qtimezone.h \ - tools/qtimezoneprivate_p.h \ - tools/qtimezoneprivate_data_p.h - SOURCES += \ - tools/qtimezone.cpp \ - tools/qtimezoneprivate.cpp - !nacl:darwin: { - SOURCES += tools/qtimezoneprivate_mac.mm - } else: android:!android-embedded: { - SOURCES += tools/qtimezoneprivate_android.cpp - } else: unix: { - SOURCES += tools/qtimezoneprivate_tz.cpp - qtConfig(icu): SOURCES += tools/qtimezoneprivate_icu.cpp - } else: qtConfig(icu): { - SOURCES += tools/qtimezoneprivate_icu.cpp - } else: win32: { - SOURCES += tools/qtimezoneprivate_win.cpp - } -} - -qtConfig(datetimeparser) { - HEADERS += tools/qdatetimeparser_p.h - SOURCES += tools/qdatetimeparser.cpp -} - qtConfig(regularexpression) { QMAKE_USE_PRIVATE += pcre2 diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 3aeca6e7af..40c0702f0a 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -72,6 +72,7 @@ SOURCES += \ ../../corelib/serialization/qtextstream.cpp \ ../../corelib/serialization/qxmlutils.cpp \ ../../corelib/serialization/qxmlstream.cpp \ + ../../corelib/time/qdatetime.cpp \ ../../corelib/tools/qbitarray.cpp \ ../../corelib/tools/qbytearray.cpp \ ../../corelib/tools/qarraydata.cpp \ @@ -79,7 +80,6 @@ SOURCES += \ ../../corelib/tools/qcommandlineparser.cpp \ ../../corelib/tools/qcommandlineoption.cpp \ ../../corelib/tools/qcryptographichash.cpp \ - ../../corelib/tools/qdatetime.cpp \ ../../corelib/tools/qhash.cpp \ ../../corelib/tools/qlist.cpp \ ../../corelib/tools/qlinkedlist.cpp \ diff --git a/tests/auto/corelib/corelib.pro b/tests/auto/corelib/corelib.pro index 44e1c519b0..1d76e1549b 100644 --- a/tests/auto/corelib/corelib.pro +++ b/tests/auto/corelib/corelib.pro @@ -14,4 +14,5 @@ SUBDIRS = \ serialization \ statemachine \ thread \ + time \ tools diff --git a/tests/auto/corelib/tools/qdate/.gitignore b/tests/auto/corelib/time/qdate/.gitignore similarity index 100% rename from tests/auto/corelib/tools/qdate/.gitignore rename to tests/auto/corelib/time/qdate/.gitignore diff --git a/tests/auto/corelib/tools/qdate/qdate.pro b/tests/auto/corelib/time/qdate/qdate.pro similarity index 100% rename from tests/auto/corelib/tools/qdate/qdate.pro rename to tests/auto/corelib/time/qdate/qdate.pro diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp similarity index 100% rename from tests/auto/corelib/tools/qdate/tst_qdate.cpp rename to tests/auto/corelib/time/qdate/tst_qdate.cpp diff --git a/tests/auto/corelib/tools/qdatetime/.gitignore b/tests/auto/corelib/time/qdatetime/.gitignore similarity index 100% rename from tests/auto/corelib/tools/qdatetime/.gitignore rename to tests/auto/corelib/time/qdatetime/.gitignore diff --git a/tests/auto/corelib/tools/qdatetime/BLACKLIST b/tests/auto/corelib/time/qdatetime/BLACKLIST similarity index 100% rename from tests/auto/corelib/tools/qdatetime/BLACKLIST rename to tests/auto/corelib/time/qdatetime/BLACKLIST diff --git a/tests/auto/corelib/tools/qdatetime/qdatetime.pro b/tests/auto/corelib/time/qdatetime/qdatetime.pro similarity index 100% rename from tests/auto/corelib/tools/qdatetime/qdatetime.pro rename to tests/auto/corelib/time/qdatetime/qdatetime.pro diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp similarity index 100% rename from tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp rename to tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm b/tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm similarity index 100% rename from tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm rename to tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm diff --git a/tests/auto/corelib/tools/qtime/.gitignore b/tests/auto/corelib/time/qtime/.gitignore similarity index 100% rename from tests/auto/corelib/tools/qtime/.gitignore rename to tests/auto/corelib/time/qtime/.gitignore diff --git a/tests/auto/corelib/tools/qtime/qtime.pro b/tests/auto/corelib/time/qtime/qtime.pro similarity index 100% rename from tests/auto/corelib/tools/qtime/qtime.pro rename to tests/auto/corelib/time/qtime/qtime.pro diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/time/qtime/tst_qtime.cpp similarity index 100% rename from tests/auto/corelib/tools/qtime/tst_qtime.cpp rename to tests/auto/corelib/time/qtime/tst_qtime.cpp diff --git a/tests/auto/corelib/tools/qtimezone/BLACKLIST b/tests/auto/corelib/time/qtimezone/BLACKLIST similarity index 100% rename from tests/auto/corelib/tools/qtimezone/BLACKLIST rename to tests/auto/corelib/time/qtimezone/BLACKLIST diff --git a/tests/auto/corelib/tools/qtimezone/qtimezone.pro b/tests/auto/corelib/time/qtimezone/qtimezone.pro similarity index 100% rename from tests/auto/corelib/tools/qtimezone/qtimezone.pro rename to tests/auto/corelib/time/qtimezone/qtimezone.pro diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp similarity index 100% rename from tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp rename to tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm b/tests/auto/corelib/time/qtimezone/tst_qtimezone_darwin.mm similarity index 100% rename from tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm rename to tests/auto/corelib/time/qtimezone/tst_qtimezone_darwin.mm diff --git a/tests/auto/corelib/time/time.pro b/tests/auto/corelib/time/time.pro new file mode 100644 index 0000000000..6f9ff038db --- /dev/null +++ b/tests/auto/corelib/time/time.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qdate \ + qdatetime \ + qtime \ + qtimezone diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index c6da33cce0..243e7e96f5 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -16,8 +16,6 @@ SUBDIRS=\ qcommandlineparser \ qcontiguouscache \ qcryptographichash \ - qdate \ - qdatetime \ qeasingcurve \ qexplicitlyshareddatapointer \ qfreelist \ @@ -62,8 +60,6 @@ SUBDIRS=\ qstringref \ qstringview \ qtextboundaryfinder \ - qtime \ - qtimezone \ qtimeline \ qvarlengtharray \ qvector \ diff --git a/tests/benchmarks/corelib/corelib.pro b/tests/benchmarks/corelib/corelib.pro index b5781ad49e..99af4c138f 100644 --- a/tests/benchmarks/corelib/corelib.pro +++ b/tests/benchmarks/corelib/corelib.pro @@ -5,6 +5,7 @@ SUBDIRS = \ mimetypes \ kernel \ thread \ + time \ tools \ codecs \ plugin diff --git a/tests/benchmarks/corelib/tools/qdate/qdate.pro b/tests/benchmarks/corelib/time/qdate/qdate.pro similarity index 100% rename from tests/benchmarks/corelib/tools/qdate/qdate.pro rename to tests/benchmarks/corelib/time/qdate/qdate.pro diff --git a/tests/benchmarks/corelib/tools/qdate/tst_bench_qdate.cpp b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp similarity index 100% rename from tests/benchmarks/corelib/tools/qdate/tst_bench_qdate.cpp rename to tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/time/qdatetime/main.cpp similarity index 100% rename from tests/benchmarks/corelib/tools/qdatetime/main.cpp rename to tests/benchmarks/corelib/time/qdatetime/main.cpp diff --git a/tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro similarity index 100% rename from tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro rename to tests/benchmarks/corelib/time/qdatetime/qdatetime.pro diff --git a/tests/benchmarks/corelib/tools/qtimezone/main.cpp b/tests/benchmarks/corelib/time/qtimezone/main.cpp similarity index 100% rename from tests/benchmarks/corelib/tools/qtimezone/main.cpp rename to tests/benchmarks/corelib/time/qtimezone/main.cpp diff --git a/tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro similarity index 100% rename from tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro rename to tests/benchmarks/corelib/time/qtimezone/qtimezone.pro diff --git a/tests/benchmarks/corelib/time/time.pro b/tests/benchmarks/corelib/time/time.pro new file mode 100644 index 0000000000..b5184845d9 --- /dev/null +++ b/tests/benchmarks/corelib/time/time.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qdate \ + qdatetime \ + qtimezone diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro index ca9c0a6f89..33cbe00438 100644 --- a/tests/benchmarks/corelib/tools/tools.pro +++ b/tests/benchmarks/corelib/tools/tools.pro @@ -5,7 +5,6 @@ SUBDIRS = \ qbytearray \ qcontiguouscache \ qcryptographichash \ - qdatetime \ qlist \ qlocale \ qmap \ @@ -15,7 +14,6 @@ SUBDIRS = \ qstring \ qstringbuilder \ qstringlist \ - qtimezone \ qvector \ qalgorithms diff --git a/util/locale_database/cldr2qtimezone.py b/util/locale_database/cldr2qtimezone.py index 256839317c..0817435d40 100755 --- a/util/locale_database/cldr2qtimezone.py +++ b/util/locale_database/cldr2qtimezone.py @@ -32,7 +32,7 @@ Script to parse the CLDR supplemental/windowsZones.xml file and encode for use in QTimeZone. See ``./cldr2qlocalexml.py`` for where to get the CLDR data. Pass its common/ directory as first parameter to this script and the qtbase root directory as second parameter. It shall -update qtbase's src/corelib/tools/qtimezoneprivate_data_p.h ready for +update qtbase's src/corelib/time/qtimezoneprivate_data_p.h ready for use. The XML structure is as follows: @@ -268,7 +268,7 @@ if not os.path.isdir(cldrPath) or not os.path.isdir(qtPath): windowsZonesPath = cldrPath + "/supplemental/windowsZones.xml" tempFileDir = qtPath -dataFilePath = qtPath + "/src/corelib/tools/qtimezoneprivate_data_p.h" +dataFilePath = qtPath + "/src/corelib/time/qtimezoneprivate_data_p.h" if not os.path.isfile(windowsZonesPath): usage() From e85aa551ebe5f882c9771dc3ea2b90b02b286a49 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 8 Apr 2019 17:05:28 +0200 Subject: [PATCH 05/17] vulkan: Add debug message filtering [ChangeLog][QtGui] Added support for filtering Vulkan debug messages in QVulkanInstance. This is especially useful for processing or suppressing messages from the validation layers. Change-Id: Idf0d7889085948daf5b1a53d2a9b11081e967609 Reviewed-by: Paul Olav Tvete --- src/gui/vulkan/qplatformvulkaninstance.cpp | 5 ++ src/gui/vulkan/qplatformvulkaninstance.h | 1 + src/gui/vulkan/qvulkaninstance.cpp | 46 +++++++++++++++++++ src/gui/vulkan/qvulkaninstance.h | 5 ++ .../qbasicvulkanplatforminstance.cpp | 16 +++++-- .../qbasicvulkanplatforminstance_p.h | 4 ++ 6 files changed, 72 insertions(+), 5 deletions(-) diff --git a/src/gui/vulkan/qplatformvulkaninstance.cpp b/src/gui/vulkan/qplatformvulkaninstance.cpp index 6201d3ec11..9d044bfd58 100644 --- a/src/gui/vulkan/qplatformvulkaninstance.cpp +++ b/src/gui/vulkan/qplatformvulkaninstance.cpp @@ -85,4 +85,9 @@ void QPlatformVulkanInstance::presentQueued(QWindow *window) Q_UNUSED(window); } +void QPlatformVulkanInstance::setDebugFilters(const QVector &filters) +{ + Q_UNUSED(filters); +} + QT_END_NAMESPACE diff --git a/src/gui/vulkan/qplatformvulkaninstance.h b/src/gui/vulkan/qplatformvulkaninstance.h index 9f34803f7b..d47c59b5db 100644 --- a/src/gui/vulkan/qplatformvulkaninstance.h +++ b/src/gui/vulkan/qplatformvulkaninstance.h @@ -78,6 +78,7 @@ public: virtual PFN_vkVoidFunction getInstanceProcAddr(const char *name) = 0; virtual bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) = 0; virtual void presentQueued(QWindow *window); + virtual void setDebugFilters(const QVector &filters); private: QScopedPointer d_ptr; diff --git a/src/gui/vulkan/qvulkaninstance.cpp b/src/gui/vulkan/qvulkaninstance.cpp index 2941bfd01f..0605d88cca 100644 --- a/src/gui/vulkan/qvulkaninstance.cpp +++ b/src/gui/vulkan/qvulkaninstance.cpp @@ -269,6 +269,7 @@ public: VkResult errorCode; QScopedPointer funcs; QHash deviceFuncs; + QVector debugFilters; }; bool QVulkanInstancePrivate::ensureVulkan() @@ -570,6 +571,7 @@ bool QVulkanInstance::create() d_ptr->extensions = d_ptr->platformInst->enabledExtensions(); d_ptr->errorCode = VK_SUCCESS; d_ptr->funcs.reset(new QVulkanFunctions(this)); + d_ptr->platformInst->setDebugFilters(d_ptr->debugFilters); return true; } @@ -785,6 +787,50 @@ void QVulkanInstance::presentQueued(QWindow *window) d_ptr->platformInst->presentQueued(window); } +/*! + \typedef QVulkanInstance::DebugFilter + + Typedef for debug filtering callback functions. + + \sa installDebugOutputFilter(), removeDebugOutputFilter() + */ + +/*! + Installs a \a filter function that is called for every Vulkan debug + message. When the callback returns \c true, the message is stopped (filtered + out) and will not appear on the debug output. + + \note Filtering is only effective when NoDebugOutputRedirect is not + \l{setFlags()}{set}. Installing filters has no effect otherwise. + + \note This function can be called before create(). + + \sa removeDebugOutputFilter() + */ +void QVulkanInstance::installDebugOutputFilter(DebugFilter filter) +{ + if (!d_ptr->debugFilters.contains(filter)) { + d_ptr->debugFilters.append(filter); + if (d_ptr->platformInst) + d_ptr->platformInst->setDebugFilters(d_ptr->debugFilters); + } +} + +/*! + Removes a \a filter function previously installed by + installDebugOutputFilter(). + + \note This function can be called before create(). + + \sa installDebugOutputFilter() + */ +void QVulkanInstance::removeDebugOutputFilter(DebugFilter filter) +{ + d_ptr->debugFilters.removeOne(filter); + if (d_ptr->platformInst) + d_ptr->platformInst->setDebugFilters(d_ptr->debugFilters); +} + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QVulkanLayer &layer) { diff --git a/src/gui/vulkan/qvulkaninstance.h b/src/gui/vulkan/qvulkaninstance.h index f28975f911..70f2fd5102 100644 --- a/src/gui/vulkan/qvulkaninstance.h +++ b/src/gui/vulkan/qvulkaninstance.h @@ -188,6 +188,11 @@ public: void presentQueued(QWindow *window); + typedef bool (*DebugFilter)(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, + size_t location, int32_t messageCode, const char *pLayerPrefix, const char *pMessage); + void installDebugOutputFilter(DebugFilter filter); + void removeDebugOutputFilter(DebugFilter filter); + private: QScopedPointer d_ptr; Q_DISABLE_COPY(QVulkanInstance) diff --git a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp index b9c5669b3f..68340a3173 100644 --- a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp +++ b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp @@ -330,6 +330,11 @@ bool QBasicPlatformVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevi return supported; } +void QBasicPlatformVulkanInstance::setDebugFilters(const QVector &filters) +{ + m_debugFilters = filters; +} + void QBasicPlatformVulkanInstance::destroySurface(VkSurfaceKHR surface) const { if (m_destroySurface && surface) @@ -345,11 +350,11 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL defaultDebugCallbackFunc(VkDebugReportFlag const char *pMessage, void *pUserData) { - Q_UNUSED(flags); - Q_UNUSED(objectType); - Q_UNUSED(object); - Q_UNUSED(location); - Q_UNUSED(pUserData); + QBasicPlatformVulkanInstance *self = static_cast(pUserData); + for (QVulkanInstance::DebugFilter filter : *self->debugFilters()) { + if (filter(flags, objectType, object, location, messageCode, pLayerPrefix, pMessage)) + return VK_FALSE; + } // not categorized, just route to plain old qDebug qDebug("vkDebug: %s: %d: %s", pLayerPrefix, messageCode, pMessage); @@ -374,6 +379,7 @@ void QBasicPlatformVulkanInstance::setupDebugOutput() | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; dbgCallbackInfo.pfnCallback = defaultDebugCallbackFunc; + dbgCallbackInfo.pUserData = this; VkResult err = createDebugReportCallback(m_vkInst, &dbgCallbackInfo, nullptr, &m_debugCallback); if (err != VK_SUCCESS) diff --git a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h index 566140b032..e59d9219fb 100644 --- a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h +++ b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance_p.h @@ -73,7 +73,10 @@ public: QByteArrayList enabledExtensions() const override; PFN_vkVoidFunction getInstanceProcAddr(const char *name) override; bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override; + void setDebugFilters(const QVector &filters) override; + void destroySurface(VkSurfaceKHR surface) const; + const QVector *debugFilters() const { return &m_debugFilters; } protected: void loadVulkanLibrary(const QString &defaultLibraryName); @@ -105,6 +108,7 @@ private: VkDebugReportCallbackEXT m_debugCallback; PFN_vkDestroyDebugReportCallbackEXT m_vkDestroyDebugReportCallbackEXT; + QVector m_debugFilters; }; QT_END_NAMESPACE From 27e723496351bf4077b3f5e548fddb252e032579 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 24 May 2019 16:34:40 +0200 Subject: [PATCH 06/17] Windows QPA: Fix clang warnings about using typedef Replace by using (except for function pointers). Change-Id: I0dfe03c22f9f87155003d13a6376381623df7217 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscursor.h | 2 +- .../platforms/windows/qwindowsdialoghelpers.cpp | 10 +++++----- src/plugins/platforms/windows/qwindowsdialoghelpers.h | 2 +- src/plugins/platforms/windows/qwindowsmenu.h | 4 ++-- src/plugins/platforms/windows/qwindowsmousehandler.cpp | 4 ++-- src/plugins/platforms/windows/qwindowsscreen.cpp | 2 +- src/plugins/platforms/windows/qwindowsscreen.h | 4 ++-- .../platforms/windows/qwindowssystemtrayicon.cpp | 2 +- src/plugins/platforms/windows/qwindowswindow.cpp | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index d5c189b5ca..b896f4c7a9 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -84,7 +84,7 @@ private: const HCURSOR m_hcursor; }; -typedef QSharedPointer CursorHandlePtr; +using CursorHandlePtr = QSharedPointer; class QWindowsCursor : public QPlatformCursor { diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index e55b8fd7b8..57f19b5ff2 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -271,7 +271,7 @@ QWindowsNativeDialogBase *QWindowsDialogHelperBase::ensureNativeDialo class QWindowsDialogThread : public QThread { public: - typedef QSharedPointer QWindowsNativeDialogBasePtr; + using QWindowsNativeDialogBasePtr = QSharedPointer; explicit QWindowsDialogThread(const QWindowsNativeDialogBasePtr &d, HWND owner) : m_dialog(d), m_owner(owner) {} @@ -551,7 +551,7 @@ IFileDialogEvents *QWindowsNativeFileDialogEventHandler::create(QWindowsNativeFi class QWindowsShellItem { public: - typedef std::vector IShellItems; + using IShellItems = std::vector; explicit QWindowsShellItem(IShellItem *item); @@ -1688,7 +1688,7 @@ class QWindowsXpNativeFileDialog : public QWindowsNativeDialogBase { Q_OBJECT public: - typedef QSharedPointer OptionsPtr; + using OptionsPtr = QSharedPointer; static QWindowsXpNativeFileDialog *create(const OptionsPtr &options, const QWindowsFileDialogSharedData &data); @@ -1779,7 +1779,7 @@ static int QT_WIN_CALLBACK xpFileDialogGetExistingDirCallbackProc(HWND hwnd, UIN #if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3) typedef ITEMIDLIST *qt_LpItemIdList; #else -typedef PIDLIST_ABSOLUTE qt_LpItemIdList; +using qt_LpItemIdList = PIDLIST_ABSOLUTE; #endif int QWindowsXpNativeFileDialog::existingDirCallback(HWND hwnd, UINT uMsg, LPARAM lParam) @@ -2007,7 +2007,7 @@ QString QWindowsXpFileDialogHelper::selectedNameFilter() const \ingroup qt-lighthouse-win */ -typedef QSharedPointer SharedPointerColor; +using SharedPointerColor = QSharedPointer; #ifdef USE_NATIVE_COLOR_DIALOG class QWindowsNativeColorDialog : public QWindowsNativeDialogBase diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.h b/src/plugins/platforms/windows/qwindowsdialoghelpers.h index f0a7ef5e90..8686749011 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.h +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.h @@ -66,7 +66,7 @@ class QWindowsDialogHelperBase : public BaseClass { Q_DISABLE_COPY_MOVE(QWindowsDialogHelperBase) public: - typedef QSharedPointer QWindowsNativeDialogBasePtr; + using QWindowsNativeDialogBasePtr = QSharedPointer; ~QWindowsDialogHelperBase() { cleanupThread(); } void exec() override; diff --git a/src/plugins/platforms/windows/qwindowsmenu.h b/src/plugins/platforms/windows/qwindowsmenu.h index 6de1553f35..aa36846ec0 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.h +++ b/src/plugins/platforms/windows/qwindowsmenu.h @@ -120,7 +120,7 @@ class QWindowsMenu : public QPlatformMenu { Q_OBJECT public: - typedef QVector MenuItems; + using MenuItems = QVector; QWindowsMenu(); ~QWindowsMenu(); @@ -196,7 +196,7 @@ class QWindowsMenuBar : public QPlatformMenuBar { Q_OBJECT public: - typedef QVector Menus; + using Menus = QVector; QWindowsMenuBar(); ~QWindowsMenuBar() override; diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 97e1319e8d..c15819a65f 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -609,8 +609,8 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QtWindows::WindowsEventType, MSG msg, LRESULT *) { - typedef QWindowSystemInterface::TouchPoint QTouchPoint; - typedef QList QTouchPointList; + using QTouchPoint = QWindowSystemInterface::TouchPoint; + using QTouchPointList = QList; if (!QWindowsContext::instance()->initTouch()) { qWarning("Unable to initialize touch handling."); diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 2f8850cbe0..e3931b3bb1 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -72,7 +72,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor) return {0, 0}; } -typedef QList WindowsScreenDataList; +using WindowsScreenDataList = QList; static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data) { diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index 3eb2d35b27..0ccebf6d71 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -76,7 +76,7 @@ class QWindowsScreen : public QPlatformScreen { public: #ifndef QT_NO_CURSOR - typedef QScopedPointer CursorPtr; + using CursorPtr = QScopedPointer; #endif explicit QWindowsScreen(const QWindowsScreenData &data); @@ -127,7 +127,7 @@ private: class QWindowsScreenManager { public: - typedef QList WindowsScreenList; + using WindowsScreenList = QList; QWindowsScreenManager(); diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index c0f4e4d014..f2dba4d06b 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -117,7 +117,7 @@ struct QWindowsHwndSystemTrayIconEntry QWindowsSystemTrayIcon *trayIcon; }; -typedef QVector HwndTrayIconEntries; +using HwndTrayIconEntries = QVector; Q_GLOBAL_STATIC(HwndTrayIconEntries, hwndTrayIconEntries) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 174c63bbbd..3669407765 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -86,7 +86,7 @@ QT_BEGIN_NAMESPACE -typedef QSharedPointer QWindowCreationContextPtr; +using QWindowCreationContextPtr = QSharedPointer; enum { defaultWindowWidth = 160, @@ -494,7 +494,7 @@ static QMargins invisibleMargins(QPoint screenPoint) struct WindowCreationData { - typedef QWindowsWindowData WindowData; + using WindowData = QWindowsWindowData; enum Flags { ForceChild = 0x1, ForceTopLevel = 0x2 }; void fromWindow(const QWindow *w, const Qt::WindowFlags flags, unsigned creationFlags = 0); From deaf044b2e5efd2d2c60e80f2593c7f9ab1feda9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 24 May 2019 10:51:36 +0200 Subject: [PATCH 07/17] Fix deprecation warnings in tst_QUrl Change-Id: I8b1877c57d0bd061908d83c0feacfb4a4d4c3868 Reviewed-by: David Faure --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 129 +++++++++++------------- 1 file changed, 58 insertions(+), 71 deletions(-) diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 9c106c7f58..daaa5516cd 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -136,8 +136,8 @@ private slots: void emptyQueryOrFragment(); void hasFragment_data(); void hasFragment(); - void setEncodedFragment_data(); - void setEncodedFragment(); + void setFragment_data(); + void setFragment(); void fromEncoded(); void stripTrailingSlash_data(); void stripTrailingSlash(); @@ -350,15 +350,15 @@ void tst_QUrl::comparison() // 6.2.2.1 Make sure hexdecimal characters in percent encoding are // treated case-insensitively QUrl url5; - url5.setEncodedQuery("a=%2a"); + url5.setQuery(QLatin1String("a=%2a")); QUrl url6; - url6.setEncodedQuery("a=%2A"); + url6.setQuery(QLatin1String("a=%2A")); QCOMPARE(url5, url6); QUrl url7; - url7.setEncodedQuery("a=C"); + url7.setQuery(QLatin1String("a=C")); QUrl url8; - url8.setEncodedQuery("a=c"); + url8.setQuery(QLatin1String("a=c")); QVERIFY(url7 != url8); QVERIFY(url7 < url8); @@ -502,7 +502,7 @@ void tst_QUrl::setUrl() QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString::fromLatin1("file")); QCOMPARE(url.path(), QString::fromLatin1("/")); - QVERIFY(url.encodedQuery().isEmpty()); + QVERIFY(url.query().isEmpty()); QVERIFY(url.userInfo().isEmpty()); QVERIFY(url.authority().isEmpty()); QVERIFY(url.fragment().isEmpty()); @@ -517,7 +517,7 @@ void tst_QUrl::setUrl() QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString::fromLatin1("http")); QCOMPARE(url.path(), QString()); - QVERIFY(url.encodedQuery().isEmpty()); + QVERIFY(url.query().isEmpty()); QVERIFY(url.userInfo().isEmpty()); QVERIFY(url.fragment().isEmpty()); QCOMPARE(url.host(), QString::fromLatin1("www.foo.bar")); @@ -536,7 +536,7 @@ void tst_QUrl::setUrl() QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString::fromLatin1("http")); QCOMPARE(url.path(), QString()); - QVERIFY(url.encodedQuery().isEmpty()); + QVERIFY(url.query().isEmpty()); QCOMPARE(url.userName(), QString::fromLatin1("user:")); QCOMPARE(url.password(), QString::fromLatin1("pass@")); QCOMPARE(url.userInfo(), QString::fromLatin1("user%3A:pass@")); @@ -781,7 +781,7 @@ void tst_QUrl::setUrl() QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString("http")); QCOMPARE(url.host(), QString("1.2.3.4")); - QCOMPARE(url.encodedQuery(), QByteArray("foo")); + QCOMPARE(url.query(QUrl::FullyEncoded), QLatin1String("foo")); } { QUrl url; @@ -798,13 +798,13 @@ void tst_QUrl::setUrl() QCOMPARE(url.scheme(), QString("data")); QCOMPARE(url.host(), QString()); QCOMPARE(url.path(), QString("text/javascript,d5 = 'five\\u0027s';")); - QCOMPARE(url.encodedPath().constData(), "text/javascript,d5%20%3D%20'five%5Cu0027s'%3B"); + QCOMPARE(url.path(QUrl::FullyEncoded), QLatin1String("text/javascript,d5%20%3D%20'five%5Cu0027s'%3B")); } { // invalid port number QUrl url; - url.setEncodedUrl("foo://tel:2147483648"); + url.setUrl(QLatin1String("foo://tel:2147483648"), QUrl::StrictMode); QVERIFY(!url.isValid()); } @@ -1144,7 +1144,7 @@ void tst_QUrl::toString_constructed_data() QTest::addColumn("host"); QTest::addColumn("port"); QTest::addColumn("path"); - QTest::addColumn("query"); + QTest::addColumn("query"); QTest::addColumn("fragment"); QTest::addColumn("asString"); QTest::addColumn("asEncoded"); @@ -1153,19 +1153,19 @@ void tst_QUrl::toString_constructed_data() QString n(""); QTest::newRow("data1") << n << n << n << QString::fromLatin1("qt-project.org") << -1 << QString::fromLatin1("/index.html") - << QByteArray() << n << QString::fromLatin1("//qt-project.org/index.html") + << QString() << n << QString::fromLatin1("//qt-project.org/index.html") << QByteArray("//qt-project.org/index.html") << 0u; - QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QByteArray() + QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QString() << n << QString::fromLatin1("file:///root") << QByteArray("file:///root") << 0u; QTest::newRow("userAndPass") << QString::fromLatin1("http") << QString::fromLatin1("dfaure") << QString::fromLatin1("kde") - << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n + << "kde.org" << 443 << QString::fromLatin1("/") << QString() << n << QString::fromLatin1("http://dfaure:kde@kde.org:443/") << QByteArray("http://dfaure:kde@kde.org:443/") << 0u; QTest::newRow("PassWithoutUser") << QString::fromLatin1("http") << n << QString::fromLatin1("kde") - << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n + << "kde.org" << 443 << QString::fromLatin1("/") << QString() << n << QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/") << 0u; QTest::newRow("PassWithoutUser-RemovePassword") << QString::fromLatin1("http") << n << QString::fromLatin1("kde") - << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n + << "kde.org" << 443 << QString::fromLatin1("/") << QString() << n << QString::fromLatin1("http://kde.org:443/") << QByteArray("http://kde.org:443/") << uint(QUrl::RemovePassword); } @@ -1178,7 +1178,7 @@ void tst_QUrl::toString_constructed() QFETCH(QString, host); QFETCH(int, port); QFETCH(QString, path); - QFETCH(QByteArray, query); + QFETCH(QString, query); QFETCH(QString, fragment); QFETCH(QString, asString); QFETCH(QByteArray, asEncoded); @@ -1198,7 +1198,7 @@ void tst_QUrl::toString_constructed() if (!path.isEmpty()) url.setPath(path); if (!query.isEmpty()) - url.setEncodedQuery(query); + url.setQuery(query, QUrl::StrictMode); if (!fragment.isEmpty()) url.setFragment(fragment); @@ -1757,7 +1757,7 @@ void tst_QUrl::symmetry() QCOMPARE(url.host(QUrl::EncodeUnicode | QUrl::EncodeSpaces), QString::fromUtf8("www.xn--rksmrgs-5wao1o.se")); QCOMPARE(url.path(), QString::fromLatin1("/pub")); // this will be encoded ... - QCOMPARE(url.encodedQuery().constData(), QString::fromLatin1("a=b&a=d%C3%B8&a=f").toLatin1().constData()); + QCOMPARE(url.query(QUrl::FullyEncoded), QLatin1String("a=b&a=d%C3%B8&a=f")); QCOMPARE(url.fragment(), QString::fromUtf8("vræl")); QUrl onlyHost("//qt-project.org"); @@ -2009,7 +2009,7 @@ void tst_QUrl::hasQuery() QUrl qurl(url); QCOMPARE(qurl.hasQuery(), trueFalse); - QCOMPARE(qurl.encodedQuery().isNull(), !trueFalse); + QCOMPARE(qurl.query().isNull(), !trueFalse); } void tst_QUrl::nameprep() @@ -2342,7 +2342,7 @@ void tst_QUrl::tolerantParser() QVERIFY(url.isValid()); QVERIFY(!url.toString().isEmpty()); QCOMPARE(url.path(), QString("/path with spaces.html")); - url.setEncodedUrl("http://www.example.com/path%20with spaces.html", QUrl::StrictMode); + url.setUrl(QLatin1String("http://www.example.com/path%20with spaces.html"), QUrl::StrictMode); QVERIFY(!url.isValid()); QVERIFY(url.toString().isEmpty()); } @@ -2392,36 +2392,36 @@ void tst_QUrl::tolerantParser() QCOMPARE(url.toEncoded(), QByteArray("%25hello.com/f%25")); QCOMPARE(url.toString(), QString("%25hello.com/f%25")); - url.setEncodedUrl("http://www.host.com/foo.php?P0=[2006-3-8]"); + url.setUrl(QLatin1String("http://www.host.com/foo.php?P0=[2006-3-8]"), QUrl::StrictMode); QVERIFY(url.isValid()); QVERIFY(!url.toString().isEmpty()); - url.setEncodedUrl("http://foo.bar/[image][1].jpg"); + url.setUrl(QLatin1String("http://foo.bar/[image][1].jpg"), QUrl::StrictMode); QVERIFY(url.isValid()); QCOMPARE(url.toString(QUrl::FullyEncoded), QString("http://foo.bar/[image][1].jpg")); QCOMPARE(url.toEncoded(), QByteArray("http://foo.bar/[image][1].jpg")); QCOMPARE(url.toString(), QString("http://foo.bar/[image][1].jpg")); - url.setEncodedUrl("http://foo.bar/%5Bimage%5D%5B1%5D.jpg"); + url.setUrl(QLatin1String("http://foo.bar/%5Bimage%5D%5B1%5D.jpg"), QUrl::StrictMode); QVERIFY(url.isValid()); QCOMPARE(url.toString(QUrl::FullyEncoded), QString("http://foo.bar/%5Bimage%5D%5B1%5D.jpg")); QCOMPARE(url.toEncoded(), QByteArray("http://foo.bar/%5Bimage%5D%5B1%5D.jpg")); QCOMPARE(url.toString(), QString("http://foo.bar/%5Bimage%5D%5B1%5D.jpg")); - url.setEncodedUrl("//[::56:56:56:56:56:56:56]"); + url.setUrl(QLatin1String("//[::56:56:56:56:56:56:56]"), QUrl::StrictMode); QCOMPARE(url.toString(QUrl::FullyEncoded), QString("//[0:56:56:56:56:56:56:56]")); QCOMPARE(url.toEncoded(), QByteArray("//[0:56:56:56:56:56:56:56]")); - url.setEncodedUrl("data:text/css,div%20{%20border-right:%20solid;%20}"); + url.setUrl(QLatin1String("data:text/css,div%20{%20border-right:%20solid;%20}"), QUrl::TolerantMode); QCOMPARE(url.toString(QUrl::FullyEncoded), QString("data:text/css,div%20%7B%20border-right:%20solid;%20%7D")); QCOMPARE(url.toEncoded(), QByteArray("data:text/css,div%20%7B%20border-right:%20solid;%20%7D")); QCOMPARE(url.toString(), QString("data:text/css,div %7B border-right: solid; %7D")); } { - QByteArray tsdgeos("http://google.com/c?c=Translation+%C2%BB+trunk|"); + const QString tsdgeos = QLatin1String("http://google.com/c?c=Translation+%C2%BB+trunk|"); QUrl tsdgeosQUrl; - tsdgeosQUrl.setEncodedUrl(tsdgeos, QUrl::TolerantMode); + tsdgeosQUrl.setUrl(tsdgeos, QUrl::TolerantMode); QVERIFY(tsdgeosQUrl.isValid()); // failed in Qt-4.4, works in Qt-4.5 QByteArray tsdgeosExpected("http://google.com/c?c=Translation+%C2%BB+trunk%7C"); QCOMPARE(QString(tsdgeosQUrl.toEncoded()), QString(tsdgeosExpected)); @@ -2626,31 +2626,31 @@ void tst_QUrl::emptyQueryOrFragment() // start with an empty one QUrl url("http://www.foo.bar/baz"); QVERIFY(!url.hasQuery()); - QVERIFY(url.encodedQuery().isNull()); + QVERIFY(url.query().isNull()); // add encodedQuery url.setQuery("abc=def"); QVERIFY(url.hasQuery()); QCOMPARE(url.query(), QString(QLatin1String("abc=def"))); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz?abc=def"))); - url.setEncodedQuery("abc=def"); + url.setQuery(QLatin1String("abc=def")); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz?abc=def"))); // remove encodedQuery url.setQuery(QString()); QVERIFY(!url.hasQuery()); - QVERIFY(url.encodedQuery().isNull()); + QVERIFY(url.query().isNull()); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz"))); - url.setEncodedQuery(QByteArray()); + url.setQuery(QString()); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz"))); // add empty encodedQuery url.setQuery(""); QVERIFY(url.hasQuery()); - QVERIFY(url.encodedQuery().isEmpty()); - QVERIFY(!url.encodedQuery().isNull()); + QVERIFY(url.query().isEmpty()); + QVERIFY(!url.query().isNull()); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz?"))); - url.setEncodedQuery(""); + url.setQuery(QLatin1String("")); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz?"))); } } @@ -2682,35 +2682,33 @@ void tst_QUrl::hasFragment() QCOMPARE(qurl.fragment().isNull(), !trueFalse); } -void tst_QUrl::setEncodedFragment_data() +void tst_QUrl::setFragment_data() { - QTest::addColumn("base"); - QTest::addColumn("fragment"); - QTest::addColumn("expected"); + QTest::addColumn("base"); + QTest::addColumn("fragment"); + QTest::addColumn("expected"); - typedef QByteArray BA; - QTest::newRow("null") << BA("http://www.kde.org") << BA() << BA("http://www.kde.org"); - QTest::newRow("empty") << BA("http://www.kde.org") << BA("") << BA("http://www.kde.org#"); - QTest::newRow("basic test") << BA("http://www.kde.org") << BA("abc") << BA("http://www.kde.org#abc"); - QTest::newRow("initial url has fragment") << BA("http://www.kde.org#old") << BA("new") << BA("http://www.kde.org#new"); - QTest::newRow("encoded fragment") << BA("http://www.kde.org") << BA("a%20c") << BA("http://www.kde.org#a%20c"); - QTest::newRow("with #") << BA("http://www.kde.org") << BA("a#b") << BA("http://www.kde.org#a%23b"); // toString uses "a#b" - QTest::newRow("unicode") << BA("http://www.kde.org") << BA("\xc3\xa9") << BA("http://www.kde.org#%C3%A9"); - QTest::newRow("binary") << BA("http://www.kde.org") << BA("\x00\xc0\x80", 3) << BA("http://www.kde.org#%00%C0%80"); + QTest::newRow("null") << QString::fromLatin1("http://www.kde.org") << QString() << QString::fromLatin1("http://www.kde.org"); + QTest::newRow("empty") << QString::fromLatin1("http://www.kde.org") << QString::fromLatin1("") << QString::fromLatin1("http://www.kde.org#"); + QTest::newRow("basic test") << QString::fromLatin1("http://www.kde.org") << QString::fromLatin1("abc") << QString::fromLatin1("http://www.kde.org#abc"); + QTest::newRow("initial url has fragment") << QString::fromLatin1("http://www.kde.org#old") << QString::fromLatin1("new") << QString::fromLatin1("http://www.kde.org#new"); + QTest::newRow("encoded fragment") << QString::fromLatin1("http://www.kde.org") << QString::fromLatin1("a%20c") << QString::fromLatin1("http://www.kde.org#a%20c"); + QTest::newRow("with #") << QString::fromLatin1("http://www.kde.org") << QString::fromLatin1("a#b") << QString::fromLatin1("http://www.kde.org#a%23b"); // toString uses "a#b" + QTest::newRow("unicode") << QString::fromLatin1("http://www.kde.org") << QString::fromUtf8("\xc3\xa9") << QString::fromLatin1("http://www.kde.org#%C3%A9"); } -void tst_QUrl::setEncodedFragment() +void tst_QUrl::setFragment() { - QFETCH(QByteArray, base); - QFETCH(QByteArray, fragment); - QFETCH(QByteArray, expected); + QFETCH(QString, base); + QFETCH(QString, fragment); + QFETCH(QString, expected); QUrl u; - u.setEncodedUrl(base, QUrl::TolerantMode); + u.setUrl(base, QUrl::TolerantMode); QVERIFY(u.isValid()); - u.setEncodedFragment(fragment); + u.setFragment(fragment); QVERIFY(u.isValid()); QCOMPARE(!fragment.isNull(), u.hasFragment()); - QCOMPARE(QString::fromLatin1(u.toEncoded()), QString::fromLatin1(expected)); + QCOMPARE(QString::fromUtf8(u.toEncoded()), expected); } void tst_QUrl::fromEncoded() @@ -3258,14 +3256,14 @@ void tst_QUrl::isEmptyForEncodedUrl() { { QUrl url; - url.setEncodedUrl("LABEL=USB_STICK", QUrl::TolerantMode); + url.setUrl(QLatin1String("LABEL=USB_STICK"), QUrl::TolerantMode); QVERIFY( url.isValid() ); QCOMPARE( url.path(), QString("LABEL=USB_STICK") ); QVERIFY( !url.isEmpty() ); } { QUrl url; - url.setEncodedUrl("LABEL=USB_STICK", QUrl::TolerantMode); + url.setUrl(QLatin1String("LABEL=USB_STICK"), QUrl::TolerantMode); QVERIFY( url.isValid() ); QVERIFY( !url.isEmpty() ); QCOMPARE( url.path(), QString("LABEL=USB_STICK") ); @@ -3277,7 +3275,7 @@ void tst_QUrl::isEmptyForEncodedUrl() void tst_QUrl::toEncodedNotUsingUninitializedPath() { QUrl url; - url.setEncodedPath("/test.txt"); + url.setPath(QLatin1String("/test.txt")); url.setHost("example.com"); QCOMPARE(url.toEncoded().constData(), "//example.com/test.txt"); @@ -3657,17 +3655,6 @@ void tst_QUrl::componentEncodings() QCOMPARE(url.toString(formatting), (((QString(toString ))))); // the weird () and space is to align the output - if (formatting == QUrl::FullyEncoded) { - QCOMPARE(url.encodedUserName(), userName.toUtf8()); - QCOMPARE(url.encodedPassword(), password.toUtf8()); - // no encodedUserInfo - QCOMPARE(url.encodedHost(), host.toUtf8()); - // no encodedAuthority - QCOMPARE(url.encodedPath(), path.toUtf8()); - QCOMPARE(url.encodedQuery(), query.toUtf8()); - QCOMPARE(url.encodedFragment(), fragment.toUtf8()); - } - // repeat with the URL we got from toString QUrl url2(toString); QCOMPARE(url2.userName(formatting), userName); From de752e8994220639b2934b769e83bab0e56a00c9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 3 Jun 2019 23:03:30 +0200 Subject: [PATCH 08/17] QLatin1Char: add comparison operators with char When QT_NO_CAST_FROM_ASCII is in effect, `char == QLatinChar` no longer compiles, because the QChar(char) ctor has become private. Fix by supplying the missing mixed-type operators. [ChangeLog][QtCore][QLatin1Char] Comparison against char now works even in QT_NO_CAST_FROM_ASCII builds. Change-Id: I86f5ec8e2ddfcda72f5928086cb298bd00b42544 Reviewed-by: Thiago Macieira --- src/corelib/tools/qchar.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index be344838ed..73344ecf52 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -58,6 +58,19 @@ private: char ch; }; +Q_DECL_CONSTEXPR inline bool operator==(char lhs, QLatin1Char rhs) noexcept { return lhs == rhs.toLatin1(); } +Q_DECL_CONSTEXPR inline bool operator!=(char lhs, QLatin1Char rhs) noexcept { return lhs != rhs.toLatin1(); } +Q_DECL_CONSTEXPR inline bool operator<=(char lhs, QLatin1Char rhs) noexcept { return lhs <= rhs.toLatin1(); } +Q_DECL_CONSTEXPR inline bool operator>=(char lhs, QLatin1Char rhs) noexcept { return lhs >= rhs.toLatin1(); } +Q_DECL_CONSTEXPR inline bool operator< (char lhs, QLatin1Char rhs) noexcept { return lhs < rhs.toLatin1(); } +Q_DECL_CONSTEXPR inline bool operator> (char lhs, QLatin1Char rhs) noexcept { return lhs > rhs.toLatin1(); } + +Q_DECL_CONSTEXPR inline bool operator==(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() == rhs; } +Q_DECL_CONSTEXPR inline bool operator!=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() != rhs; } +Q_DECL_CONSTEXPR inline bool operator<=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() <= rhs; } +Q_DECL_CONSTEXPR inline bool operator>=(QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() >= rhs; } +Q_DECL_CONSTEXPR inline bool operator< (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() < rhs; } +Q_DECL_CONSTEXPR inline bool operator> (QLatin1Char lhs, char rhs) noexcept { return lhs.toLatin1() > rhs; } class Q_CORE_EXPORT QChar { public: From a76ae0a631c8387bc96ec7d358e14f6c86b73f35 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Tue, 20 Mar 2018 14:20:23 +0100 Subject: [PATCH 09/17] rtems: Fix build sha3 (undef ALIGN) ALIGN macro exists in RTEMS system headers and in sha3 library. Change-Id: I00cbb5be5598a6a6ca1f011f199da62d658ef9d5 Reviewed-by: Ryan Chu --- src/corelib/tools/qcryptographichash.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 3c79bb797d..ee7657789c 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -58,6 +58,10 @@ typedef unsigned char BitSequence; typedef unsigned long long DataLength; typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn; +#ifdef Q_OS_RTEMS +# undef ALIGN +#endif + #include "../../3rdparty/sha3/KeccakSponge.c" typedef spongeState hashState; From 2c51a91e03de48e6a0fa215e265fe4a6a85c02f6 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Thu, 6 Jun 2019 10:18:20 +0200 Subject: [PATCH 10/17] rtems: Disable sys/sem.h include RTEMS does not have sys/sem.h Change-Id: I9fe5c5244a4205521493885b39fa0051abcc4539 Reviewed-by: Volker Hilsheimer Reviewed-by: Thiago Macieira --- src/corelib/kernel/qsharedmemory_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index 59802eb6ce..bf7c42dc62 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -69,7 +69,7 @@ namespace QSharedMemoryPrivate #include "qsystemsemaphore.h" #include "private/qobject_p.h" -#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY) +#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_RTEMS) # include #endif From 0624c99ea3d52f07c93378fcf75c3121df1b3928 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Jun 2019 22:03:58 +0200 Subject: [PATCH 11/17] QDistanceField: add missing copy assignment operator As found by GCC, while compiling qt5/qttools/src/distancefieldgenerator/mainwindow.cpp. Change-Id: I155c0b8b09bd12c12af0bd69e19747485be960e1 Reviewed-by: Thiago Macieira --- src/gui/text/qdistancefield.cpp | 3 +++ src/gui/text/qdistancefield_p.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 82bb617733..5967c8d3de 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -904,6 +904,9 @@ QDistanceField::QDistanceField(const QDistanceField &other) d = other.d; } +QDistanceField &QDistanceField::operator=(const QDistanceField &) + = default; + QDistanceField::QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution) { setGlyph(font, glyph, doubleResolution); diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h index 1a1b6866a2..dc5d5a9a02 100644 --- a/src/gui/text/qdistancefield_p.h +++ b/src/gui/text/qdistancefield_p.h @@ -95,6 +95,7 @@ public: QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false); QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution = false); QDistanceField(const QDistanceField &other); + QDistanceField &operator=(const QDistanceField &other); bool isNull() const; From 3619e87ba1c0b11b8406fee3e1fe5c1e96abb7ef Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 4 Jun 2019 19:49:12 +0200 Subject: [PATCH 12/17] Fix a minor grammar glitch in new string / byte-array doc note Amends 8845caa057cfcf54f7d46621adb3393c13747ffb. Change-Id: I4bf09b9c1fff52815de58070fbe4ff0c08eff53f Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.cpp | 2 +- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 5c2af7e058..9526350126 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1439,7 +1439,7 @@ QByteArray &QByteArray::operator=(const char *str) \note Before Qt 5.14 it was possible to use this operator to access a character at an out-of-bounds position in the byte array, and - then assign to such position, causing the byte array to be + then assign to such a position, causing the byte array to be automatically resized. Furthermore, assigning a value to the returned QByteRef would cause a detach of the byte array, even if the byte array has been copied in the meanwhile (and the QByteRef kept diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 06636098af..963c2a4d34 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -5800,7 +5800,7 @@ QString QString::trimmed_helper(QString &str) \note Before Qt 5.14 it was possible to use this operator to access a character at an out-of-bounds position in the string, and - then assign to such position, causing the string to be + then assign to such a position, causing the string to be automatically resized. Furthermore, assigning a value to the returned QCharRef would cause a detach of the string, even if the string has been copied in the meanwhile (and the QCharRef kept From cbc9d8947842b97f28e3acb2d87d80b4861d00b9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 5 Jun 2019 21:59:46 +0200 Subject: [PATCH 13/17] QInputDeviceManager: replace a QMap with a std::array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QInputDeviceManager::DeviceType is a (non-flag) enum with all of five values. Using a self-rebalancing rb-tree to map these to an int is overkill. An array can do the job just as well and better, given the enum values are consecutive, and even if some don't make sense (like Unknown), the waste caused by unused array slots is more than compensated by the lack of any memory allocations. Even more so as the array API is 1:1 identical with the map's for the use-case at hand. Saves 1.2KiB in text size on optimized Linux AMD64 GCC 9.1 builds. Change-Id: I1bfa115ac75e2f7d9a4bd9a0e3f3241bf68c9989 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qinputdevicemanager.cpp | 4 ++-- src/gui/kernel/qinputdevicemanager_p.h | 4 +++- src/gui/kernel/qinputdevicemanager_p_p.h | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qinputdevicemanager.cpp b/src/gui/kernel/qinputdevicemanager.cpp index 6e4e5a9c93..11442407e1 100644 --- a/src/gui/kernel/qinputdevicemanager.cpp +++ b/src/gui/kernel/qinputdevicemanager.cpp @@ -75,13 +75,13 @@ int QInputDeviceManager::deviceCount(DeviceType type) const int QInputDeviceManagerPrivate::deviceCount(QInputDeviceManager::DeviceType type) const { - return m_deviceCount.value(type); + return m_deviceCount[type]; } void QInputDeviceManagerPrivate::setDeviceCount(QInputDeviceManager::DeviceType type, int count) { Q_Q(QInputDeviceManager); - if (m_deviceCount.value(type) != count) { + if (m_deviceCount[type] != count) { m_deviceCount[type] = count; emit q->deviceListChanged(type); } diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h index 74494d712b..1d20b102e3 100644 --- a/src/gui/kernel/qinputdevicemanager_p.h +++ b/src/gui/kernel/qinputdevicemanager_p.h @@ -69,7 +69,9 @@ public: DeviceTypePointer, DeviceTypeKeyboard, DeviceTypeTouch, - DeviceTypeTablet + DeviceTypeTablet, + + NumDeviceTypes }; QInputDeviceManager(QObject *parent = nullptr); diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h index 0a91252fbc..871f9315c3 100644 --- a/src/gui/kernel/qinputdevicemanager_p_p.h +++ b/src/gui/kernel/qinputdevicemanager_p_p.h @@ -52,10 +52,11 @@ // #include -#include #include #include "qinputdevicemanager_p.h" +#include + QT_BEGIN_NAMESPACE class Q_GUI_EXPORT QInputDeviceManagerPrivate : public QObjectPrivate @@ -68,7 +69,7 @@ public: int deviceCount(QInputDeviceManager::DeviceType type) const; void setDeviceCount(QInputDeviceManager::DeviceType type, int count); - QMap m_deviceCount; + std::array m_deviceCount; Qt::KeyboardModifiers keyboardModifiers; }; From b16fab1b636c94cb1fd723f46a1714e010a4dc54 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 27 May 2019 22:03:33 +0200 Subject: [PATCH 14/17] Fix deprecation warnings Fix deprecation warnings - replace qFindChild/Children() with QObject::findChild/Children() and replace some 0 with nullptr. Change-Id: If2f01d12fa91d09d98a61f73b0449a6773ac93db Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- .../corelib/kernel/qobject/tst_qobject.cpp | 107 +++++++++--------- 1 file changed, 52 insertions(+), 55 deletions(-) diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index e0394a5d25..f1c4effa95 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -537,91 +536,91 @@ void tst_QObject::findChildren() QObject *op = 0; - op = qFindChild(&o, "o1"); + op = o.findChild("o1"); QCOMPARE(op, &o1); - op = qFindChild(&o, "o2"); + op = o.findChild("o2"); QCOMPARE(op, &o2); - op = qFindChild(&o, "o11"); + op = o.findChild("o11"); QCOMPARE(op, &o11); - op = qFindChild(&o, "o12"); + op = o.findChild("o12"); QCOMPARE(op, &o12); - op = qFindChild(&o, "o111"); + op = o.findChild("o111"); QCOMPARE(op, &o111); - op = qFindChild(&o, "t1"); + op = o.findChild("t1"); QCOMPARE(op, static_cast(&t1)); - op = qFindChild(&o, "t121"); + op = o.findChild("t121"); QCOMPARE(op, static_cast(&t121)); - op = qFindChild(&o, "t1"); + op = o.findChild("t1"); QCOMPARE(op, static_cast(&t1)); - op = qFindChild(&o, "t121"); + op = o.findChild("t121"); QCOMPARE(op, static_cast(&t121)); - op = qFindChild(&o, "o12"); + op = o.findChild("o12"); QCOMPARE(op, static_cast(0)); - op = qFindChild(&o, "o"); + op = o.findChild("o"); QCOMPARE(op, static_cast(0)); - op = qFindChild(&o, "harry"); + op = o.findChild("harry"); QCOMPARE(op, static_cast(0)); - op = qFindChild(&o, "o1"); + op = o.findChild("o1"); QCOMPARE(op, &o1); QList l; QList tl; - l = qFindChildren(&o, "o1"); + l = o.findChildren("o1"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o1); - l = qFindChildren(&o, "o2"); + l = o.findChildren("o2"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o2); - l = qFindChildren(&o, "o11"); + l = o.findChildren("o11"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o11); - l = qFindChildren(&o, "o12"); + l = o.findChildren("o12"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o12); - l = qFindChildren(&o, "o111"); + l = o.findChildren("o111"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o111); - l = qFindChildren(&o, "t1"); + l = o.findChildren("t1"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), static_cast(&t1)); - l = qFindChildren(&o, "t121"); + l = o.findChildren("t121"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), static_cast(&t121)); - tl = qFindChildren(&o, "t1"); + tl = o.findChildren("t1"); QCOMPARE(tl.size(), 1); QCOMPARE(tl.at(0), &t1); - tl = qFindChildren(&o, "t121"); + tl = o.findChildren("t121"); QCOMPARE(tl.size(), 1); QCOMPARE(tl.at(0), &t121); - l = qFindChildren(&o, "o"); + l = o.findChildren("o"); QCOMPARE(l.size(), 0); - l = qFindChildren(&o, "harry"); + l = o.findChildren("harry"); QCOMPARE(l.size(), 0); - tl = qFindChildren(&o, "o12"); + tl = o.findChildren("o12"); QCOMPARE(tl.size(), 0); - l = qFindChildren(&o, "o1"); + l = o.findChildren("o1"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o1); - l = qFindChildren(&o, QRegExp("o.*")); + l = o.findChildren(QRegularExpression("^o.*$")); QCOMPARE(l.size(), 5); QVERIFY(l.contains(&o1)); QVERIFY(l.contains(&o2)); QVERIFY(l.contains(&o11)); QVERIFY(l.contains(&o12)); QVERIFY(l.contains(&o111)); - l = qFindChildren(&o, QRegExp("t.*")); + l = o.findChildren(QRegularExpression("t.*")); QCOMPARE(l.size(), 2); QVERIFY(l.contains(&t1)); QVERIFY(l.contains(&t121)); - tl = qFindChildren(&o, QRegExp(".*")); + tl = o.findChildren(QRegularExpression("^.*$")); QCOMPARE(tl.size(), 3); QVERIFY(tl.contains(&t1)); QVERIFY(tl.contains(&t121)); - tl = qFindChildren(&o, QRegExp("o.*")); + tl = o.findChildren(QRegularExpression("^o.*$")); QCOMPARE(tl.size(), 0); - l = qFindChildren(&o, QRegExp("harry")); + l = o.findChildren(QRegularExpression("^harry$")); QCOMPARE(l.size(), 0); l = o.findChildren(QRegularExpression("o.*")); @@ -645,18 +644,18 @@ void tst_QObject::findChildren() QCOMPARE(l.size(), 0); // empty and null string check - op = qFindChild(&o); + op = o.findChild(); QCOMPARE(op, &o1); - op = qFindChild(&o, ""); + op = o.findChild(""); QCOMPARE(op, &unnamed); - op = qFindChild(&o, "unnamed"); + op = o.findChild("unnamed"); QCOMPARE(op, static_cast(0)); - l = qFindChildren(&o); + l = o.findChildren(); QCOMPARE(l.size(), 9); - l = qFindChildren(&o, ""); + l = o.findChildren(""); QCOMPARE(l.size(), 2); - l = qFindChildren(&o, "unnamed"); + l = o.findChildren("unnamed"); QCOMPARE(l.size(), 0); tl = o.findChildren("t1"); @@ -724,19 +723,19 @@ void tst_QObject::findChildren() QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o1); - l = o.findChildren(QRegExp("o.*"), Qt::FindDirectChildrenOnly); + l = o.findChildren(QRegularExpression("^o.*$"), Qt::FindDirectChildrenOnly); QCOMPARE(l.size(), 2); QVERIFY(l.contains(&o1)); QVERIFY(l.contains(&o2)); - l = o.findChildren(QRegExp("t.*"), Qt::FindDirectChildrenOnly); + l = o.findChildren(QRegularExpression("^t.*$"), Qt::FindDirectChildrenOnly); QCOMPARE(l.size(), 1); QVERIFY(l.contains(&t1)); - tl = o.findChildren(QRegExp(".*"), Qt::FindDirectChildrenOnly); + tl = o.findChildren(QRegularExpression("^.*$"), Qt::FindDirectChildrenOnly); QCOMPARE(tl.size(), 2); QVERIFY(tl.contains(&t1)); - tl = o.findChildren(QRegExp("o.*"), Qt::FindDirectChildrenOnly); + tl = o.findChildren(QRegularExpression("^o.*$"), Qt::FindDirectChildrenOnly); QCOMPARE(tl.size(), 0); - l = o.findChildren(QRegExp("harry"), Qt::FindDirectChildrenOnly); + l = o.findChildren(QRegularExpression("^harry$"), Qt::FindDirectChildrenOnly); QCOMPARE(l.size(), 0); // empty and null string check @@ -1035,18 +1034,16 @@ public Q_SLOTS: void tst_QObject::connectNotify_connectSlotsByName() { ConnectByNameNotifyReceiverObject testObject; - QList senders = - qFindChildren(&testObject); - for (int i = 0; i < senders.size(); ++i) { - ConnectByNameNotifySenderObject *o = senders.at(i); + const QList senders = + testObject.findChildren(); + for (ConnectByNameNotifySenderObject *o : senders) { QVERIFY(o->connectedSignals.isEmpty()); QVERIFY(o->disconnectedSignals.isEmpty()); } QMetaObject::connectSlotsByName(&testObject); - for (int i = 0; i < senders.size(); ++i) { - ConnectByNameNotifySenderObject *o = senders.at(i); + for (ConnectByNameNotifySenderObject *o : senders) { QCOMPARE(o->connectedSignals.size(), 1); QCOMPARE(o->connectedSignals.at(0), QMetaMethod::fromSignal(&ConnectByNameNotifySenderObject::signal1)); QVERIFY(o->disconnectedSignals.isEmpty()); @@ -1631,7 +1628,7 @@ void tst_QObject::thread() QObject object; // thread affinity for objects with no parent should be the // current thread - QVERIFY(object.thread() != 0); + QVERIFY(object.thread() != nullptr); QCOMPARE(object.thread(), currentThread); // children inherit their parent's thread QObject child(&object); @@ -1643,7 +1640,7 @@ void tst_QObject::thread() { TestThread thr; - QVERIFY(thr.thread() != 0); + QVERIFY(thr.thread() != nullptr); QCOMPARE(thr.thread(), currentThread); thr.object = &object; @@ -1802,8 +1799,8 @@ void tst_QObject::moveToThread() QMetaObject::invokeMethod(object, "deleteLater", Qt::QueuedConnection); thread.wait(); - QVERIFY(opointer == 0); - QVERIFY(cpointer == 0); + QVERIFY(opointer == nullptr); + QVERIFY(cpointer == nullptr); } { @@ -2379,7 +2376,7 @@ void tst_QObject::testUserData() for (int i=0; i(my_test_object.userData(id)); - QVERIFY(data != 0); + QVERIFY(data != nullptr); QCOMPARE(data->id, id); } } @@ -3627,7 +3624,7 @@ class OverloadObject : public QObject void sig(int i, int j = 12); void sig(QObject *o, QObject *p, QObject *q = 0, QObject *r = 0) const; void other(int a = 0); - void sig(QObject *o, OverloadObject *p = 0, QObject *q = 0, QObject *r = 0); + void sig(QObject *o, OverloadObject *p = 0, QObject *q = 0, QObject *r = nullptr); void sig(double r = 0.5); public slots: void slo(int i, int j = 43) From b3c52e82245f46af9ce633a6de1e4e41fb9f3f6d Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 10 Feb 2019 18:43:05 +0100 Subject: [PATCH 15/17] Simplify {to,from}Std{List,Vector} Use the newly-added range constructors. Change-Id: I7f1d2699d88656fb7dddd11a9d781d810d45b0b4 Reviewed-by: Marc Mutz --- src/corelib/tools/qlist.h | 15 ++++----------- src/corelib/tools/qvector.h | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 04c1f12f5f..70bbc11ad2 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -414,10 +414,10 @@ public: Q_DECL_DEPRECATED_X("Use QList(list.begin(), list.end()) instead.") static inline QList fromStdList(const std::list &list) - { QList tmp; std::copy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; } + { return QList(list.begin(), list.end()); } Q_DECL_DEPRECATED_X("Use std::list(list.begin(), list.end()) instead.") inline std::list toStdList() const - { std::list tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } + { return std::list(begin(), end()); } #endif private: @@ -1105,10 +1105,7 @@ inline int QList::count_impl(const T &t, QListData::ArrayCompatibleLayout) co template Q_OUTOFLINE_TEMPLATE QVector QList::toVector() const { - QVector result(size()); - for (int i = 0; i < size(); ++i) - result[i] = at(i); - return result; + return QVector(begin(), end()); } template @@ -1120,11 +1117,7 @@ QList QList::fromVector(const QVector &vector) template Q_OUTOFLINE_TEMPLATE QList QVector::toList() const { - QList result; - result.reserve(size()); - for (int i = 0; i < size(); ++i) - result.append(at(i)); - return result; + return QList(begin(), end()); } template diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index c223e4efa0..5d68a283bd 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -303,7 +303,7 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6,0,0) Q_DECL_DEPRECATED_X("Use QVector(vector.begin(), vector.end()) instead.") static inline QVector fromStdVector(const std::vector &vector) - { QVector tmp; tmp.reserve(int(vector.size())); std::copy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } + { return QVector(vector.begin(), vector.end()); } Q_DECL_DEPRECATED_X("Use std::vector(vector.begin(), vector.end()) instead.") inline std::vector toStdVector() const { return std::vector(d->begin(), d->end()); } From d7093487a36b0b1a35c28d065f4f0a5890676216 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Tue, 20 Mar 2018 14:27:45 +0100 Subject: [PATCH 16/17] rtems: Disable fork feature and fix compilation in corelib/io RTEMS does not support fork. RTEMS has LOCK_EX and LOCK_NB defines but does not have flock. Change-Id: I2b1774435bc972f53596f4163ec410b9d22aca4a Reviewed-by: Ryan Chu --- src/corelib/io/io.pri | 2 +- src/corelib/io/qlockfile_unix.cpp | 5 +++++ src/corelib/io/qstorageinfo_unix.cpp | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 13b43ad8f7..fe81689932 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -172,7 +172,7 @@ win32 { io/qlockfile_unix.cpp \ io/qfilesystemiterator_unix.cpp - !integrity:!uikit { + !integrity:!uikit:!rtems { SOURCES += io/forkfd_qt.cpp HEADERS += \ ../3rdparty/forkfd/forkfd.h diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 4a12157607..b2bf77c0da 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -58,6 +58,11 @@ #include // flock #endif +#if defined(Q_OS_RTEMS) +# undef LOCK_EX +# undef LOCK_NB +#endif + #include // kill #include // kill #include // gethostname diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index b7621b5d2f..d25a607d9f 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -812,7 +812,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo() valid = true; ready = true; -#if defined(Q_OS_INTEGRITY) || (defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)) +#if defined(Q_OS_INTEGRITY) || (defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)) || defined(Q_OS_RTEMS) bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize; bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize; bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize; @@ -822,7 +822,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo() bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize; #endif blockSize = statfs_buf.f_bsize; -#if defined(Q_OS_ANDROID) || defined(Q_OS_BSD4) || defined(Q_OS_INTEGRITY) +#if defined(Q_OS_ANDROID) || defined(Q_OS_BSD4) || defined(Q_OS_INTEGRITY) || defined(Q_OS_RTEMS) #if defined(_STATFS_F_FLAGS) readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0; #endif From 3e75c2965c96fa014ab74121e84d623fd04a27f7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 10 Jun 2019 00:09:10 +0200 Subject: [PATCH 17/17] Remove QLatin1Literal usages That's an undocumented Qt 4/3/2 remnant, start remove usages. Fix incorrect include header in qclass_lib_map.h as a drive-by. Change-Id: I939be2621bc03e5c75f7e3f152546d3af6d37b91 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- qmake/generators/mac/pbuilder_pbx.cpp | 2 +- src/gui/painting/qbrush.cpp | 16 +++++----- src/plugins/platforms/ios/qioscontext.mm | 2 +- .../xcb/nativepainting/qpaintengine_x11.cpp | 2 +- src/testlib/qtaptestlogger.cpp | 24 +++++++-------- src/tools/uic/qclass_lib_map.h | 2 +- .../qmetaproperty/tst_qmetaproperty.cpp | 6 ++-- .../corelib/kernel/qobject/tst_qobject.cpp | 2 +- tests/auto/gui/painting/qbrush/tst_qbrush.cpp | 6 ++-- .../qdatetimeedit/tst_qdatetimeedit.cpp | 30 +++++++++---------- .../qdoublespinbox/tst_qdoublespinbox.cpp | 18 +++++------ .../widgets/widgets/qspinbox/tst_qspinbox.cpp | 18 +++++------ .../corelib/tools/qstringbuilder/main.cpp | 2 +- 13 files changed, 65 insertions(+), 65 deletions(-) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index b3c6ba4869..3acc351b12 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -1467,7 +1467,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) << "\t\t\t" << writeSettings("name", "Qt Test") << ";\n" << "\t\t};\n"; - QLatin1Literal testTargetID("TestTargetID"); + QLatin1String testTargetID("TestTargetID"); project->values(ProKey("QMAKE_PBX_TARGET_ATTRIBUTES_" + testTargetKey + "_" + testTargetID)).append(keyFor(pbx_dir + "QMAKE_PBX_TARGET")); project->values(ProKey("QMAKE_PBX_TARGET_ATTRIBUTES_" + testTargetKey)).append(ProKey(testTargetID)); } diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 13d986073e..21e41979af 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -1385,16 +1385,16 @@ QGradient::QGradient(Preset preset) setCoordinateMode(ObjectMode); setSpread(PadSpread); - const QJsonValue start = presetData[QLatin1Literal("start")]; - const QJsonValue end = presetData[QLatin1Literal("end")]; - m_data.linear.x1 = start[QLatin1Literal("x")].toDouble(); - m_data.linear.y1 = start[QLatin1Literal("y")].toDouble(); - m_data.linear.x2 = end[QLatin1Literal("x")].toDouble(); - m_data.linear.y2 = end[QLatin1Literal("y")].toDouble(); + const QJsonValue start = presetData[QLatin1String("start")]; + const QJsonValue end = presetData[QLatin1String("end")]; + m_data.linear.x1 = start[QLatin1String("x")].toDouble(); + m_data.linear.y1 = start[QLatin1String("y")].toDouble(); + m_data.linear.x2 = end[QLatin1String("x")].toDouble(); + m_data.linear.y2 = end[QLatin1String("y")].toDouble(); for (const QJsonValue &stop : presetData[QLatin1String("stops")].toArray()) { - setColorAt(stop[QLatin1Literal("position")].toDouble(), - QColor(QRgb(stop[QLatin1Literal("color")].toInt()))); + setColorAt(stop[QLatin1String("position")].toDouble(), + QColor(QRgb(stop[QLatin1String("color")].toInt()))); } cachedPresets.insert(preset, *this); diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 535e7d7aa6..c9509ae599 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -118,7 +118,7 @@ QSurfaceFormat QIOSContext::format() const return m_format; } -#define QT_IOS_GL_STATUS_CASE(val) case val: return QLatin1Literal(#val) +#define QT_IOS_GL_STATUS_CASE(val) case val: return QLatin1String(#val) static QString fboStatusString(GLenum status) { diff --git a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp index 8d958aae94..82b6d60bcd 100644 --- a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp @@ -455,7 +455,7 @@ static const uchar base_dither_matrix[DITHER_SIZE][DITHER_SIZE] = { static QPixmap qt_patternForAlpha(uchar alpha, int screen) { QPixmap pm; - QString key = QLatin1Literal("$qt-alpha-brush$") + QString key = QLatin1String("$qt-alpha-brush$") % HexString(alpha) % HexString(screen); diff --git a/src/testlib/qtaptestlogger.cpp b/src/testlib/qtaptestlogger.cpp index 540b36e273..476761e602 100644 --- a/src/testlib/qtaptestlogger.cpp +++ b/src/testlib/qtaptestlogger.cpp @@ -154,10 +154,10 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description, // This is fragile, but unfortunately testlib doesn't plumb // the expected and actual values to the loggers (yet). static QRegularExpression verifyRegex( - QLatin1Literal("^'(?.*)' returned (?\\w+).+\\((?.*)\\)$")); + QLatin1String("^'(?.*)' returned (?\\w+).+\\((?.*)\\)$")); static QRegularExpression comparRegex( - QLatin1Literal("^(?.*)\n" + QLatin1String("^(?.*)\n" "\\s*Actual\\s+\\((?.*)\\)\\s*: (?.*)\n" "\\s*Expected\\s+\\((?.*)\\)\\s*: (?.*)$")); @@ -168,22 +168,22 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description, if (match.hasMatch()) { bool isVerify = match.regularExpression() == verifyRegex; - QString message = match.captured(QLatin1Literal("message")); + QString message = match.captured(QLatin1String("message")); QString expected; QString actual; if (isVerify) { - QString expression = QLatin1Literal(" (") - % match.captured(QLatin1Literal("actualexpression")) % QLatin1Char(')') ; - actual = match.captured(QLatin1Literal("actual")).toLower() % expression; - expected = (actual.startsWith(QLatin1Literal("true")) ? QLatin1Literal("false") : QLatin1Literal("true")) % expression; + QString expression = QLatin1String(" (") + % match.captured(QLatin1String("actualexpression")) % QLatin1Char(')') ; + actual = match.captured(QLatin1String("actual")).toLower() % expression; + expected = (actual.startsWith(QLatin1String("true")) ? QLatin1String("false") : QLatin1String("true")) % expression; if (message.isEmpty()) - message = QLatin1Literal("Verification failed"); + message = QLatin1String("Verification failed"); } else { - expected = match.captured(QLatin1Literal("expected")) - % QLatin1Literal(" (") % match.captured(QLatin1Literal("expectedexpresssion")) % QLatin1Char(')'); - actual = match.captured(QLatin1Literal("actual")) - % QLatin1Literal(" (") % match.captured(QLatin1Literal("actualexpression")) % QLatin1Char(')'); + expected = match.captured(QLatin1String("expected")) + % QLatin1String(" (") % match.captured(QLatin1String("expectedexpresssion")) % QLatin1Char(')'); + actual = match.captured(QLatin1String("actual")) + % QLatin1String(" (") % match.captured(QLatin1String("actualexpression")) % QLatin1Char(')'); } QTestCharBuffer diagnosticsYamlish; diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index 8e1afa0878..8cebe65a00 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -249,7 +249,7 @@ QT_CLASS_LIB(QLatin1String, QtCore, qstring.h) QT_CLASS_LIB(QCharRef, QtCore, qstring.h) QT_CLASS_LIB(QConstString, QtCore, qstring.h) QT_CLASS_LIB(QStringRef, QtCore, qstring.h) -QT_CLASS_LIB(QLatin1Literal, QtCore, qstringbuilder.h) +QT_CLASS_LIB(QLatin1Literal, QtCore, qstring.h) QT_CLASS_LIB(QAbstractConcatenable, QtCore, qstringbuilder.h) QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h) QT_CLASS_LIB(QStringBuilder, QtCore, qstringbuilder.h) diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp index 681a5d0146..cc67fc7884 100644 --- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp +++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp @@ -130,7 +130,7 @@ public: QString m_value; void setValue(const QString &value) { m_value = value; } QString getValue() { return m_value; } - void resetValue() { m_value = QLatin1Literal("reset"); } + void resetValue() { m_value = QLatin1String("reset"); } }; void tst_QMetaProperty::gadget() @@ -140,7 +140,7 @@ void tst_QMetaProperty::gadget() QVERIFY(valueProp.isValid()); { MyGadget g; - QString hello = QLatin1Literal("hello"); + QString hello = QLatin1String("hello"); QVERIFY(valueProp.writeOnGadget(&g, hello)); QCOMPARE(g.m_value, QLatin1String("hello")); QCOMPARE(valueProp.readOnGadget(&g), QVariant(hello)); @@ -242,7 +242,7 @@ void tst_QMetaProperty::conversion() QCOMPARE(custom.str, QString()); // or reset resetable QVERIFY(value7P.write(this, QVariant())); - QCOMPARE(value7, QLatin1Literal("reset")); + QCOMPARE(value7, QLatin1String("reset")); } QTEST_MAIN(tst_QMetaProperty) diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index f1c4effa95..7c9d8a476a 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -5979,7 +5979,7 @@ void ConnectToPrivateSlot::test(SenderObject* obj1) { obj1->signal1(); QCOMPARE(d->receivedCount, 1); QCOMPARE(d->receivedValue, QVariant()); - obj1->signal7(666, QLatin1Literal("_")); + obj1->signal7(666, QLatin1String("_")); QCOMPARE(d->receivedCount, 2); QCOMPARE(d->receivedValue, QVariant(666)); QVERIFY(QObjectPrivate::connect(obj1, &SenderObject::signal2, d, &ConnectToPrivateSlotPrivate::thisIsAPrivateSlot, Qt::UniqueConnection)); diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp index ce6ce15767..f35d4f330b 100644 --- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp +++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp @@ -338,9 +338,9 @@ void tst_QBrush::gradientPresets() QCOMPARE(lg->finalStop(), QPointF(1, 0)); QCOMPARE(lg->stops().size(), 3); - QCOMPARE(lg->stops().at(0), QGradientStop(0, QColor(QLatin1Literal("#ff9a9e")))); - QCOMPARE(lg->stops().at(1), QGradientStop(0.99, QColor(QLatin1Literal("#fad0c4")))); - QCOMPARE(lg->stops().at(2), QGradientStop(1, QColor(QLatin1Literal("#fad0c4")))); + QCOMPARE(lg->stops().at(0), QGradientStop(0, QColor(QLatin1String("#ff9a9e")))); + QCOMPARE(lg->stops().at(1), QGradientStop(0.99, QColor(QLatin1String("#fad0c4")))); + QCOMPARE(lg->stops().at(2), QGradientStop(1, QColor(QLatin1String("#fad0c4")))); QGradient invalidPreset(QGradient::Preset(-1)); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index b5ef454b14..c6f6900def 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -307,19 +307,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -331,17 +331,17 @@ static QLatin1String sectionToName(const QDateTimeEdit::Section section) { switch (section) { case QDateTimeEdit::SecondSection: - return QLatin1Literal("Second"); + return QLatin1String("Second"); case QDateTimeEdit::MinuteSection: - return QLatin1Literal("Minute"); + return QLatin1String("Minute"); case QDateTimeEdit::HourSection: - return QLatin1Literal("Hours"); + return QLatin1String("Hours"); case QDateTimeEdit::DaySection: - return QLatin1Literal("Day"); + return QLatin1String("Day"); case QDateTimeEdit::MonthSection: - return QLatin1Literal("Month"); + return QLatin1String("Month"); case QDateTimeEdit::YearSection: - return QLatin1Literal("Year"); + return QLatin1String("Year"); default: qFatal("Unexpected section"); return QLatin1String(); @@ -3217,16 +3217,16 @@ void tst_QDateTimeEdit::wheelEvent_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 954ee6471d..a20b5568da 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -221,19 +221,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -1448,16 +1448,16 @@ void tst_QDoubleSpinBox::wheelEvents_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 7bce23af26..3dd29b0214 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -222,19 +222,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -1402,16 +1402,16 @@ void tst_QSpinBox::wheelEvents_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); diff --git a/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp b/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp index d0dfe3b1a7..0de6d33846 100644 --- a/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp +++ b/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp @@ -401,7 +401,7 @@ private slots: } private: - const QLatin1Literal l1literal; + const QLatin1String l1literal; const QLatin1String l1string; const QByteArray ba; const QString string;