diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake index 547aaad48ad..1613455fc6d 100644 --- a/cmake/QtCreatorAPI.cmake +++ b/cmake/QtCreatorAPI.cmake @@ -1,5 +1,18 @@ include(FeatureSummary) +# +# Default Qt compilation defines +# + +list(APPEND DEFAULT_DEFINES + QT_CREATOR + QT_NO_JAVA_STYLE_ITERATORS + QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII + QT_DISABLE_DEPRECATED_BEFORE=0x050900 + QT_USE_FAST_OPERATOR_PLUS + QT_USE_FAST_CONCATENATION +) + # # Setup path handling # diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a4e013627c8..c0a0b979f4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,13 +1,3 @@ -# Not in the main CMakeLists.txt file because some tests fail if we have the flags set as default -list(APPEND DEFAULT_DEFINES - QT_CREATOR - QT_NO_JAVA_STYLE_ITERATORS - QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII - QT_DISABLE_DEPRECATED_BEFORE=0x050900 - QT_USE_FAST_OPERATOR_PLUS - QT_USE_FAST_CONCATENATION -) - add_library(app_version INTERFACE) target_include_directories(app_version INTERFACE $) install(TARGETS app_version EXPORT QtCreator) diff --git a/tests/auto/cplusplus/lexer/tst_lexer.cpp b/tests/auto/cplusplus/lexer/tst_lexer.cpp index 72900df6982..79548e6fd46 100644 --- a/tests/auto/cplusplus/lexer/tst_lexer.cpp +++ b/tests/auto/cplusplus/lexer/tst_lexer.cpp @@ -127,7 +127,7 @@ void tst_SimpleLexer::run(const QByteArray &source, languageFeatures.flags |= extraLanguageFeatures.flags; lexer.setLanguageFeatures(languageFeatures); } - const Tokens tokens = lexer(source, preserveState ? _state : 0); + const Tokens tokens = lexer(QString::fromUtf8(source), preserveState ? _state : 0); if (preserveState) _state = lexer.state(); diff --git a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp index 6c628c5c7f7..005ea5c1fad 100644 --- a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp +++ b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp @@ -217,10 +217,8 @@ public: dir = QFileInfo(currentFileName).dir(); const QFileInfo inc(dir, includedFileName); if (inc.exists()) { - const QString resolved = inc.filePath(); - return resolved.toUtf8().constData(); + return inc.filePath(); } else { - // std::cerr<<"Cannot find " << inc.fileName().toUtf8().constData()< lines = buf.split('\n'); foreach (const QByteArray &line, lines) { if (!line.startsWith('#')) { - out.append(' '); - out.append(line); + out.append(" "); + out.append(QString::fromUtf8(line)); } } diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index f1413dee6ac..e5be41a104c 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -281,7 +281,7 @@ static QString parentIName(const QString &iname) struct Value { Value() : value(noValue) {} - Value(const char *str) : value(str) {} + Value(const char *str) : value(QString::fromUtf8(str)) {} Value(const QString &str) : value(str) {} bool matches(const QString &actualValue0, const Context &context) const @@ -595,11 +595,11 @@ struct CheckType : public Check { CheckType(const QByteArray &iname, const Name &name, const Type &type) - : Check(iname, name, noValue, type) + : Check(QString::fromUtf8(iname), name, noValue, type) {} CheckType(const QByteArray &iname, const Type &type) - : Check(iname, noValue, type) + : Check(QString::fromUtf8(iname), noValue, type) {} }; @@ -609,19 +609,23 @@ const QtVersion Qt5 = QtVersion(0x50000); struct Check4 : Check { Check4(const QByteArray &iname, const Value &value, const Type &type) - : Check(iname, value, type) { qtVersionForCheck = Qt4; } + : Check(QString::fromUtf8(iname), value, type) + { qtVersionForCheck = Qt4; } Check4(const QByteArray &iname, const Name &name, const Value &value, const Type &type) - : Check(iname, name, value, type) { qtVersionForCheck = Qt4; } + : Check(QString::fromUtf8(iname), name, value, type) + { qtVersionForCheck = Qt4; } }; struct Check5 : Check { Check5(const QByteArray &iname, const Value &value, const Type &type) - : Check(iname, value, type) { qtVersionForCheck = Qt5; } + : Check(QString::fromUtf8(iname), value, type) + { qtVersionForCheck = Qt5; } Check5(const QByteArray &iname, const Name &name, const Value &value, const Type &type) - : Check(iname, name, value, type) { qtVersionForCheck = Qt5; } + : Check(QString::fromUtf8(iname), name, value, type) + { qtVersionForCheck = Qt5; } }; @@ -733,8 +737,8 @@ public: const Data &operator+(const Profile &profile) const { - profileExtra += profile.contents; - includes += profile.includes; + profileExtra += QString::fromUtf8(profile.contents); + includes += QString::fromUtf8(profile.includes); return *this; } @@ -1613,7 +1617,7 @@ void tst_Dumpers::dumper() contents = output.mid(posDataStart); contents.replace("\\\"", "\""); - actual.fromStringMultiple(contents); + actual.fromStringMultiple(QString::fromLocal8Bit(contents)); context.nameSpace = actual["qtnamespace"].data(); actual = actual["data"]; //qDebug() << "FOUND NS: " << context.nameSpace; @@ -1632,12 +1636,13 @@ void tst_Dumpers::dumper() posNameSpaceStart += sizeof("@NS@") - 1; int posNameSpaceEnd = output.indexOf("@", posNameSpaceStart); QVERIFY(posNameSpaceEnd != -1); - context.nameSpace = output.mid(posNameSpaceStart, posNameSpaceEnd - posNameSpaceStart); + context.nameSpace = QString::fromLocal8Bit(output.mid( + posNameSpaceStart, posNameSpaceEnd - posNameSpaceStart)); //qDebug() << "FOUND NS: " << context.nameSpace; if (context.nameSpace == "::") context.nameSpace.clear(); contents.replace("\\\"", "\""); - actual.fromString(contents); + actual.fromString(QString::fromLocal8Bit(contents)); } else { QByteArray localsAnswerStart("|R|42|"); QByteArray locals("|script|"); @@ -1653,7 +1658,7 @@ void tst_Dumpers::dumper() if (localsBeginPos != -1) localsBeginPos = output.indexOf(locals, localsBeginPos); } while (localsBeginPos != -1); - actual.fromString(contents); + actual.fromString(QString::fromLocal8Bit(contents)); context.nameSpace = actual["result"]["qtnamespace"].data(); actual = actual["result"]["data"]; } diff --git a/tests/auto/json/tst_json.cpp b/tests/auto/json/tst_json.cpp index 1253f00806c..cb38a70489a 100644 --- a/tests/auto/json/tst_json.cpp +++ b/tests/auto/json/tst_json.cpp @@ -1571,8 +1571,8 @@ void tst_Json::fromBinary() void tst_Json::toAndFromBinary_data() { QTest::addColumn("filename"); - QTest::newRow("test.json") << (testDataDir + QLatin1String("/test.json")); - QTest::newRow("test2.json") << (testDataDir + QLatin1String("/test2.json")); + QTest::newRow("test.json") << QString(testDataDir + QLatin1String("/test.json")); + QTest::newRow("test2.json") << QString(testDataDir + QLatin1String("/test2.json")); } void tst_Json::toAndFromBinary() diff --git a/tests/auto/qml/codemodel/check/tst_check.cpp b/tests/auto/qml/codemodel/check/tst_check.cpp index 4c9a8e4d65f..9f5207284be 100644 --- a/tests/auto/qml/codemodel/check/tst_check.cpp +++ b/tests/auto/qml/codemodel/check/tst_check.cpp @@ -114,7 +114,7 @@ void tst_Check::test() Document::MutablePtr doc = Document::create(path, Dialect::Qml); QFile file(doc->fileName()); file.open(QFile::ReadOnly | QFile::Text); - doc->setSource(file.readAll()); + doc->setSource(QString::fromUtf8(file.readAll())); file.close(); doc->parse(); snapshot.insert(doc); diff --git a/tests/auto/qml/codemodel/dependencies/tst_dependencies.cpp b/tests/auto/qml/codemodel/dependencies/tst_dependencies.cpp index 79ce9cec1be..3139e6feca5 100644 --- a/tests/auto/qml/codemodel/dependencies/tst_dependencies.cpp +++ b/tests/auto/qml/codemodel/dependencies/tst_dependencies.cpp @@ -74,7 +74,7 @@ struct TestData static TestData testData(const QString &path) { QFile file(path); file.open(QFile::ReadOnly | QFile::Text); - const QString content = QString(file.readAll()); + const QString content = QString::fromUtf8(file.readAll()); file.close(); Document::MutablePtr doc = Document::create(path, Dialect::Qml); diff --git a/tests/auto/qml/codemodel/ecmascript7/tst_ecmascript7.cpp b/tests/auto/qml/codemodel/ecmascript7/tst_ecmascript7.cpp index 735daa04f71..ea530d21437 100644 --- a/tests/auto/qml/codemodel/ecmascript7/tst_ecmascript7.cpp +++ b/tests/auto/qml/codemodel/ecmascript7/tst_ecmascript7.cpp @@ -76,7 +76,7 @@ static TestData testData(const QString &path) { QFile file(path); file.open(QFile::ReadOnly | QFile::Text); - const QString content = QString(file.readAll()); + const QString content = QString::fromUtf8(file.readAll()); file.close(); Document::MutablePtr doc = Document::create(path, Dialect::Qml); @@ -96,7 +96,7 @@ static QStringList readSkipList(const QDir &dir, const QString &filename) return QStringList(); while (!f.atEnd()) { - const QString s = f.readLine().trimmed(); + const QString s = QString::fromUtf8(f.readLine().trimmed()); if (!s.isEmpty()) result << dir.absoluteFilePath(s); } diff --git a/tests/auto/qml/qmljssimplereader/tst_qmljssimplereader.cpp b/tests/auto/qml/qmljssimplereader/tst_qmljssimplereader.cpp index c42053083ec..a17ef2d993e 100644 --- a/tests/auto/qml/qmljssimplereader/tst_qmljssimplereader.cpp +++ b/tests/auto/qml/qmljssimplereader/tst_qmljssimplereader.cpp @@ -67,7 +67,7 @@ void tst_SimpleReader::testWellFormed() SimpleReaderNode::WeakPtr weak02; { SimpleReader reader; - SimpleReaderNode::Ptr rootNode = reader.readFromSource(source); + SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source)); QVERIFY(reader.errors().isEmpty()); QVERIFY(rootNode); QVERIFY(rootNode->isValid()); @@ -130,7 +130,7 @@ void tst_SimpleReader::testIllFormed01() " propertyBlah: false\n" "}\n"; SimpleReader reader; - SimpleReaderNode::Ptr rootNode = reader.readFromSource(source); + SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source)); QVERIFY(!rootNode); QVERIFY(!reader.errors().empty()); @@ -153,7 +153,7 @@ void tst_SimpleReader::testIllFormed02() "}\n"; SimpleReader reader; - SimpleReaderNode::Ptr rootNode = reader.readFromSource(source); + SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source)); QVERIFY(rootNode); QVERIFY(rootNode->isValid()); @@ -188,7 +188,7 @@ void tst_SimpleReader::testArrays() const QVariant variant = variantList; SimpleReader reader; - SimpleReaderNode::Ptr rootNode = reader.readFromSource(source); + SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source)); QVERIFY(rootNode); QVERIFY(rootNode->isValid()); @@ -239,7 +239,7 @@ void tst_SimpleReader::testBug01() "}\n"; SimpleReader reader; - SimpleReaderNode::Ptr rootNode = reader.readFromSource(source); + SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source)); QVERIFY(rootNode); QVERIFY(rootNode->isValid()); diff --git a/tests/auto/ssh/tst_ssh.cpp b/tests/auto/ssh/tst_ssh.cpp index dfc60952ae1..5283f71960c 100644 --- a/tests/auto/ssh/tst_ssh.cpp +++ b/tests/auto/ssh/tst_ssh.cpp @@ -89,10 +89,10 @@ static SshConnectionParameters getParameters() } \ if (params.userName().isEmpty()) \ QSKIP(qPrintable(QString::fromLatin1("No user name provided. Set %1.") \ - .arg(userVar()))); \ + .arg(QString::fromUtf8(userVar())))); \ if (params.privateKeyFile.isEmpty()) \ QSKIP(qPrintable(QString::fromLatin1("No key file provided. Set %1.") \ - .arg(keyFileVar()))); \ + .arg(QString::fromUtf8(keyFileVar())))); \ } while (false) class tst_Ssh : public QObject @@ -234,9 +234,9 @@ void tst_Ssh::remoteProcess() connect(&runner, &SshRemoteProcessRunner::readyReadStandardError, [&remoteStderr, &runner] { remoteStderr += runner.readAllStandardError(); }); if (useTerminal) - runner.runInTerminal(commandLine, params); + runner.runInTerminal(QString::fromUtf8(commandLine), params); else - runner.run(commandLine, params); + runner.run(QString::fromUtf8(commandLine), params); QTimer timer; QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); timer.setSingleShot(true); @@ -254,7 +254,7 @@ void tst_Ssh::remoteProcess() SshRemoteProcessRunner killer; if (isBlocking) - killer.run("pkill -f -9 \"" + commandLine + '"', params); + killer.run("pkill -f -9 \"" + QString::fromUtf8(commandLine) + '"', params); timer.start(); loop.exec(); @@ -285,7 +285,7 @@ void tst_Ssh::remoteProcessChannels() QByteArray remoteStderr; QByteArray remoteData; SshRemoteProcessPtr echoProcess - = connection.createRemoteProcess("printf " + testString + " >&2"); + = connection.createRemoteProcess("printf " + QString::fromUtf8(testString) + " >&2"); echoProcess->setReadChannel(QProcess::StandardError); QEventLoop loop; connect(echoProcess.get(), &SshRemoteProcess::done, &loop, &QEventLoop::quit); diff --git a/tests/auto/utils/stringutils/tst_stringutils.cpp b/tests/auto/utils/stringutils/tst_stringutils.cpp index 98e04185ab3..010e6ce8b42 100644 --- a/tests/auto/utils/stringutils/tst_stringutils.cpp +++ b/tests/auto/utils/stringutils/tst_stringutils.cpp @@ -194,7 +194,7 @@ void tst_StringUtils::testStripAccelerator() { QFETCH(QString, expected); - QCOMPARE(Utils::stripAccelerator(QTest::currentDataTag()), expected); + QCOMPARE(Utils::stripAccelerator(QString::fromUtf8(QTest::currentDataTag())), expected); } void tst_StringUtils::testStripAccelerator_data() diff --git a/tests/unit/unittest/builddependencycollector-test.cpp b/tests/unit/unittest/builddependencycollector-test.cpp index 7bfe6de4cca..5be0689ef64 100644 --- a/tests/unit/unittest/builddependencycollector-test.cpp +++ b/tests/unit/unittest/builddependencycollector-test.cpp @@ -128,7 +128,7 @@ protected: static std::time_t lastModified(Utils::SmallStringView filePath) { - return QFileInfo(QString(filePath)).lastModified().toTime_t(); + return QFileInfo(QString(filePath)).lastModified().toSecsSinceEpoch(); } ClangBackEnd::FileStatus fileStatus(Utils::SmallStringView filePath) const diff --git a/tests/unit/unittest/symbolscollector-test.cpp b/tests/unit/unittest/symbolscollector-test.cpp index 47190307375..5954f8a9f5a 100644 --- a/tests/unit/unittest/symbolscollector-test.cpp +++ b/tests/unit/unittest/symbolscollector-test.cpp @@ -146,7 +146,7 @@ protected: static std::time_t lastModified(Utils::SmallStringView filePath) { - return QFileInfo(QString(filePath)).lastModified().toTime_t(); + return QFileInfo(QString(filePath)).lastModified().toSecsSinceEpoch(); } ClangBackEnd::FileStatus fileStatus(Utils::SmallStringView filePath) const diff --git a/tests/unit/unittest/usedmacrocollector-test.cpp b/tests/unit/unittest/usedmacrocollector-test.cpp index 31aa4fab382..191662db6b0 100644 --- a/tests/unit/unittest/usedmacrocollector-test.cpp +++ b/tests/unit/unittest/usedmacrocollector-test.cpp @@ -63,7 +63,7 @@ protected: static std::time_t lastModified(Utils::SmallStringView filePath) { - return QFileInfo(QString(filePath)).lastModified().toTime_t(); + return QFileInfo(QString(filePath)).lastModified().toSecsSinceEpoch(); } ClangBackEnd::FileStatus fileStatus(Utils::SmallStringView filePath) const