aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/fdegen/fdegen.pro8
-rw-r--r--tools/fdegen/main.cpp362
-rw-r--r--tools/qml/main.cpp25
-rw-r--r--tools/qml/qml.pro2
-rw-r--r--tools/qmleasing/mainwindow.cpp1
-rw-r--r--tools/qmleasing/splineeditor.cpp17
-rw-r--r--tools/qmlimportscanner/main.cpp94
-rw-r--r--tools/qmljs/qmljs.cpp73
-rw-r--r--tools/qmlmin/main.cpp2
-rw-r--r--tools/qmlplugindump/main.cpp52
-rw-r--r--tools/qmlplugindump/qmlstreamwriter.cpp2
-rw-r--r--tools/qmlprofiler/commandlistener.h2
-rw-r--r--tools/qmlprofiler/main.cpp6
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp38
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.h11
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.cpp8
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.h11
-rw-r--r--tools/qmlscene/main.cpp25
-rw-r--r--tools/qmlscene/qmlscene.pro3
-rw-r--r--tools/tools.pro5
20 files changed, 222 insertions, 525 deletions
diff --git a/tools/fdegen/fdegen.pro b/tools/fdegen/fdegen.pro
deleted file mode 100644
index a52533280e..0000000000
--- a/tools/fdegen/fdegen.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = app
-TARGET = fdegen
-INCLUDEPATH += .
-
-# Input
-SOURCES += main.cpp
-
-LIBS += -ldwarf -lelf
diff --git a/tools/fdegen/main.cpp b/tools/fdegen/main.cpp
deleted file mode 100644
index 53ee9dec2a..0000000000
--- a/tools/fdegen/main.cpp
+++ /dev/null
@@ -1,362 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the V4VM module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <libdwarf.h>
-#include <dwarf.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#define DEBUG
-
-#ifdef DEBUG
-#include <libelf.h>
-#endif
-
-#include <qglobal.h>
-
-enum DwarfRegs {
-#if defined(Q_PROCESSOR_X86_64)
- // X86-64
- RAX = 0,
- RDX = 1,
- RCX = 2,
- RBX = 3,
- RSI = 4,
- RDI = 5,
- RBP = 6,
- RSP = 7,
- R8 = 8,
- R9 = 9,
- R10 = 10,
- R11 = 11,
- R12 = 12,
- R13 = 13,
- R14 = 14,
- R15 = 15,
- RIP = 16,
-
- InstructionPointerRegister = RIP,
- StackPointerRegister = RSP,
- StackFrameRegister = RBP
-#elif defined(Q_PROCESSOR_X86)
- // x86
- EAX = 0,
- EDX = 1,
- ECX = 2,
- EBX = 3,
- ESP = 4,
- EBP = 5,
- ESI = 6,
- EDI = 7,
- EIP = 8,
-
- InstructionPointerRegister = EIP,
- StackPointerRegister = ESP,
- StackFrameRegister = EBP
-#else
-#error Not ported yet
-#endif
-};
-
-static const DwarfRegs calleeSavedRegisters[] = {
-#if defined(Q_PROCESSOR_X86_64)
- R12,
- R14
-#elif defined(Q_PROCESSOR_X86)
- ESI,
- EDI
-#endif
-};
-static const int calleeSavedRegisterCount = sizeof(calleeSavedRegisters) / sizeof(calleeSavedRegisters[0]);
-
-#if QT_POINTER_SIZE == 8
-#define Elf_Ehdr Elf64_Ehdr
-#define elf_newehdr elf64_newehdr
-#define Elf_Shdr Elf64_Shdr
-#define elf_getshdr elf64_getshdr
-#else
-#define Elf_Ehdr Elf32_Ehdr
-#define elf_newehdr elf32_newehdr
-#define Elf_Shdr Elf32_Shdr
-#define elf_getshdr elf32_getshdr
-#endif
-
-static void die(const char *msg)
-{
- fprintf(stderr, "error: %s\n", msg);
- exit(1);
-}
-
-static int createSectionCallback(
- char *name,
- int size,
- Dwarf_Unsigned /*type*/,
- Dwarf_Unsigned /*flags*/,
- Dwarf_Unsigned /*link*/,
- Dwarf_Unsigned /*info*/,
- Dwarf_Unsigned* /*sect_name_index*/,
- void * /*user_data*/,
- int* /*error*/)
-{
- if (strcmp(name, ".debug_frame"))
- return 0;
- fprintf(stderr, "createsection called with %s and size %d\n", name, size);
- return 1;
-}
-
-static unsigned char cie_init_instructions[] = {
- DW_CFA_def_cfa, StackPointerRegister, /*offset in bytes */sizeof(void*),
- DW_CFA_offset | InstructionPointerRegister, 1,
-};
-
-int main()
-{
- Dwarf_Error error = 0;
- Dwarf_P_Debug dw = dwarf_producer_init_c(DW_DLC_WRITE | DW_DLC_SIZE_64,
- createSectionCallback,
- /* error handler */0,
- /* error arg */0,
- /* user data */0,
- &error);
- if (error != 0)
- die("dwarf_producer_init_c failed");
-
- Dwarf_Unsigned cie = dwarf_add_frame_cie(dw,
- "",
- /* code alignment factor */sizeof(void*),
- /* data alignment factor */-sizeof(void*),
- /* return address reg*/InstructionPointerRegister,
- cie_init_instructions,
- sizeof(cie_init_instructions),
- &error);
- if (error != 0)
- die("dwarf_add_frame_cie failed");
-
- Dwarf_P_Fde fde = dwarf_new_fde(dw, &error);
- if (error != 0)
- die("dwarf_new_fde failed");
-
- /* New entry in state machine for code offset 1 after push rbp instruction */
- dwarf_add_fde_inst(fde,
- DW_CFA_advance_loc,
- /*offset in code alignment units*/ 1,
- /* unused*/ 0,
- &error);
-
- /* After "push rbp" the offset to the CFA is now 2 instead of 1 */
- dwarf_add_fde_inst(fde,
- DW_CFA_def_cfa_offset_sf,
- /*offset in code alignment units*/ -2,
- /* unused*/ 0,
- &error);
-
- /* After "push rbp" the value of rbp is now stored at offset 1 from CFA */
- dwarf_add_fde_inst(fde,
- DW_CFA_offset,
- StackFrameRegister,
- 2,
- &error);
-
- /* New entry in state machine for code offset 3 for mov rbp, rsp instruction */
- dwarf_add_fde_inst(fde,
- DW_CFA_advance_loc,
- /*offset in code alignment units*/ 3,
- /* unused */ 0,
- &error);
-
- /* After "mov rbp, rsp" the cfa is reachable via rbp */
- dwarf_add_fde_inst(fde,
- DW_CFA_def_cfa_register,
- StackFrameRegister,
- /* unused */0,
- &error);
-
- /* Callee saved registers */
- for (int i = 0; i < calleeSavedRegisterCount; ++i) {
- dwarf_add_fde_inst(fde,
- DW_CFA_offset,
- calleeSavedRegisters[i],
- i + 3,
- &error);
- }
-
- dwarf_add_frame_fde(dw, fde,
- /* die */0,
- cie,
- /*virt addr */0,
- /* length of code */0,
- /* symbol index */0,
- &error);
- if (error != 0)
- die("dwarf_add_frame_fde failed");
-
- dwarf_transform_to_disk_form(dw, &error);
- if (error != 0)
- die("dwarf_transform_to_disk_form failed");
-
- Dwarf_Unsigned len = 0;
- Dwarf_Signed elfIdx = 0;
- unsigned char *bytes = (unsigned char *)dwarf_get_section_bytes(dw, /* section */1,
- &elfIdx, &len, &error);
- if (error != 0)
- die("dwarf_get_section_bytes failed");
-
- // libdwarf doesn't add a terminating FDE with zero length, so let's add one
- // ourselves.
- unsigned char *newBytes = (unsigned char *)alloca(len + 4);
- memcpy(newBytes, bytes, len);
- newBytes[len] = 0;
- newBytes[len + 1] = 0;
- newBytes[len + 2] = 0;
- newBytes[len + 3] = 0;
- newBytes[len + 4] = 0;
- bytes = newBytes;
- len += 4;
-
- // Reset CIE-ID back to 0 as expected for .eh_frames
- bytes[4] = 0;
- bytes[5] = 0;
- bytes[6] = 0;
- bytes[7] = 0;
-
- unsigned fde_offset = bytes[0] + 4;
-
- bytes[fde_offset + 4] = fde_offset + 4;
-
- printf("static const unsigned char cie_fde_data[] = {\n");
- int i = 0;
- while (i < len) {
- printf(" ");
- for (int j = 0; i < len && j < 8; ++j, ++i)
- printf("0x%x, ", bytes[i]);
- printf("\n");
- }
- printf("};\n");
-
- printf("static const int fde_offset = %d;\n", fde_offset);
- printf("static const int initial_location_offset = %d;\n", fde_offset + 8);
- printf("static const int address_range_offset = %d;\n", fde_offset + 8 + sizeof(void*));
-
-#ifdef DEBUG
- {
- if (elf_version(EV_CURRENT) == EV_NONE)
- die("wrong elf version");
- int fd = open("debug.o", O_WRONLY | O_CREAT, 0777);
- if (fd < 0)
- die("cannot create debug.o");
-
- Elf *e = elf_begin(fd, ELF_C_WRITE, 0);
- if (!e)
- die("elf_begin failed");
-
- Elf_Ehdr *ehdr = elf_newehdr(e);
- if (!ehdr)
- die(elf_errmsg(-1));
-
- ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
-#if defined(Q_PROCESSOR_X86_64)
- ehdr->e_machine = EM_X86_64;
-#elif defined(Q_PROCESSOR_X86)
- ehdr->e_machine = EM_386;
-#else
-#error port me :)
-#endif
- ehdr->e_type = ET_EXEC;
- ehdr->e_version = EV_CURRENT;
-
- Elf_Scn *section = elf_newscn(e);
- if (!section)
- die("elf_newscn failed");
-
- Elf_Data *data = elf_newdata(section);
- if (!data)
- die(elf_errmsg(-1));
- data->d_align = 4;
- data->d_off = 0;
- data->d_buf = bytes;
- data->d_size = len;
- data->d_type = ELF_T_BYTE;
- data->d_version = EV_CURRENT;
-
- Elf_Shdr *shdr = elf_getshdr(section);
- if (!shdr)
- die(elf_errmsg(-1));
-
- shdr->sh_name = 1;
- shdr->sh_type = SHT_PROGBITS;
- shdr->sh_entsize = 0;
-
- char stringTable[] = {
- 0,
- '.', 'e', 'h', '_', 'f', 'r', 'a', 'm', 'e', 0,
- '.', 's', 'h', 's', 't', 'r', 't', 'a', 'b', 0
- };
-
- section = elf_newscn(e);
- if (!section)
- die("elf_newscn failed");
-
- data = elf_newdata(section);
- if (!data)
- die(elf_errmsg(-1));
- data->d_align = 1;
- data->d_off = 0;
- data->d_buf = stringTable;
- data->d_size = sizeof(stringTable);
- data->d_type = ELF_T_BYTE;
- data->d_version = EV_CURRENT;
-
- shdr = elf_getshdr(section);
- if (!shdr)
- die(elf_errmsg(-1));
-
- shdr->sh_name = 11;
- shdr->sh_type = SHT_STRTAB;
- shdr->sh_flags = SHF_STRINGS | SHF_ALLOC;
- shdr->sh_entsize = 0;
-
- ehdr->e_shstrndx = elf_ndxscn(section);
-
- if (elf_update(e, ELF_C_WRITE) < 0)
- die(elf_errmsg(-1));
-
- elf_end(e);
- close(fd);
- }
-#endif
-
- dwarf_producer_finish(dw, &error);
- if (error != 0)
- die("dwarf_producer_finish failed");
- return 0;
-}
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index a795144984..be62500858 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -160,18 +160,23 @@ public:
LoadWatcher(QQmlApplicationEngine *e, int expected)
: QObject(e)
, earlyExit(false)
+ , returnCode(0)
, expect(expected)
, haveOne(false)
{
connect(e, SIGNAL(objectCreated(QObject*,QUrl)),
this, SLOT(checkFinished(QObject*)));
// QQmlApplicationEngine also connects quit() to QCoreApplication::quit
- // but if called before exec() then QCoreApplication::quit does nothing
+ // and exit() to QCoreApplication::exit but if called before exec()
+ // then QCoreApplication::quit or QCoreApplication::exit does nothing
connect(e, SIGNAL(quit()),
this, SLOT(quit()));
+ connect(e, &QQmlEngine::exit,
+ this, &LoadWatcher::exit);
}
bool earlyExit;
+ int returnCode;
private:
void contain(QObject *o, const QUrl &containPath);
@@ -187,7 +192,7 @@ public Q_SLOTS:
checkForWindow(o);
haveOne = true;
if (conf && qae)
- foreach (PartialScene *ps, conf->completers)
+ for (PartialScene *ps : qAsConst(conf->completers))
if (o->inherits(ps->itemType().toUtf8().constData()))
contain(o, ps->container());
}
@@ -196,14 +201,20 @@ public Q_SLOTS:
if (! --expect) {
printf("qml: Did not load any objects, exiting.\n");
- exit(2);//Different return code from qFatal
+ std::exit(2);//Different return code from qFatal
}
}
void quit() {
//Will be checked before calling exec()
earlyExit = true;
+ returnCode = 0;
}
+ void exit(int retCode) {
+ earlyExit = true;
+ returnCode = retCode;
+ }
+
#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL)
void onOpenGlContextCreated(QOpenGLContext *context);
#endif
@@ -402,8 +413,8 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory)
QObject *dummyData = comp.create();
if (comp.isError()) {
- QList<QQmlError> errors = comp.errors();
- foreach (const QQmlError &error, errors)
+ const QList<QQmlError> errors = comp.errors();
+ for (const QQmlError &error : errors)
qWarning() << error;
}
@@ -555,7 +566,7 @@ int main(int argc, char *argv[])
if (!dummyDir.isEmpty() && QFileInfo (dummyDir).isDir())
loadDummyDataFiles(e, dummyDir);
- foreach (const QString &path, files) {
+ for (const QString &path : qAsConst(files)) {
//QUrl::fromUserInput doesn't treat no scheme as relative file paths
#ifndef QT_NO_REGULAREXPRESSION
QRegularExpression urlRe("[[:word:]]+://.*");
@@ -582,7 +593,7 @@ int main(int argc, char *argv[])
}
if (lw->earlyExit)
- return 0;
+ return lw->returnCode;
return app->exec();
}
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index fe90916980..5f05054d04 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -12,6 +12,6 @@ mac {
ICON = qml.icns
}
-DEFINES += QT_QML_DEBUG_NO_WARNING
+!contains(QT_CONFIG, no-qml-debug): DEFINES += QT_QML_DEBUG_NO_WARNING
load(qt_tool)
diff --git a/tools/qmleasing/mainwindow.cpp b/tools/qmleasing/mainwindow.cpp
index e45feea76e..5a5f651396 100644
--- a/tools/qmleasing/mainwindow.cpp
+++ b/tools/qmleasing/mainwindow.cpp
@@ -29,7 +29,6 @@
#include "mainwindow.h"
#include "splineeditor.h"
#include <QtQuick/QQuickView>
-#include <QtQuick>
#include <QtQml/QQmlContext>
#include <QEasingCurve>
#include <QHBoxLayout>
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp
index 78ed9606db..6fee013c62 100644
--- a/tools/qmleasing/splineeditor.cpp
+++ b/tools/qmleasing/splineeditor.cpp
@@ -34,6 +34,7 @@
#include <QContextMenuEvent>
#include <QDebug>
#include <QApplication>
+#include <QVector>
const int canvasWidth = 640;
const int canvasHeight = 320;
@@ -287,7 +288,7 @@ QHash<QString, QEasingCurve> SplineEditor::presets() const
QString SplineEditor::generateCode()
{
QString s = QLatin1String("[");
- foreach (const QPointF &point, m_controlPoints) {
+ for (const QPointF &point : qAsConst(m_controlPoints)) {
s += QString::number(point.x(), 'g', 2) + QLatin1Char(',')
+ QString::number(point.y(), 'g', 3) + QLatin1Char(',');
}
@@ -672,25 +673,23 @@ void SplineEditor::setEasingCurve(const QString &code)
if (m_block)
return;
if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) {
- QString cleanCode = code;
- cleanCode.remove(0, 1);
- cleanCode.chop(1);
- const QStringList stringList = cleanCode.split(QLatin1Char(','), QString::SkipEmptyParts);
+ const QStringRef cleanCode(&code, 1, code.size() - 2);
+ const auto stringList = cleanCode.split(QLatin1Char(','), QString::SkipEmptyParts);
if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) {
- QList<qreal> realList;
+ QVector<qreal> realList;
realList.reserve(stringList.count());
- foreach (const QString &string, stringList) {
+ for (const QStringRef &string : stringList) {
bool ok;
realList.append(string.toDouble(&ok));
if (!ok)
return;
}
- QList<QPointF> points;
+ QVector<QPointF> points;
const int count = realList.count() / 2;
points.reserve(count);
for (int i = 0; i < count; ++i)
points.append(QPointF(realList.at(i * 2), realList.at(i * 2 + 1)));
- if (points.last() == QPointF(1.0, 1.0)) {
+ if (points.constLast() == QPointF(1.0, 1.0)) {
QEasingCurve easingCurve(QEasingCurve::BezierSpline);
for (int i = 0; i < points.count() / 3; ++i) {
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
index 2569d78c63..f7f5a5e4e4 100644
--- a/tools/qmlimportscanner/main.cpp
+++ b/tools/qmlimportscanner/main.cpp
@@ -55,6 +55,14 @@ QT_USE_NAMESPACE
QStringList g_qmlImportPaths;
+static inline QString typeLiteral() { return QStringLiteral("type"); }
+static inline QString versionLiteral() { return QStringLiteral("version"); }
+static inline QString nameLiteral() { return QStringLiteral("name"); }
+static inline QString pluginsLiteral() { return QStringLiteral("plugins"); }
+static inline QString pathLiteral() { return QStringLiteral("path"); }
+static inline QString classnamesLiteral() { return QStringLiteral("classnames"); }
+static inline QString dependenciesLiteral() { return QStringLiteral("dependencies"); }
+
static void printUsage(const QString &appNameIn)
{
const std::wstring appName = appNameIn.toStdWString();
@@ -84,14 +92,14 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con
// handle directory imports
if (!importNode->fileName.isEmpty()) {
QString name = importNode->fileName.toString();
- import[QStringLiteral("name")] = name;
+ import[nameLiteral()] = name;
if (name.endsWith(QLatin1String(".js"))) {
- import[QStringLiteral("type")] = QStringLiteral("javascript");
+ import[typeLiteral()] = QStringLiteral("javascript");
} else {
- import[QStringLiteral("type")] = QStringLiteral("directory");
+ import[typeLiteral()] = QStringLiteral("directory");
}
- import[QStringLiteral("path")] = QDir::cleanPath(path + QLatin1Char('/') + name);
+ import[pathLiteral()] = QDir::cleanPath(path + QLatin1Char('/') + name);
} else {
// Walk the id chain ("Foo" -> "Bar" -> etc)
QString name;
@@ -103,9 +111,9 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con
}
name.chop(1); // remove trailing "."
if (!name.isEmpty())
- import[QStringLiteral("name")] = name;
- import[QStringLiteral("type")] = QStringLiteral("module");
- import[QStringLiteral("version")] = code.mid(importNode->versionToken.offset, importNode->versionToken.length);
+ import[nameLiteral()] = name;
+ import[typeLiteral()] = QStringLiteral("module");
+ import[versionLiteral()] = code.mid(importNode->versionToken.offset, importNode->versionToken.length);
}
imports.append(import);
@@ -117,7 +125,7 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con
// Read the qmldir file, extract a list of plugins by
// parsing the "plugin" and "classname" lines.
QVariantMap pluginsForModulePath(const QString &modulePath) {
- QFile qmldirFile(modulePath + QStringLiteral("/qmldir"));
+ QFile qmldirFile(modulePath + QLatin1String("/qmldir"));
if (!qmldirFile.exists())
return QVariantMap();
@@ -141,16 +149,16 @@ QVariantMap pluginsForModulePath(const QString &modulePath) {
if (dep.length() != 3)
std::cerr << "depends: expected 2 arguments: module identifier and version" << std::endl;
else
- dependencies << QString::fromUtf8(dep[1]) + QStringLiteral(" ") + QString::fromUtf8(dep[2]).simplified();
+ dependencies << QString::fromUtf8(dep[1]) + QLatin1Char(' ') + QString::fromUtf8(dep[2]).simplified();
}
} while (line.length() > 0);
QVariantMap pluginInfo;
- pluginInfo[QStringLiteral("plugins")] = plugins.simplified();
- pluginInfo[QStringLiteral("classnames")] = classnames.simplified();
+ pluginInfo[pluginsLiteral()] = plugins.simplified();
+ pluginInfo[classnamesLiteral()] = classnames.simplified();
if (dependencies.length())
- pluginInfo[QStringLiteral("dependencies")] = dependencies;
+ pluginInfo[dependenciesLiteral()] = dependencies;
return pluginInfo;
}
@@ -163,7 +171,7 @@ QString resolveImportPath(const QString &uri, const QString &version)
QString ver = version;
while (true) {
- foreach (const QString &qmlImportPath, g_qmlImportPaths) {
+ for (const QString &qmlImportPath : qAsConst(g_qmlImportPaths)) {
// Search for the most specific version first, and search
// also for the version in parent modules. For example:
// - qml/QtQml/Models.2.0
@@ -210,25 +218,25 @@ QVariantList findPathsForModuleImports(const QVariantList &imports)
for (int i = 0; i < importsCopy.length(); ++i) {
QVariantMap import = qvariant_cast<QVariantMap>(importsCopy[i]);
- if (import[QStringLiteral("type")] == QLatin1String("module")) {
- QString path = resolveImportPath(import.value(QStringLiteral("name")).toString(), import.value(QStringLiteral("version")).toString());
+ if (import[typeLiteral()] == QLatin1String("module")) {
+ QString path = resolveImportPath(import.value(nameLiteral()).toString(), import.value(versionLiteral()).toString());
if (!path.isEmpty())
- import[QStringLiteral("path")] = path;
- QVariantMap plugininfo = pluginsForModulePath(import.value(QStringLiteral("path")).toString());
- QString plugins = plugininfo.value(QStringLiteral("plugins")).toString();
- QString classnames = plugininfo.value(QStringLiteral("classnames")).toString();
+ import[pathLiteral()] = path;
+ QVariantMap plugininfo = pluginsForModulePath(import.value(pathLiteral()).toString());
+ QString plugins = plugininfo.value(pluginsLiteral()).toString();
+ QString classnames = plugininfo.value(classnamesLiteral()).toString();
if (!plugins.isEmpty())
- import[QStringLiteral("plugin")] = plugins;
+ import.insert(QStringLiteral("plugin"), plugins);
if (!classnames.isEmpty())
- import[QStringLiteral("classname")] = classnames;
- if (plugininfo.contains(QStringLiteral("dependencies"))) {
- QStringList dependencies = plugininfo.value(QStringLiteral("dependencies")).toStringList();
- foreach (const QString &line, dependencies) {
- QList<QString> dep = line.split(QLatin1Char(' '));
+ import.insert(QStringLiteral("classname"), classnames);
+ if (plugininfo.contains(dependenciesLiteral())) {
+ const QStringList dependencies = plugininfo.value(dependenciesLiteral()).toStringList();
+ for (const QString &line : dependencies) {
+ const auto dep = line.splitRef(QLatin1Char(' '));
QVariantMap depImport;
- depImport[QStringLiteral("type")] = QStringLiteral("module");
- depImport[QStringLiteral("name")] = dep[0];
- depImport[QStringLiteral("version")] = dep[1];
+ depImport[typeLiteral()] = QStringLiteral("module");
+ depImport[nameLiteral()] = dep[0].toString();
+ depImport[versionLiteral()] = dep[1].toString();
importsCopy.append(depImport);
}
}
@@ -277,8 +285,8 @@ struct ImportCollector : public QQmlJS::Directives
virtual void importFile(const QString &jsfile, const QString &module, int line, int column)
{
QVariantMap entry;
- entry[QLatin1String("type")] = QStringLiteral("javascript");
- entry[QLatin1String("path")] = jsfile;
+ entry[typeLiteral()] = QStringLiteral("javascript");
+ entry[pathLiteral()] = jsfile;
imports << entry;
Q_UNUSED(module);
@@ -290,12 +298,12 @@ struct ImportCollector : public QQmlJS::Directives
{
QVariantMap entry;
if (uri.contains(QLatin1Char('/'))) {
- entry[QLatin1String("type")] = QStringLiteral("directory");
- entry[QLatin1String("name")] = uri;
+ entry[typeLiteral()] = QStringLiteral("directory");
+ entry[nameLiteral()] = uri;
} else {
- entry[QLatin1String("type")] = QStringLiteral("module");
- entry[QLatin1String("name")] = uri;
- entry[QLatin1String("version")] = version;
+ entry[typeLiteral()] = QStringLiteral("module");
+ entry[nameLiteral()] = uri;
+ entry[versionLiteral()] = version;
}
imports << entry;
@@ -354,7 +362,7 @@ QVariantList findQmlImportsInFile(const QString &filePath)
QVariantList mergeImports(const QVariantList &a, const QVariantList &b)
{
QVariantList merged = a;
- foreach (const QVariant &variant, b) {
+ for (const QVariant &variant : b) {
if (!merged.contains(variant))
merged.append(variant);
}
@@ -413,19 +421,19 @@ QVariantList findQmlImportsInDirectory(const QString &qmlDir)
continue;
}
- foreach (const QFileInfo &x, entries)
+ for (const QFileInfo &x : entries)
if (x.isFile())
ret = mergeImports(ret, findQmlImportsInFile(x.absoluteFilePath()));
}
return ret;
}
-QSet<QString> importModulePaths(QVariantList imports) {
+QSet<QString> importModulePaths(const QVariantList &imports) {
QSet<QString> ret;
- foreach (const QVariant &importVariant, imports) {
+ for (const QVariant &importVariant : imports) {
QVariantMap import = qvariant_cast<QVariantMap>(importVariant);
- QString path = import.value(QStringLiteral("path")).toString();
- QString type = import.value(QStringLiteral("type")).toString();
+ QString path = import.value(pathLiteral()).toString();
+ QString type = import.value(typeLiteral()).toString();
if (type == QLatin1String("module") && !path.isEmpty())
ret.insert(QDir(path).canonicalPath());
}
@@ -440,13 +448,13 @@ QVariantList findQmlImportsRecursively(const QStringList &qmlDirs, const QString
QVariantList ret;
// scan all app root qml directories for imports
- foreach (const QString &qmlDir, qmlDirs) {
+ for (const QString &qmlDir : qmlDirs) {
QVariantList imports = findQmlImportsInDirectory(qmlDir);
ret = mergeImports(ret, imports);
}
// scan app qml files for imports
- foreach (const QString &file, scanFiles) {
+ for (const QString &file : scanFiles) {
QVariantList imports = findQmlImportsInFile(file);
ret = mergeImports(ret, imports);
}
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index 68aa52ce91..4b63357363 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -32,8 +32,10 @@
#include "private/qv4errorobject_p.h"
#include "private/qv4globalobject_p.h"
#include "private/qv4codegen_p.h"
+#if QT_CONFIG(qml_interpreter)
#include "private/qv4isel_moth_p.h"
#include "private/qv4vme_moth_p.h"
+#endif
#include "private/qv4objectproto_p.h"
#include "private/qv4isel_p.h"
#include "private/qv4mm_p.h"
@@ -43,10 +45,14 @@
#ifdef V4_ENABLE_JIT
# include "private/qv4isel_masm_p.h"
+#else
+QT_REQUIRE_CONFIG(qml_interpreter);
#endif // V4_ENABLE_JIT
#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDateTime>
#include <private/qqmljsengine_p.h>
#include <private/qqmljslexer_p.h>
#include <private/qqmljsparser_p.h>
@@ -61,14 +67,14 @@ using namespace QV4;
struct Print: FunctionObject
{
struct Data : Heap::FunctionObject {
- Data(ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("print"))
+ void init(ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("print"));
}
};
V4_OBJECT(FunctionObject)
- static ReturnedValue call(const Managed *, CallData *callData)
+ static void call(const Managed *, Scope &scope, CallData *callData)
{
for (int i = 0; i < callData->argc; ++i) {
QString s = callData->args[i].toQStringNoThrow();
@@ -77,7 +83,7 @@ struct Print: FunctionObject
std::cout << qPrintable(s);
}
std::cout << std::endl;
- return Encode::undefined();
+ scope.result = Encode::undefined();
}
};
@@ -86,18 +92,18 @@ DEFINE_OBJECT_VTABLE(Print);
struct GC: public FunctionObject
{
struct Data : Heap::FunctionObject {
- Data(ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("gc"))
+ void init(ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("gc"));
}
};
V4_OBJECT(FunctionObject)
- static ReturnedValue call(const Managed *m, CallData *)
+ static void call(const Managed *m, Scope &scope, CallData *)
{
static_cast<const GC *>(m)->engine()->memoryManager->runGC();
- return Encode::undefined();
+ scope.result = Encode::undefined();
}
};
@@ -118,7 +124,7 @@ static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exceptio
std::cerr << "Uncaught exception: " << qPrintable(message->toQStringNoThrow()) << std::endl;
}
- foreach (const QV4::StackFrame &frame, trace) {
+ for (const QV4::StackFrame &frame : trace) {
std::cerr << " at " << qPrintable(frame.function) << " (" << qPrintable(frame.source);
if (frame.line >= 0)
std::cerr << ':' << frame.line;
@@ -143,6 +149,7 @@ int main(int argc, char *argv[])
#endif
bool runAsQml = false;
+ bool cache = false;
if (!args.isEmpty()) {
if (args.first() == QLatin1String("--jit")) {
@@ -150,16 +157,23 @@ int main(int argc, char *argv[])
args.removeFirst();
}
+#if QT_CONFIG(qml_interpreter)
if (args.first() == QLatin1String("--interpret")) {
mode = use_moth;
args.removeFirst();
}
+#endif
if (args.first() == QLatin1String("--qml")) {
runAsQml = true;
args.removeFirst();
}
+ if (args.first() == QLatin1String("--cache")) {
+ cache = true;
+ args.removeFirst();
+ }
+
if (args.first() == QLatin1String("--help")) {
std::cerr << "Usage: qmljs [|--jit|--interpret|--qml] file..." << std::endl;
return EXIT_SUCCESS;
@@ -171,7 +185,9 @@ int main(int argc, char *argv[])
case use_moth: {
QV4::EvalISelFactory* iSelFactory = 0;
if (mode == use_moth) {
+#if QT_CONFIG(qml_interpreter)
iSelFactory = new QV4::Moth::ISelFactory;
+#endif
#ifdef V4_ENABLE_JIT
} else {
iSelFactory = new QV4::JIT::ISelFactory;
@@ -188,18 +204,41 @@ int main(int argc, char *argv[])
QV4::ScopedObject gc(scope, vm.memoryManager->allocObject<builtins::GC>(ctx));
vm.globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc);
- foreach (const QString &fn, args) {
+ for (const QString &fn : qAsConst(args)) {
QFile file(fn);
if (file.open(QFile::ReadOnly)) {
- const QString code = QString::fromUtf8(file.readAll());
- file.close();
+ QScopedPointer<QV4::Script> script;
+ if (cache && QFile::exists(fn + QLatin1Char('c'))) {
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = iSelFactory->createUnitForLoading();
+ QString error;
+ if (unit->loadFromDisk(QUrl::fromLocalFile(fn), iSelFactory, &error)) {
+ script.reset(new QV4::Script(&vm, nullptr, unit));
+ } else {
+ std::cout << "Error loading" << qPrintable(fn) << "from disk cache:" << qPrintable(error) << std::endl;
+ }
+ }
+ if (!script) {
+ const QString code = QString::fromUtf8(file.readAll());
+ file.close();
+ script.reset(new QV4::Script(ctx, code, fn));
+ script->parseAsBinding = runAsQml;
+ script->parse();
+ }
QV4::ScopedValue result(scope);
- QV4::Script script(ctx, code, fn);
- script.parseAsBinding = runAsQml;
- script.parse();
- if (!scope.engine->hasException)
- result = script.run();
+ if (!scope.engine->hasException) {
+ const auto unit = script->compilationUnit;
+ if (cache && unit && !(unit->data->flags & QV4::CompiledData::Unit::StaticData)) {
+ if (unit->data->sourceTimeStamp == 0) {
+ const_cast<QV4::CompiledData::Unit*>(unit->data)->sourceTimeStamp = QFileInfo(fn).lastModified().toMSecsSinceEpoch();
+ }
+ QString saveError;
+ if (!unit->saveToDisk(QUrl::fromLocalFile(fn), &saveError)) {
+ std::cout << "Error saving JS cache file: " << qPrintable(saveError) << std::endl;
+ }
+ }
+ result = script->run();
+ }
if (scope.engine->hasException) {
QV4::StackTrace trace;
QV4::ScopedValue ex(scope, scope.engine->catchException(&trace));
diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp
index 2b18a8442b..d2bad9d0d5 100644
--- a/tools/qmlmin/main.cpp
+++ b/tools/qmlmin/main.cpp
@@ -120,7 +120,7 @@ protected:
static QString quote(const QString &string)
{
QString quotedString;
- foreach (const QChar &ch, string) {
+ for (const QChar &ch : string) {
if (ch == QLatin1Char('"'))
quotedString += QLatin1String("\\\"");
else {
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 5a39e497d2..ea54fee885 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -76,7 +76,7 @@
static const uint qtQmlMajorVersion = 2;
static const uint qtQmlMinorVersion = 2;
static const uint qtQuickMajorVersion = 2;
-static const uint qtQuickMinorVersion = 7;
+static const uint qtQuickMinorVersion = 8;
const QString qtQuickQualifiedName = QString::fromLatin1("QtQuick %1.%2")
.arg(qtQuickMajorVersion)
@@ -248,15 +248,15 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine,
QSet<const QQmlType *> baseExports = qmlTypesByCppName.value(it.key());
const QSet<QByteArray> extensionCppNames = it.value();
- foreach (const QByteArray &extensionCppName, extensionCppNames) {
+ for (const QByteArray &extensionCppName : extensionCppNames) {
const QSet<const QQmlType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
// remove extension exports from base imports
// unfortunately the QQmlType pointers don't match, so can't use QSet::subtract
QSet<const QQmlType *> newBaseExports;
- foreach (const QQmlType *baseExport, baseExports) {
+ for (const QQmlType *baseExport : qAsConst(baseExports)) {
bool match = false;
- foreach (const QQmlType *extensionExport, extensionExports) {
+ for (const QQmlType *extensionExport : extensionExports) {
if (baseExport->qmlTypeName() == extensionExport->qmlTypeName()
&& baseExport->majorVersion() == extensionExport->majorVersion()
&& baseExport->minorVersion() == extensionExport->minorVersion()) {
@@ -469,7 +469,7 @@ public:
void dumpComposite(QQmlEngine *engine, const QSet<const QQmlType *> &compositeType, QSet<QByteArray> &defaultReachableNames)
{
- foreach (const QQmlType *type, compositeType)
+ for (const QQmlType *type : compositeType)
dumpCompositeItem(engine, type, defaultReachableNames);
}
@@ -518,7 +518,7 @@ public:
}
}
- foreach (const QMetaObject *meta, objectsToMerge)
+ for (const QMetaObject *meta : qAsConst(objectsToMerge))
writeMetaContent(meta, &knownAttributes);
qml->writeEndObject();
@@ -542,11 +542,11 @@ public:
if (meta->superClass())
qml->writeScriptBinding(QLatin1String("prototype"), enquote(convertToId(meta->superClass())));
- QSet<const QQmlType *> qmlTypes = qmlTypesByCppName.value(meta->className());
+ const QSet<const QQmlType *> qmlTypes = qmlTypesByCppName.value(meta->className());
if (!qmlTypes.isEmpty()) {
QHash<QString, const QQmlType *> exports;
- foreach (const QQmlType *qmlTy, qmlTypes) {
+ for (const QQmlType *qmlTy : qmlTypes) {
const QString exportString = getExportString(qmlTy->qmlTypeName(), qmlTy->majorVersion(), qmlTy->minorVersion());
exports.insert(exportString, qmlTy);
}
@@ -564,7 +564,7 @@ public:
// write meta object revisions
QStringList metaObjectRevisions;
- foreach (const QString &exportString, exportStrings) {
+ for (const QString &exportString : qAsConst(exportStrings)) {
int metaObjectRevision = exports[exportString]->metaObjectRevision();
metaObjectRevisions += QString::number(metaObjectRevision);
}
@@ -749,7 +749,7 @@ static bool readDependenciesData(QString dependenciesFile, const QByteArray &fil
if (verbose) {
std::cerr << "parsing "
<< qPrintable( dependenciesFile ) << " skipping";
- foreach (const QString &uriToSkip, urisToSkip)
+ for (const QString &uriToSkip : urisToSkip)
std::cerr << ' ' << qPrintable(uriToSkip);
std::cerr << std::endl;
}
@@ -763,13 +763,13 @@ static bool readDependenciesData(QString dependenciesFile, const QByteArray &fil
return false;
}
if (doc.isArray()) {
- QStringList requiredKeys = QStringList() << QStringLiteral("name")
- << QStringLiteral("type")
- << QStringLiteral("version");
+ const QStringList requiredKeys = QStringList() << QStringLiteral("name")
+ << QStringLiteral("type")
+ << QStringLiteral("version");
foreach (const QJsonValue &dep, doc.array()) {
if (dep.isObject()) {
QJsonObject obj = dep.toObject();
- foreach (const QString &requiredKey, requiredKeys)
+ for (const QString &requiredKey : requiredKeys)
if (!obj.contains(requiredKey) || obj.value(requiredKey).isString())
continue;
if (obj.value(QStringLiteral("type")).toString() != QLatin1String("module"))
@@ -850,7 +850,7 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
if (!importScanner.waitForFinished()) {
std::cerr << "failure to start " << qPrintable(command);
- foreach (const QString &arg, commandArgs)
+ for (const QString &arg : qAsConst(commandArgs))
std::cerr << ' ' << qPrintable(arg);
std::cerr << std::endl;
return false;
@@ -863,7 +863,7 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
}
QStringList aux;
- foreach (const QString &str, *dependencies) {
+ for (const QString &str : qAsConst(*dependencies)) {
if (!str.startsWith("Qt.test.qtestroot"))
aux += str;
}
@@ -977,7 +977,7 @@ int main(int argc, char *argv[])
}
}
- if (!requireWindowManager)
+ if (!requireWindowManager && qEnvironmentVariableIsEmpty("QT_QPA_PLATFORM"))
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("minimal"));
else
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
@@ -1124,7 +1124,7 @@ int main(int argc, char *argv[])
// load the QtQml builtins and the dependencies
{
QByteArray code(qtQmlImportString.toUtf8());
- foreach (const QString &moduleToImport, dependencies) {
+ for (const QString &moduleToImport : qAsConst(dependencies)) {
code.append("\nimport ");
code.append(moduleToImport.toUtf8());
}
@@ -1154,7 +1154,7 @@ int main(int argc, char *argv[])
QSet<const QMetaObject *> metas;
if (action == Builtins) {
- foreach (const QMetaObject *m, defaultReachable) {
+ for (const QMetaObject *m : qAsConst(defaultReachable)) {
if (m->className() == QLatin1String("Qt")) {
metas.insert(m);
break;
@@ -1175,7 +1175,7 @@ int main(int argc, char *argv[])
return EXIT_INVALIDARGUMENTS;
}
metas = defaultReachable;
- foreach (const QMetaObject *m, defaultReachable) {
+ for (const QMetaObject *m : qAsConst(defaultReachable)) {
if (m->className() == QLatin1String("Qt")) {
metas.remove(m);
break;
@@ -1196,7 +1196,7 @@ int main(int argc, char *argv[])
QString::number(qtObjectType->minorVersion())).toUtf8();
}
// avoid importing dependencies?
- foreach (const QString &moduleToImport, dependencies) {
+ for (const QString &moduleToImport : qAsConst(dependencies)) {
importCode.append("\nimport ");
importCode.append(moduleToImport.toUtf8());
}
@@ -1231,9 +1231,9 @@ int main(int argc, char *argv[])
// Also eliminate meta objects with the same classname.
// This is required because extended objects seem not to share
// a single meta object instance.
- foreach (const QMetaObject *mo, defaultReachable)
+ for (const QMetaObject *mo : qAsConst(defaultReachable))
defaultReachableNames.insert(QByteArray(mo->className()));
- foreach (const QMetaObject *mo, candidates) {
+ for (const QMetaObject *mo : qAsConst(candidates)) {
if (!defaultReachableNames.contains(mo->className()))
metas.insert(mo);
}
@@ -1265,19 +1265,19 @@ int main(int argc, char *argv[])
compactDependencies(&dependencies);
QStringList quotedDependencies;
- foreach (const QString &dep, dependencies)
+ for (const QString &dep : qAsConst(dependencies))
quotedDependencies << enquote(dep);
qml.writeArrayBinding("dependencies", quotedDependencies);
// put the metaobjects into a map so they are always dumped in the same order
QMap<QString, const QMetaObject *> nameToMeta;
- foreach (const QMetaObject *meta, metas)
+ for (const QMetaObject *meta : qAsConst(metas))
nameToMeta.insert(convertToId(meta), meta);
Dumper dumper(&qml);
if (relocatable)
dumper.setRelocatableModuleUri(pluginImportUri);
- foreach (const QMetaObject *meta, nameToMeta) {
+ for (const QMetaObject *meta : qAsConst(nameToMeta)) {
dumper.dump(QQmlEnginePrivate::get(&engine), meta, uncreatableMetas.contains(meta), singletonMetas.contains(meta));
}
diff --git a/tools/qmlplugindump/qmlstreamwriter.cpp b/tools/qmlplugindump/qmlstreamwriter.cpp
index dd3c188fe4..3632cee60d 100644
--- a/tools/qmlplugindump/qmlstreamwriter.cpp
+++ b/tools/qmlplugindump/qmlstreamwriter.cpp
@@ -179,7 +179,7 @@ void QmlStreamWriter::flushPotentialLinesWithNewlines()
{
if (m_maybeOneline)
m_stream->write("\n");
- foreach (const QByteArray &line, m_pendingLines) {
+ for (const QByteArray &line : qAsConst(m_pendingLines)) {
writeIndent();
m_stream->write(line);
m_stream->write("\n");
diff --git a/tools/qmlprofiler/commandlistener.h b/tools/qmlprofiler/commandlistener.h
index c10b199daa..2a994bf449 100644
--- a/tools/qmlprofiler/commandlistener.h
+++ b/tools/qmlprofiler/commandlistener.h
@@ -33,7 +33,7 @@
class CommandListener : public QObject {
Q_OBJECT
-public slots:
+public:
void readCommand();
signals:
diff --git a/tools/qmlprofiler/main.cpp b/tools/qmlprofiler/main.cpp
index d3e2beb83f..c7cb979ff8 100644
--- a/tools/qmlprofiler/main.cpp
+++ b/tools/qmlprofiler/main.cpp
@@ -39,8 +39,10 @@ int main(int argc, char *argv[])
QThread listenerThread;
CommandListener listener;
listener.moveToThread(&listenerThread);
- QObject::connect(&listener, SIGNAL(command(QString)), &app, SLOT(userCommand(QString)));
- QObject::connect(&app, SIGNAL(readyForCommand()), &listener, SLOT(readCommand()));
+ QObject::connect(&listener, &CommandListener::command,
+ &app, &QmlProfilerApplication::userCommand);
+ QObject::connect(&app, &QmlProfilerApplication::readyForCommand,
+ &listener, &CommandListener::readCommand);
listenerThread.start();
int exitValue = app.exec();
listenerThread.quit();
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index b04ff7e558..033492b516 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -87,17 +87,21 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
m_connectionAttempts(0)
{
m_connectTimer.setInterval(1000);
- connect(&m_connectTimer, SIGNAL(timeout()), this, SLOT(tryToConnect()));
+ connect(&m_connectTimer, &QTimer::timeout, this, &QmlProfilerApplication::tryToConnect);
- connect(&m_connection, SIGNAL(connected()), this, SLOT(connected()));
+ connect(&m_connection, &QQmlDebugConnection::connected,
+ this, &QmlProfilerApplication::connected);
- connect(&m_qmlProfilerClient, SIGNAL(enabledChanged(bool)),
- this, SLOT(traceClientEnabledChanged(bool)));
- connect(&m_qmlProfilerClient, SIGNAL(recordingStarted()), this, SLOT(notifyTraceStarted()));
- connect(&m_qmlProfilerClient, SIGNAL(error(QString)), this, SLOT(logError(QString)));
+ connect(&m_qmlProfilerClient, &QmlProfilerClient::enabledChanged,
+ this, &QmlProfilerApplication::traceClientEnabledChanged);
+ connect(&m_qmlProfilerClient, &QmlProfilerClient::recordingStarted,
+ this, &QmlProfilerApplication::notifyTraceStarted);
+ connect(&m_qmlProfilerClient, &QmlProfilerClient::error,
+ this, &QmlProfilerApplication::logError);
- connect(&m_profilerData, SIGNAL(error(QString)), this, SLOT(logError(QString)));
- connect(&m_profilerData, SIGNAL(dataReady()), this, SLOT(traceFinished()));
+ connect(&m_profilerData, &QmlProfilerData::error, this, &QmlProfilerApplication::logError);
+ connect(&m_profilerData, &QmlProfilerData::dataReady,
+ this, &QmlProfilerApplication::traceFinished);
}
@@ -257,7 +261,7 @@ void QmlProfilerApplication::parseArguments()
int QmlProfilerApplication::exec()
{
- QTimer::singleShot(0, this, SLOT(run()));
+ QTimer::singleShot(0, this, &QmlProfilerApplication::run);
return QCoreApplication::exec();
}
@@ -270,8 +274,8 @@ quint64 QmlProfilerApplication::parseFeatures(const QStringList &featureList, co
bool exclude)
{
quint64 features = exclude ? std::numeric_limits<quint64>::max() : 0;
- QStringList givenFeatures = values.split(QLatin1Char(','));
- foreach (const QString &f, givenFeatures) {
+ const QStringList givenFeatures = values.split(QLatin1Char(','));
+ for (const QString &f : givenFeatures) {
int index = featureList.indexOf(f);
if (index < 0) {
logError(tr("Unknown feature '%1'").arg(f));
@@ -343,7 +347,7 @@ bool QmlProfilerApplication::checkOutputFile(PendingRequest pending)
void QmlProfilerApplication::userCommand(const QString &command)
{
- QStringList args = command.split(QChar::Space, QString::SkipEmptyParts);
+ auto args = command.splitRef(QChar::Space, QString::SkipEmptyParts);
if (args.isEmpty()) {
prompt();
return;
@@ -397,7 +401,7 @@ void QmlProfilerApplication::userCommand(const QString &command)
} else if (m_profilerData.isEmpty()) {
prompt(tr("No data was recorded so far."));
} else {
- m_interactiveOutputFile = args.length() > 0 ? args[0] : m_outputFile;
+ m_interactiveOutputFile = args.length() > 0 ? args.at(0).toString() : m_outputFile;
if (checkOutputFile(REQUEST_OUTPUT_FILE))
output();
}
@@ -414,7 +418,7 @@ void QmlProfilerApplication::userCommand(const QString &command)
if (!m_recording && m_profilerData.isEmpty()) {
prompt(tr("No data was recorded so far."));
} else {
- m_interactiveOutputFile = args.length() > 0 ? args[0] : m_outputFile;
+ m_interactiveOutputFile = args.length() > 0 ? args.at(0).toString() : m_outputFile;
if (checkOutputFile(REQUEST_FLUSH_FILE))
flush();
}
@@ -460,9 +464,9 @@ void QmlProfilerApplication::run()
arguments << m_programArguments;
m_process->setProcessChannelMode(QProcess::MergedChannels);
- connect(m_process, SIGNAL(readyRead()), this, SLOT(processHasOutput()));
- connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this,
- SLOT(processFinished()));
+ connect(m_process, &QIODevice::readyRead, this, &QmlProfilerApplication::processHasOutput);
+ connect(m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
+ this, [this](int){ processFinished(); });
logStatus(QString("Starting '%1 %2' ...").arg(m_programPath,
arguments.join(QLatin1Char(' '))));
m_process->start(m_programPath, arguments);
diff --git a/tools/qmlprofiler/qmlprofilerapplication.h b/tools/qmlprofiler/qmlprofilerapplication.h
index 04f9d43c87..13f0f041f0 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.h
+++ b/tools/qmlprofiler/qmlprofilerapplication.h
@@ -58,16 +58,14 @@ public:
void parseArguments();
int exec();
bool isInteractive() const;
-
-signals:
- void readyForCommand();
-
-public slots:
void userCommand(const QString &command);
void notifyTraceStarted();
void outputData();
-private slots:
+signals:
+ void readyForCommand();
+
+private:
void run();
void tryToConnect();
void connected();
@@ -81,7 +79,6 @@ private slots:
void logError(const QString &error);
void logStatus(const QString &status);
-private:
quint64 parseFeatures(const QStringList &featureList, const QString &values, bool exclude);
bool checkOutputFile(PendingRequest pending);
void flush();
diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp
index 74fa44c1d6..048c92bb93 100644
--- a/tools/qmlprofiler/qmlprofilerdata.cpp
+++ b/tools/qmlprofiler/qmlprofilerdata.cpp
@@ -248,7 +248,7 @@ void QmlProfilerData::addQmlEvent(QQmlProfilerDefinitions::RangeType type,
eventHashStr = getHashStringForQmlEvent(eventLocation, type);
} else {
const QString filePath = QUrl(eventLocation.filename).path();
- displayName = filePath.mid(
+ displayName = filePath.midRef(
filePath.lastIndexOf(QLatin1Char('/')) + 1) +
QLatin1Char(':') + QString::number(eventLocation.line);
eventHashStr = getHashStringForQmlEvent(eventLocation, type);
@@ -327,8 +327,8 @@ void QmlProfilerData::addPixmapCacheEvent(QQmlProfilerDefinitions::PixmapEventTy
QString filePath = QUrl(location).path();
- QString eventHashStr = filePath.mid(filePath.lastIndexOf(QLatin1Char('/')) + 1) +
- QStringLiteral(":") + QString::number(type);
+ const QString eventHashStr = filePath.midRef(filePath.lastIndexOf(QLatin1Char('/')) + 1)
+ + QLatin1Char(':') + QString::number(type);
QmlRangeEventData *newEvent;
if (d->eventDescriptions.contains(eventHashStr)) {
newEvent = d->eventDescriptions[eventHashStr];
@@ -572,7 +572,7 @@ bool QmlProfilerData::save(const QString &filename)
stream.writeEndElement(); // eventData
stream.writeStartElement(QStringLiteral("profilerDataModel"));
- foreach (const QmlRangeEventStartInstance &event, d->startInstanceList) {
+ for (const QmlRangeEventStartInstance &event : qAsConst(d->startInstanceList)) {
stream.writeStartElement(QStringLiteral("range"));
stream.writeAttribute(QStringLiteral("startTime"), QString::number(event.startTime));
if (event.duration >= 0)
diff --git a/tools/qmlprofiler/qmlprofilerdata.h b/tools/qmlprofiler/qmlprofilerdata.h
index 2570513d93..00ef037071 100644
--- a/tools/qmlprofiler/qmlprofilerdata.h
+++ b/tools/qmlprofiler/qmlprofilerdata.h
@@ -58,12 +58,6 @@ public:
bool isEmpty() const;
-signals:
- void error(QString);
- void stateChanged();
- void dataReady();
-
-public slots:
void clear();
void setTraceEndTime(qint64 time);
void setTraceStartTime(qint64 time);
@@ -83,6 +77,11 @@ public slots:
void complete();
bool save(const QString &filename);
+signals:
+ void error(QString);
+ void stateChanged();
+ void dataReady();
+
private:
void sortStartTimes();
void computeQmlTime();
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index c892f60680..9e1002166d 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -175,10 +175,10 @@ QFileInfoList findQmlFiles(const QString &dirName)
QFileInfoList ret;
if (dir.exists()) {
- QFileInfoList fileInfos = dir.entryInfoList(QStringList() << "*.qml",
- QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot);
+ const QFileInfoList fileInfos = dir.entryInfoList(QStringList() << "*.qml",
+ QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot);
- foreach (QFileInfo fileInfo, fileInfos) {
+ for (const QFileInfo &fileInfo : fileInfos) {
if (fileInfo.isDir())
ret += findQmlFiles(fileInfo.filePath());
else if (fileInfo.fileName().length() > 0 && fileInfo.fileName().at(0).isLower())
@@ -196,9 +196,9 @@ static int displayOptionsDialog(Options *options)
QFormLayout *layout = new QFormLayout(&dialog);
QComboBox *qmlFileComboBox = new QComboBox(&dialog);
- QFileInfoList fileInfos = findQmlFiles(":/bundle") + findQmlFiles("./qmlscene-resources");
+ const QFileInfoList fileInfos = findQmlFiles(":/bundle") + findQmlFiles("./qmlscene-resources");
- foreach (QFileInfo fileInfo, fileInfos)
+ for (const QFileInfo &fileInfo : fileInfos)
qmlFileComboBox->addItem(fileInfo.dir().dirName() + QLatin1Char('/') + fileInfo.fileName(), QVariant::fromValue(fileInfo));
QCheckBox *originalCheckBox = new QCheckBox(&dialog);
@@ -319,8 +319,8 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory)
QObject *dummyData = comp.create();
if(comp.isError()) {
- QList<QQmlError> errors = comp.errors();
- foreach (const QQmlError &error, errors)
+ const QList<QQmlError> errors = comp.errors();
+ for (const QQmlError &error : errors)
fprintf(stderr, "%s\n", qPrintable(error.toString()));
}
@@ -361,7 +361,7 @@ static void usage()
puts(" ");
exit(1);
}
-
+#ifndef QT_NO_OPENGL
// Listen on GL context creation of the QQuickWindow in order to print diagnostic output.
class DiagnosticGlContextCreationListener : public QObject {
Q_OBJECT
@@ -389,7 +389,9 @@ private slots:
context->doneCurrent();
deleteLater();
}
+
};
+#endif
static void setWindowTitle(bool verbose, const QObject *topLevel, QWindow *window)
{
@@ -403,8 +405,10 @@ static void setWindowTitle(bool verbose, const QObject *topLevel, QWindow *windo
if (verbose) {
newTitle += QLatin1String(" [Qt ") + QLatin1String(QT_VERSION_STR) + QLatin1Char(' ')
+ QGuiApplication::platformName() + QLatin1Char(' ');
+#ifndef QT_NO_OPENGL
newTitle += QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
? QLatin1String("GL") : QLatin1String("GLES");
+#endif
newTitle += QLatin1Char(']');
}
if (oldTitle != newTitle)
@@ -453,7 +457,7 @@ int main(int argc, char ** argv)
options.applicationAttributes.append(Qt::AA_DisableHighDpiScaling);
}
- foreach (Qt::ApplicationAttribute a, options.applicationAttributes)
+ for (Qt::ApplicationAttribute a : qAsConst(options.applicationAttributes))
QCoreApplication::setAttribute(a);
#ifdef QT_WIDGETS_LIB
QApplication app(argc, argv);
@@ -560,6 +564,7 @@ int main(int argc, char ** argv)
loadDummyDataFiles(engine, fi.path());
}
QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
+ QObject::connect(&engine, &QQmlEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit);
component->loadUrl(options.url);
while (component->isLoading())
QCoreApplication::processEvents();
@@ -592,8 +597,10 @@ int main(int argc, char ** argv)
if (window) {
setWindowTitle(options.verbose, topLevel, window.data());
+#ifndef QT_NO_OPENGL
if (options.verbose)
new DiagnosticGlContextCreationListener(window.data());
+#endif
QSurfaceFormat surfaceFormat = window->requestedFormat();
if (options.multisample)
surfaceFormat.setSamples(16);
diff --git a/tools/qmlscene/qmlscene.pro b/tools/qmlscene/qmlscene.pro
index 0411fd8e31..b1267612c5 100644
--- a/tools/qmlscene/qmlscene.pro
+++ b/tools/qmlscene/qmlscene.pro
@@ -4,6 +4,7 @@ CONFIG += no_import_scan
SOURCES += main.cpp
-DEFINES += QML_RUNTIME_TESTING QT_QML_DEBUG_NO_WARNING
+DEFINES += QML_RUNTIME_TESTING
+!contains(QT_CONFIG, no-qml-debug): DEFINES += QT_QML_DEBUG_NO_WARNING
load(qt_tool)
diff --git a/tools/tools.pro b/tools/tools.pro
index 18bfe28a8a..3952ec4b01 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -1,4 +1,5 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += qml-private
SUBDIRS += \
qmlmin \
qmlimportscanner
@@ -11,7 +12,7 @@ qmlimportscanner.CONFIG = host_build
qml \
qmllint
- !contains(QT_CONFIG, no-qml-debug): SUBDIRS += qmlprofiler
+ qtConfig(qml-network):!contains(QT_CONFIG, no-qml-debug): SUBDIRS += qmlprofiler
qtHaveModule(quick) {
!static: {
@@ -23,7 +24,7 @@ qmlimportscanner.CONFIG = host_build
qtHaveModule(widgets): SUBDIRS += qmleasing
}
qtHaveModule(qmltest): SUBDIRS += qmltestrunner
- contains(QT_CONFIG, private_tests): SUBDIRS += qmljs
+ qtConfig(private_tests): SUBDIRS += qmljs
}
qml.depends = qmlimportscanner