diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/bootstrap/bootstrap.pro | 6 | ||||
-rw-r--r-- | src/tools/moc/generator.cpp | 33 | ||||
-rw-r--r-- | src/tools/moc/main.cpp | 2 | ||||
-rw-r--r-- | src/tools/moc/moc.cpp | 7 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 29 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.h | 1 | ||||
-rw-r--r-- | src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 17 | ||||
-rw-r--r-- | src/tools/qfloat16-tables/gen_qfloat16_tables.cpp | 161 | ||||
-rw-r--r-- | src/tools/qfloat16-tables/qfloat16-tables.pro | 9 | ||||
-rw-r--r-- | src/tools/rcc/main.cpp | 5 | ||||
-rw-r--r-- | src/tools/rcc/rcc.cpp | 5 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteincludes.cpp | 24 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteincludes.h | 4 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 10 | ||||
-rw-r--r-- | src/tools/uic/main.cpp | 2 |
15 files changed, 260 insertions, 55 deletions
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 2acc3fc77c..507b5260cd 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -28,6 +28,7 @@ SOURCES += \ ../../corelib/global/qlogging.cpp \ ../../corelib/global/qmalloc.cpp \ ../../corelib/global/qnumeric.cpp \ + ../../corelib/global/qoperatingsystemversion.cpp \ ../../corelib/io/qabstractfileengine.cpp \ ../../corelib/io/qbuffer.cpp \ ../../corelib/io/qdatastream.cpp \ @@ -45,6 +46,7 @@ SOURCES += \ ../../corelib/io/qresource.cpp \ ../../corelib/io/qtemporaryfile.cpp \ ../../corelib/io/qtextstream.cpp \ + ../../corelib/io/qsavefile.cpp \ ../../corelib/io/qstandardpaths.cpp \ ../../corelib/io/qloggingcategory.cpp \ ../../corelib/io/qloggingregistry.cpp \ @@ -95,7 +97,8 @@ unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \ ../../corelib/io/qfilesystemiterator_unix.cpp \ ../../corelib/io/qfsfileengine_unix.cpp -win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ +win32:SOURCES += ../../corelib/global/qoperatingsystemversion_win.cpp \ + ../../corelib/io/qfilesystemengine_win.cpp \ ../../corelib/io/qfilesystemiterator_win.cpp \ ../../corelib/io/qfsfileengine_win.cpp \ ../../corelib/kernel/qcoreapplication_win.cpp \ @@ -106,6 +109,7 @@ mac { ../../corelib/kernel/qcoreapplication_mac.cpp \ ../../corelib/kernel/qcore_mac.cpp OBJECTIVE_SOURCES += \ + ../../corelib/global/qoperatingsystemversion_darwin.mm \ ../../corelib/kernel/qcore_mac_objc.mm \ ../../corelib/kernel/qcore_foundation.mm diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index ccc6d795d7..674398e783 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -515,7 +515,7 @@ void Generator::generateCode() for (int i = 0; i < extraList.count(); ++i) { fprintf(out, " &%s::staticMetaObject,\n", extraList.at(i).constData()); } - fprintf(out, " Q_NULLPTR\n};\n\n"); + fprintf(out, " nullptr\n};\n\n"); } // @@ -527,24 +527,24 @@ void Generator::generateCode() fprintf(out, "const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData()); if (isQObject) - fprintf(out, " { Q_NULLPTR, "); + fprintf(out, " { nullptr, "); else if (cdef->superclassList.size() && (!cdef->hasQGadget || knownGadgets.contains(purestSuperClass))) fprintf(out, " { &%s::staticMetaObject, ", purestSuperClass.constData()); else - fprintf(out, " { Q_NULLPTR, "); + fprintf(out, " { nullptr, "); fprintf(out, "qt_meta_stringdata_%s.data,\n" " qt_meta_data_%s, ", qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData()); if (hasStaticMetaCall) fprintf(out, " qt_static_metacall, "); else - fprintf(out, " Q_NULLPTR, "); + fprintf(out, " nullptr, "); if (extraList.isEmpty()) - fprintf(out, "Q_NULLPTR, "); + fprintf(out, "nullptr, "); else fprintf(out, "qt_meta_extradata_%s, ", qualifiedClassNameIdentifier.constData()); - fprintf(out, "Q_NULLPTR}\n};\n\n"); + fprintf(out, "nullptr}\n};\n\n"); if(isQt) return; @@ -559,7 +559,7 @@ void Generator::generateCode() // Generate smart cast function // fprintf(out, "\nvoid *%s::qt_metacast(const char *_clname)\n{\n", cdef->qualified.constData()); - fprintf(out, " if (!_clname) return Q_NULLPTR;\n"); + fprintf(out, " if (!_clname) return nullptr;\n"); fprintf(out, " if (!strcmp(_clname, qt_meta_stringdata_%s.stringdata0))\n" " return static_cast<void*>(const_cast< %s*>(this));\n", qualifiedClassNameIdentifier.constData(), cdef->classname.constData()); @@ -584,7 +584,7 @@ void Generator::generateCode() QByteArray superClass = purestSuperClass; fprintf(out, " return %s::qt_metacast(_clname);\n", superClass.constData()); } else { - fprintf(out, " return Q_NULLPTR;\n"); + fprintf(out, " return nullptr;\n"); } fprintf(out, "}\n"); @@ -918,8 +918,6 @@ void Generator::generateMetacall() fprintf(out, " _id = %s::qt_metacall(_c, _id, _a);\n", superClass.constData()); } - fprintf(out, " if (_id < 0)\n return _id;\n"); - fprintf(out, " "); bool needElse = false; QVector<FunctionDef> methodList; @@ -927,6 +925,15 @@ void Generator::generateMetacall() methodList += cdef->slotList; methodList += cdef->methodList; + // If there are no methods or properties, we will return _id anyway, so + // don't emit this comparison -- it is unnecessary, and it makes coverity + // unhappy. + if (methodList.size() || cdef->propertyList.size()) { + fprintf(out, " if (_id < 0)\n return _id;\n"); + } + + fprintf(out, " "); + if (methodList.size()) { needElse = true; fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n"); @@ -1067,7 +1074,7 @@ void Generator::generateMetacall() fprintf(out, "\n#endif // QT_NO_PROPERTIES"); } - if (methodList.size() || cdef->signalList.size() || cdef->propertyList.size()) + if (methodList.size() || cdef->propertyList.size()) fprintf(out, "\n "); fprintf(out,"return _id;\n}\n"); } @@ -1481,7 +1488,7 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, "QPrivateSignal"); fprintf(out, ")%s\n{\n" - " QMetaObject::activate(%s, &staticMetaObject, %d, Q_NULLPTR);\n" + " QMetaObject::activate(%s, &staticMetaObject, %d, nullptr);\n" "}\n", constQualifier, thisPtr.constData(), index); return; } @@ -1511,7 +1518,7 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, " void *_a[] = { "); if (def->normalizedType == "void") { - fprintf(out, "Q_NULLPTR"); + fprintf(out, "nullptr"); } else { if (def->returnTypeIsVolatile) fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(&_t0))"); diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 6128d5490b..b30de66258 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -305,7 +305,7 @@ int runMoc(int argc, char **argv) const QStringList files = parser.positionalArguments(); if (files.count() > 1) { - error(qPrintable(QStringLiteral("Too many input files specified: '") + files.join(QStringLiteral("' '")) + QLatin1Char('\''))); + error(qPrintable(QLatin1String("Too many input files specified: '") + files.join(QLatin1String("' '")) + QLatin1Char('\''))); parser.showHelp(1); } else if (!files.isEmpty()) { filename = files.first(); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 03f022da69..e2987f1be4 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1294,7 +1294,12 @@ void Moc::parsePluginData(ClassDef *def) return; } QFile file(fi.canonicalFilePath()); - file.open(QFile::ReadOnly); + if (!file.open(QFile::ReadOnly)) { + QByteArray msg = "Plugin Metadata file " + lexem() + " could not be opened: " + + file.errorString().toUtf8(); + error(msg.constData()); + return; + } metaData = file.readAll(); } } diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 11bf8d7937..f5639ffe31 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -1005,22 +1005,20 @@ static void mergeStringLiterals(Symbols *_symbols) } } -QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo) +static QByteArray searchIncludePaths(const QList<Parser::IncludePath> &includepaths, + const QByteArray &include) { - // #### stringery QFileInfo fi; - if (!relativeTo.isEmpty()) - fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo.constData())).dir(), QString::fromLocal8Bit(include.constData())); - for (int j = 0; j < Preprocessor::includes.size() && !fi.exists(); ++j) { - const IncludePath &p = Preprocessor::includes.at(j); + for (int j = 0; j < includepaths.size() && !fi.exists(); ++j) { + const Parser::IncludePath &p = includepaths.at(j); if (p.isFrameworkPath) { const int slashPos = include.indexOf('/'); if (slashPos == -1) continue; fi.setFile(QString::fromLocal8Bit(p.path + '/' + include.left(slashPos) + ".framework/Headers/"), - QString::fromLocal8Bit(include.mid(slashPos + 1).constData())); + QString::fromLocal8Bit(include.mid(slashPos + 1))); } else { - fi.setFile(QString::fromLocal8Bit(p.path.constData()), QString::fromLocal8Bit(include.constData())); + fi.setFile(QString::fromLocal8Bit(p.path), QString::fromLocal8Bit(include)); } // try again, maybe there's a file later in the include paths with the same name // (186067) @@ -1035,6 +1033,21 @@ QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteAr return fi.canonicalFilePath().toLocal8Bit(); } +QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo) +{ + if (!relativeTo.isEmpty()) { + QFileInfo fi; + fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo)).dir(), QString::fromLocal8Bit(include)); + if (fi.exists() && !fi.isDir()) + return fi.canonicalFilePath().toLocal8Bit(); + } + + auto it = nonlocalIncludePathResolutionCache.find(include); + if (it == nonlocalIncludePathResolutionCache.end()) + it = nonlocalIncludePathResolutionCache.insert(include, searchIncludePaths(includes, include)); + return it.value(); +} + void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) { currentFilenames.push(filename); diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h index a7eb1a19e1..39f56d6e92 100644 --- a/src/tools/moc/preprocessor.h +++ b/src/tools/moc/preprocessor.h @@ -61,6 +61,7 @@ public: static bool preprocessOnly; QList<QByteArray> frameworks; QSet<QByteArray> preprocessedIncludes; + QHash<QByteArray, QByteArray> nonlocalIncludePathResolutionCache; Macros macros; QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo); Symbols preprocessed(const QByteArray &filename, QFile *device); diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index 26e7b086d9..efce778acf 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -103,9 +103,8 @@ static inline QString typeNameToXml(const char *typeName) static QString addFunction(const FunctionDef &mm, bool isSignal = false) { - QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n") - .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")) - .arg(QLatin1String(mm.name)); + QString xml = QString::asprintf(" <%s name=\"%s\">\n", + isSignal ? "signal" : "method", mm.name.constData()); // check the return type first int typeId = QMetaType::type(mm.normalizedType.constData()); @@ -156,9 +155,9 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) { const char *signature = QDBusMetaType::typeToSignature(types.at(j)); xml += QString::fromLatin1(" <arg %1type=\"%2\" direction=\"%3\"/>\n") - .arg(name) - .arg(QLatin1String(signature)) - .arg(isOutput ? QLatin1String("out") : QLatin1String("in")); + .arg(name, + QLatin1String(signature), + isOutput ? QLatin1String("out") : QLatin1String("in")); // do we need to describe this argument? if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) { @@ -220,9 +219,9 @@ static QString generateInterfaceXml(const ClassDef *mo) continue; retval += QString::fromLatin1(" <property name=\"%1\" type=\"%2\" access=\"%3\"") - .arg(QLatin1String(mp.name)) - .arg(QLatin1String(signature)) - .arg(QLatin1String(accessvalues[access])); + .arg(QLatin1String(mp.name), + QLatin1String(signature), + QLatin1String(accessvalues[access])); if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) { retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n") diff --git a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp new file mode 100644 index 0000000000..f5051e25fc --- /dev/null +++ b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2016 by Southwest Research Institute (R) +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qfile.h> +#include <qdebug.h> + +quint32 convertmantissa(qint32 i) +{ + quint32 m = i << 13; // Zero pad mantissa bits + quint32 e = 0; // Zero exponent + + while (!(m & 0x00800000)) { // While not normalized + e -= 0x00800000; // Decrement exponent (1<<23) + m <<= 1; // Shift mantissa + } + m &= ~0x00800000; // Clear leading 1 bit + e += 0x38800000; // Adjust bias ((127-14)<<23) + return m | e; // Return combined number +} + +// we first build these tables up and then print them out as a separate step in order +// to more closely map the implementation given in the paper. +quint32 basetable[512]; +quint32 shifttable[512]; + +#define PRINTHEX(a) "0x" + QByteArray::number(a,16).toUpper() + "U,\n" + +qint32 main(qint32 argc, char **argv) +{ + if (argc < 2) { + qWarning() << "Must provide output filename as argument."; + return -1; + } + + QFile fid(argv[1]); + if (!fid.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning() << "Abort: Failed to open/create file" << fid.fileName(); + return -1; + } + quint32 i; + + fid.write("/* This file was generated by gen_qfloat16_tables.cpp */\n\n"); + fid.write("#include <QtCore/qfloat16.h>\n\n"); + + fid.write("QT_BEGIN_NAMESPACE\n\n"); + + fid.write("const quint32 qfloat16::mantissatable[2048] = {\n"); + fid.write("0,\n"); + for (i = 1; i < 1024; i++) + fid.write(PRINTHEX(convertmantissa(i))); + for (i = 1024; i < 2048; i++) + fid.write(PRINTHEX(0x38000000U + ((i - 1024) << 13))); + fid.write("};\n\n"); + + fid.write("const quint32 qfloat16::exponenttable[64] = {\n"); + fid.write("0,\n"); + for (i = 1; i < 31; i++) + fid.write(PRINTHEX(i << 23)); + fid.write("0x47800000U,\n"); // 31 + fid.write("0x80000000U,\n"); // 32 + for (i = 33; i < 63; i++) + fid.write(PRINTHEX(0x80000000U + ((i - 32) << 23))); + fid.write("0xC7800000U,\n"); // 63 + fid.write("};\n\n"); + + fid.write("const quint32 qfloat16::offsettable[64] = {\n"); + fid.write("0,\n"); + for (i = 1; i < 32; i++) + fid.write("1024U,\n"); + fid.write("0,\n"); + for (i = 33; i < 64; i++) + fid.write("1024U,\n"); + fid.write("};\n\n"); + + qint32 e; + for (i = 0; i < 256; ++i) { + e = i - 127; + if (e < -24) { // Very small numbers map to zero + basetable[i | 0x000] = 0x0000; + basetable[i | 0x100] = 0x8000; + shifttable[i | 0x000] = 24; + shifttable[i | 0x100] = 24; + + } else if (e < -14) { // Small numbers map to denorms + basetable[i | 0x000] = (0x0400 >> (-e - 14)); + basetable[i | 0x100] = (0x0400 >> (-e - 14)) | 0x8000; + shifttable[i | 0x000] = -e - 1; + shifttable[i | 0x100] = -e - 1; + + } else if (e <= 15) { // Normal numbers just lose precision + basetable[i | 0x000] = ((e + 15) << 10); + basetable[i | 0x100] = ((e + 15) << 10) | 0x8000; + shifttable[i | 0x000] = 13; + shifttable[i | 0x100] = 13; + + } else if (e < 128) { // Large numbers map to Infinity + basetable[i | 0x000] = 0x7C00; + basetable[i | 0x100] = 0xFC00; + shifttable[i | 0x000] = 24; + shifttable[i | 0x100] = 24; + + } else { // Infinity and NaN's stay Infinity and NaN's + basetable[i | 0x000] = 0x7C00; + basetable[i | 0x100] = 0xFC00; + shifttable[i | 0x000] = 13; + shifttable[i | 0x100] = 13; + } + } + + fid.write("const quint32 qfloat16::basetable[512] = {\n"); + for (i = 0; i < 512; i++) + fid.write(PRINTHEX(basetable[i])); + + fid.write("};\n\n"); + + fid.write("const quint32 qfloat16::shifttable[512] = {\n"); + for (i = 0; i < 512; i++) + fid.write(PRINTHEX(shifttable[i])); + + fid.write("};\n\n"); + + fid.write("QT_END_NAMESPACE\n"); + fid.close(); + return 0; +} diff --git a/src/tools/qfloat16-tables/qfloat16-tables.pro b/src/tools/qfloat16-tables/qfloat16-tables.pro new file mode 100644 index 0000000000..a7d10ac197 --- /dev/null +++ b/src/tools/qfloat16-tables/qfloat16-tables.pro @@ -0,0 +1,9 @@ +option(host_build) + +CONFIG += force_bootstrap +SOURCES += gen_qfloat16_tables.cpp + +load(qt_tool) + +lib.CONFIG = dummy_install +INSTALLS = lib diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 423b566896..f749b90019 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -261,7 +261,8 @@ int runRcc(int argc, char *argv[]) } else { out.setFileName(outFilename); if (!out.open(mode)) { - const QString msg = QString::fromLatin1("Unable to open %1 for writing: %2\n").arg(outFilename).arg(out.errorString()); + const QString msg = QString::fromLatin1("Unable to open %1 for writing: %2\n") + .arg(outFilename, out.errorString()); errorDevice.write(msg.toUtf8()); return 1; } @@ -282,7 +283,7 @@ int runRcc(int argc, char *argv[]) temp.setFileName(tempFilename); if (!temp.open(QIODevice::ReadOnly)) { const QString msg = QString::fromUtf8("Unable to open temporary file %1 for reading: %2\n") - .arg(outFilename).arg(out.errorString()); + .arg(outFilename, out.errorString()); errorDevice.write(msg.toUtf8()); return 1; } diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index c8ac554cd4..24dc1092ef 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -73,7 +73,7 @@ void RCCResourceLibrary::writeByteArray(const QByteArray &other) static inline QString msgOpenReadFailed(const QString &fname, const QString &why) { - return QString::fromLatin1("Unable to open %1 for reading: %2\n").arg(fname).arg(why); + return QString::fromLatin1("Unable to open %1 for reading: %2\n").arg(fname, why); } @@ -499,7 +499,8 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QFileInfo file(absFileName); if (!file.exists()) { m_failedResources.push_back(absFileName); - const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n").arg(fname).arg(fileName); + const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n") + .arg(fname, fileName); m_errorDevice->write(msg.toUtf8()); if (ignoreErrors) continue; diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index a99d6adf07..dcbe400224 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -114,8 +114,9 @@ void WriteIncludes::acceptUI(DomUI *node) TreeWalker::acceptUI(node); - if (!m_uic->option().includeFile.isEmpty()) - m_globalIncludes.insert(m_uic->option().includeFile, true); + const auto includeFile = m_uic->option().includeFile; + if (!includeFile.isEmpty()) + m_globalIncludes.insert(includeFile); writeHeaders(m_globalIncludes, true); writeHeaders(m_localIncludes, false); @@ -272,10 +273,11 @@ void WriteIncludes::insertInclude(const QString &header, bool global) fprintf(stderr, "%s %s %d\n", Q_FUNC_INFO, qPrintable(header), global); OrderedSet &includes = global ? m_globalIncludes : m_localIncludes; - if (includes.contains(header)) + // Insert (if not already done). + const bool isNewHeader = includes.insert(header).second; + if (!isNewHeader) return; - // Insert. Also remember base name for quick check of suspicious custom plugins - includes.insert(header, false); + // Also remember base name for quick check of suspicious custom plugins const QString lowerBaseName = QFileInfo(header).completeBaseName ().toLower(); m_includeBaseNames.insert(lowerBaseName); } @@ -286,13 +288,11 @@ void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global) const QChar closingQuote = global ? QLatin1Char('>') : QLatin1Char('"'); // Check for the old headers 'qslider.h' and replace by 'QtGui/QSlider' - const OrderedSet::const_iterator cend = headers.constEnd(); - for (OrderedSet::const_iterator sit = headers.constBegin(); sit != cend; ++sit) { - const StringMap::const_iterator hit = m_oldHeaderToNewHeader.constFind(sit.key()); - const bool mapped = hit != m_oldHeaderToNewHeader.constEnd(); - const QString header = mapped ? hit.value() : sit.key(); - if (!QStringRef(&header).trimmed().isEmpty()) - m_output << "#include " << openingQuote << header << closingQuote << QLatin1Char('\n'); + for (const QString &header : headers) { + const QString value = m_oldHeaderToNewHeader.value(header, header); + const auto trimmed = QStringRef(&value).trimmed(); + if (!trimmed.isEmpty()) + m_output << "#include " << openingQuote << trimmed << closingQuote << QLatin1Char('\n'); } } diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h index 397c6a26e1..7a6a499536 100644 --- a/src/tools/uic/cpp/cppwriteincludes.h +++ b/src/tools/uic/cpp/cppwriteincludes.h @@ -35,6 +35,8 @@ #include <qset.h> #include <qstring.h> +#include <set> + QT_BEGIN_NAMESPACE class QTextStream; @@ -72,7 +74,7 @@ private: void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false); private: - typedef QMap<QString, bool> OrderedSet; + typedef std::set<QString> OrderedSet; void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false); void insertInclude(const QString &header, bool global); void writeHeaders(const OrderedSet &headers, bool global); diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 2fc6f20782..2b0d70eac6 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -152,7 +152,8 @@ namespace { if (const DomResourceIcon *dri = p->elementIconSet()) { if (!isIconFormat44(dri)) { if (dri->text().isEmpty()) { - const QString msg = QString::fromUtf8("%1: Warning: An invalid icon property '%2' was encountered.").arg(fileName).arg(p->attributeName()); + const QString msg = QString::fromLatin1("%1: Warning: An invalid icon property '%2' was encountered.") + .arg(fileName, p->attributeName()); qWarning("%s", qPrintable(msg)); return false; } @@ -162,7 +163,8 @@ namespace { case DomProperty::Pixmap: if (const DomResourcePixmap *drp = p->elementPixmap()) if (drp->text().isEmpty()) { - const QString msg = QString::fromUtf8("%1: Warning: An invalid pixmap property '%2' was encountered.").arg(fileName).arg(p->attributeName()); + const QString msg = QString::fromUtf8("%1: Warning: An invalid pixmap property '%2' was encountered.") + .arg(fileName, p->attributeName()); qWarning("%s", qPrintable(msg)); return false; } @@ -1029,7 +1031,7 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node) const int row = node->attributeRow(); const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1; const QString role = formLayoutRole(node->attributeColumn(), colSpan); - addArgs = QString::fromLatin1("%1, %2, %3").arg(row).arg(role).arg(itemName); + addArgs = QString::fromLatin1("%1, %2, %3").arg(row).arg(role, itemName); } else { addArgs = itemName; if (layout->attributeClass().contains(QLatin1String("Box")) && !node->attributeAlignment().isEmpty()) @@ -1365,7 +1367,7 @@ void WriteInitialization::writeProperties(const QString &varName, case DomProperty::Locale: { const DomLocale *locale = p->elementLocale(); propertyValue = QString::fromLatin1("QLocale(QLocale::%1, QLocale::%2)") - .arg(locale->attributeLanguage()).arg(locale->attributeCountry()); + .arg(locale->attributeLanguage(), locale->attributeCountry()); break; } case DomProperty::SizePolicy: { diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index e2399cd1fd..fca604690e 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -115,7 +115,7 @@ int runUic(int argc, char *argv[]) QString inputFile; if (!parser.positionalArguments().isEmpty()) - inputFile = parser.positionalArguments().first(); + inputFile = parser.positionalArguments().at(0); else // reading from stdin driver.option().headerProtection = false; |