From 9e5376327fb258e1c0207c2d6b6a2f9254f5b3ee Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Wed, 19 Feb 2020 17:17:59 +0300 Subject: Escape url.toString() before passing it to QRegularExpression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise the test fails when path contains special characters like ‘+’. Change-Id: I461d9755436148ce979284be31ef8d204235c8a4 Reviewed-by: Ulf Hermann --- tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index 5e855efe1a..2bee283826 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -302,7 +302,8 @@ void tst_qqmlapplicationengine::failureToLoadTriggersWarningSignal() auto url = testFileUrl("invalid.qml"); qRegisterMetaType>(); QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlApplicationEngine failed to load component"); - QTest::ignoreMessage(QtMsgType::QtWarningMsg, QRegularExpression(url.toString() + QLatin1Char('*'))); + QTest::ignoreMessage(QtMsgType::QtWarningMsg, + QRegularExpression(QRegularExpression::escape(url.toString()) + QLatin1Char('*'))); QQmlApplicationEngine test; QSignalSpy warningObserver(&test, &QQmlApplicationEngine::warnings); test.load(url); -- cgit v1.2.3 From b3ff342d327dc00d99281dca4fbfe6c4300aa6c6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 20 Feb 2020 16:00:05 +0100 Subject: Revert "QQuickItemView: do not set parent to nullptr upon destruction" This reverts commit 5445fcac36d7122d533a2bdf0fcfe6206b7f3ff4. The original commit avoids a warning generated for a dubious use case and breaks controls2 in a non-trivial way as a side effect. We should rather live with the warning. Task-number: QTBUG-82368 Change-Id: I6197bb63036cb25ec3e88f549667519b8f3ff13a Reviewed-by: Mitch Curtis Reviewed-by: Fabian Kosmale --- src/quick/items/qquickitemview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 3e3a2c262b..7fb392233e 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -2419,7 +2419,7 @@ void QQuickItemView::destroyingItem(QObject *object) Q_D(QQuickItemView); QQuickItem* item = qmlobject_cast(object); if (item) { - QQuickItemPrivate::get(item)->setCulled(true); + item->setParentItem(nullptr); d->unrequestedItems.remove(item); } } -- cgit v1.2.3 From dd481a2bb4f858178b984a38cd8c3621d46446b7 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 19 Feb 2020 16:40:31 -0600 Subject: Fix texture coords for the compressed texture atlas The texture coords should be based on the actual image size, and not on the padded size. Change-Id: I262b7ca93e26c48324ec892a988f2fc62132175e Reviewed-by: Laszlo Agocs --- .../scenegraph/compressedtexture/qsgcompressedatlastexture.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp index e981921c69..7c98e2c1e1 100644 --- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp +++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp @@ -136,12 +136,12 @@ Texture::Texture(Atlas *atlas, const QRect &textureRect, const QByteArray &data, { float w = atlas->size().width(); float h = atlas->size().height(); - QRect nopad = atlasSubRect(); + const QRect &r = atlasSubRect(); // offset by half-pixel to prevent bleeding when scaling - m_texture_coords_rect = QRectF((nopad.x() + .5) / w, - (nopad.y() + .5) / h, - (nopad.width() - 1.) / w, - (nopad.height() - 1.) / h); + m_texture_coords_rect = QRectF((r.x() + .5) / w, + (r.y() + .5) / h, + (size.width() - 1.) / w, + (size.height() - 1.) / h); } Texture::~Texture() -- cgit v1.2.3 From 130c26023b56469f4274c4c0b039acd20ac3988b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 17 Feb 2020 14:15:49 +0100 Subject: Doc: Fix documentation from QQmlEngine::singletonInstance() Don't suggest procedural registration of C++ types. Change-Id: Ib133fa7557f7555222fc55344a29967efc5c1f6f Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlengine.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index f97612ab75..ad57b1f74b 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1360,12 +1360,16 @@ void QQmlEngine::setOutputWarningsToStandardError(bool enabled) \code class MySingleton : public QObject { Q_OBJECT + + // Register as default constructed singleton. + QML_ELEMENT + QML_SINGLETON + static int typeId; // ... }; - // Register with QObject* callback - MySingleton::typeId = qmlRegisterSingletonType(...); + MySingleton::typeId = qmlTypeId(...); // Retrieve as QObject* QQmlEngine engine; @@ -1382,11 +1386,10 @@ void QQmlEngine::setOutputWarningsToStandardError(bool enabled) QJSValue instance = engine.singletonInstance(typeId); \endcode - It is recommended to store the QML type id during registration, e.g. as a static member - in the singleton class. Otherwise, a costly lookup via qmlTypeId() has to be performed - at run-time. + It is recommended to store the QML type id, e.g. as a static member in the + singleton class. The lookup via qmlTypeId() is costly. - \sa qmlRegisterSingletonType(), qmlTypeId() + \sa QML_SINGLETON, qmlRegisterSingletonType(), qmlTypeId() \since 5.12 */ template<> -- cgit v1.2.3 From deb74c609e066b0efd73d1adbc6077e6ca7d8c45 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 24 Feb 2020 09:41:22 +0100 Subject: Fix build with -no-feature-network Fixes: QTBUG-82418 Change-Id: Ibceeefed75941d963e6b79b44e9231d0d8053221 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 2 ++ src/qml/jsruntime/qv4engine_p.h | 6 ++++++ src/qmlworkerscript/qquickworkerscript.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index d885c28166..76fefb767d 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -2351,9 +2351,11 @@ int ExecutionEngine::registerExtension() return registrationData()->extensionCount++; } +#if QT_CONFIG(qml_network) QNetworkAccessManager *QV4::detail::getNetworkAccessManager(ExecutionEngine *engine) { return engine->qmlEngine()->networkAccessManager(); } +#endif // qml_network QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index e0025feb00..efe44a324c 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -91,6 +91,7 @@ class PageAllocation; QT_BEGIN_NAMESPACE +#if QT_CONFIG(qml_network) class QNetworkAccessManager; namespace QV4 { @@ -99,6 +100,9 @@ namespace detail { QNetworkAccessManager *getNetworkAccessManager(ExecutionEngine *engine); } } +#else +namespace QV4 { struct QObjectMethod; } +#endif // qml_network // Used to allow a QObject method take and return raw V4 handles without having to expose // 48 in the public API. @@ -355,7 +359,9 @@ public: FunctionObject *getStackFunction() const { return reinterpret_cast(jsObjects + GetStack_Function); } FunctionObject *thrower() const { return reinterpret_cast(jsObjects + ThrowerObject); } +#if QT_CONFIG(qml_network) QNetworkAccessManager* (*networkAccessManager)(ExecutionEngine*) = detail::getNetworkAccessManager; +#endif enum JSStrings { String_Empty, diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp index d42742d6f5..635d508daf 100644 --- a/src/qmlworkerscript/qquickworkerscript.cpp +++ b/src/qmlworkerscript/qquickworkerscript.cpp @@ -130,7 +130,9 @@ struct WorkerScript : public QV4::ExecutionEngine { QQuickWorkerScriptEnginePrivate *p = nullptr; QUrl source; QQuickWorkerScript *owner = nullptr; +#if QT_CONFIG(qml_network) QScopedPointer scriptLocalNAM; +#endif int id = -1; }; @@ -390,6 +392,7 @@ WorkerScript::WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent) QV4::ScopedValue sendMessage(scope, QV4::FunctionObject::createBuiltinFunction(this, name, QQuickWorkerScriptEnginePrivate::method_sendMessage, 1)); api->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("sendMessage"))), sendMessage); globalObject->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("WorkerScript"))), api); +#if QT_CONFIG(qml_network) networkAccessManager = [](QV4::ExecutionEngine *engine){ auto *workerScript = static_cast(engine); if (workerScript->scriptLocalNAM) @@ -400,6 +403,7 @@ WorkerScript::WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent) workerScript->scriptLocalNAM.reset(new QNetworkAccessManager(workerScript->p)); return workerScript->scriptLocalNAM.get(); }; +#endif // qml_network } int QQuickWorkerScriptEngine::registerWorkerScript(QQuickWorkerScript *owner) -- cgit v1.2.3 From 40cb674800e0ba90876e982160c3c5bcd2f0e929 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 17 Feb 2020 14:35:26 +0100 Subject: Doc: Fix QQuickTableView snippet Use static registration, provide a .pro file, and make it load and show the right file. Change-Id: I949831a399ce00cd8b3d012d8bd4e95a1efcdeb5 Reviewed-by: Simon Hausmann --- .../doc/snippets/qml/tableview/cpp-tablemodel.cpp | 47 ++--------- .../doc/snippets/qml/tableview/cpp-tablemodel.h | 94 ++++++++++++++++++++++ src/quick/doc/snippets/qml/tableview/tableview.pro | 20 +++++ src/quick/items/qquicktableview.cpp | 2 +- 4 files changed, 120 insertions(+), 43 deletions(-) create mode 100644 src/quick/doc/snippets/qml/tableview/cpp-tablemodel.h create mode 100644 src/quick/doc/snippets/qml/tableview/tableview.pro diff --git a/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp b/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp index ea9f76f131..a8a37f80af 100644 --- a/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp +++ b/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp @@ -48,56 +48,19 @@ ** ****************************************************************************/ -//![0] +#include "cpp-tablemodel.h" #include -#include -#include - -class TableModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - - int rowCount(const QModelIndex & = QModelIndex()) const override - { - return 200; - } - - int columnCount(const QModelIndex & = QModelIndex()) const override - { - return 200; - } - - QVariant data(const QModelIndex &index, int role) const override - { - switch (role) { - case Qt::DisplayRole: - return QString("%1, %2").arg(index.column()).arg(index.row()); - default: - break; - } - - return QVariant(); - } - - QHash roleNames() const override - { - return { {Qt::DisplayRole, "display"} }; - } -}; +#include int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("TableModel", 0, 1, "TableModel"); - - QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + QQuickView view; + view.setSource(QStringLiteral("qrc:/cpp-tablemodel.qml")); + view.show(); return app.exec(); } -#include "main.moc" //![0] diff --git a/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.h b/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.h new file mode 100644 index 0000000000..4a3c46b573 --- /dev/null +++ b/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.h @@ -0,0 +1,94 @@ +/**************************************************************************** + ** + ** Copyright (C) 2020 The Qt Company Ltd. + ** Contact: https://www.qt.io/licensing/ + ** + ** This file is part of the documentation of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and The Qt Company. For licensing terms + ** and conditions see https://www.qt.io/terms-conditions. For further + ** information use the contact form at https://www.qt.io/contact-us. + ** + ** BSD License Usage + ** Alternatively, you may use this file under the terms of the BSD license + ** as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of The Qt Company Ltd nor the names of its + ** contributors may be used to endorse or promote products derived + ** from this software without specific prior written permission. + ** + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#ifndef CPPTABLEMODEL_H +#define CPPTABLEMODEL_H + +//![0] +#include +#include + +class TableModel : public QAbstractTableModel +{ + Q_OBJECT + QML_ELEMENT + QML_ADDED_IN_MINOR_VERSION(1) + +public: + int rowCount(const QModelIndex & = QModelIndex()) const override + { + return 200; + } + + int columnCount(const QModelIndex & = QModelIndex()) const override + { + return 200; + } + + QVariant data(const QModelIndex &index, int role) const override + { + switch (role) { + case Qt::DisplayRole: + return QString("%1, %2").arg(index.column()).arg(index.row()); + default: + break; + } + + return QVariant(); + } + + QHash roleNames() const override + { + return { {Qt::DisplayRole, "display"} }; + } +}; +//![0] + +#endif // CPPTABLEMODEL_H diff --git a/src/quick/doc/snippets/qml/tableview/tableview.pro b/src/quick/doc/snippets/qml/tableview/tableview.pro new file mode 100644 index 0000000000..0821f1b5d3 --- /dev/null +++ b/src/quick/doc/snippets/qml/tableview/tableview.pro @@ -0,0 +1,20 @@ +TEMPLATE = app + +QT += qml quick + +CONFIG += qmltypes +QML_IMPORT_NAME = TableModel +QML_IMPORT_MAJOR_VERSION = 0 + +SOURCES += \ + cpp-tablemodel.cpp + +HEADERS += \ + cpp-tablemodel.h + +RESOURCES += \ + cpp-tablemodel.qml \ + qml-tablemodel.qml \ + reusabledelegate.qml \ + tableviewwithheader.qml \ + tableviewwithprovider.qml diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 403801b7ae..6124c8304b 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -82,7 +82,7 @@ The following example shows how to create a model from C++ with multiple columns: - \snippet qml/tableview/cpp-tablemodel.cpp 0 + \snippet qml/tableview/cpp-tablemodel.h 0 And then how to use it from QML: -- cgit v1.2.3 From a962681a11a4a4a36053d060702353965298b8bb Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Wed, 12 Feb 2020 17:33:06 +0200 Subject: Examples: enable HighDPI scaling for Android These examples show very tiny UI elements on Android devices, thus enabling HighDPI. Task-number: QTBUG-80717 Change-Id: Id3b4184bef74faf9f7d165ac211bd39375d67f62 Reviewed-by: Ulf Hermann --- examples/quick/models/objectlistmodel/main.cpp | 1 + examples/quick/scenegraph/customgeometry/main.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/quick/models/objectlistmodel/main.cpp b/examples/quick/models/objectlistmodel/main.cpp index 8fbe7c183c..1418af90ca 100644 --- a/examples/quick/models/objectlistmodel/main.cpp +++ b/examples/quick/models/objectlistmodel/main.cpp @@ -66,6 +66,7 @@ //![0] int main(int argc, char ** argv) { + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QList dataList = { diff --git a/examples/quick/scenegraph/customgeometry/main.cpp b/examples/quick/scenegraph/customgeometry/main.cpp index 15310d279f..0b9b2eb3f9 100644 --- a/examples/quick/scenegraph/customgeometry/main.cpp +++ b/examples/quick/scenegraph/customgeometry/main.cpp @@ -56,6 +56,7 @@ //! [1] int main(int argc, char **argv) { + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQuickView view; -- cgit v1.2.3 From 033154229442e19bc675ab69015d460fe3aee775 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 13 Jan 2020 11:14:12 +0100 Subject: Warn when requesting unknown RHI backend When QSG_RHI_BACKEND is set to something we don't recognize. Change-Id: Ifa18cf38bc110e3a96b94fa89abac5bdfd70ba8a Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/qsgrhisupport.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 9194d3e730..cf30cb3f9a 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -157,6 +157,8 @@ void QSGRhiSupport::applySettings() } else if (rhiBackend == QByteArrayLiteral("null")) { m_rhiBackend = QRhi::Null; } else { + if (!rhiBackend.isEmpty()) + qWarning("Unknown key \"%s\" for QSG_RHI_BACKEND, falling back to default backend.", qPrintable(rhiBackend)); #if defined(Q_OS_WIN) m_rhiBackend = QRhi::D3D11; #elif defined(Q_OS_MACOS) || defined(Q_OS_IOS) -- cgit v1.2.3 From 86b3f39566ec597243718edb87498a653648457a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 21 Feb 2020 15:12:56 +0100 Subject: Doc: Add section about QVariantList and QVariantMap as C++ properties Change-Id: Ie18661274880f45d911baf05797a8b384d72f9f7 Fixes: QTBUG-82249 Reviewed-by: Edward Welbourne Reviewed-by: Paul Wicking --- src/qml/doc/src/cppintegration/data.qdoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc index 171b2b6a11..c91ce28f42 100644 --- a/src/qml/doc/src/cppintegration/data.qdoc +++ b/src/qml/doc/src/cppintegration/data.qdoc @@ -197,6 +197,25 @@ type or method parameter, the value can be created as a JavaScript array or object in QML, and is automatically converted to a QVariantList or QVariantMap when it is passed to C++. +Mind that QVariantList and QVariantMap properties of C++ types are stored as +values and cannot be changed in place by QML code. You can only replace the +whole map or list, but not manipulate its contents. The following code does +not work if the property \c l is a QVariantList: + +\code +MyListExposingItem { + l: [1, 2, 3] + Component.onCompleted: l[0] = 10 +} +\endcode + +The following code does work: +\code +MyListExposingItem { + l: [1, 2, 3] + Component.onCompleted: l = [10, 2, 3] +} +\endcode \section2 QDateTime to JavaScript Date -- cgit v1.2.3 From 8dcd51b63d26fcac466d80dc90942ae2cf3b4f4e Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 24 Feb 2020 17:26:41 +0000 Subject: Revert "Replace call to deprecated QNetworkReply::error method" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e5a4ba4a5573ace08def218b985dde83de0805fb. Reason for revert: it was decided to re-name a signal instead, like it's done in QProcess. Change-Id: I0f393c482d8be506430258d7afd4a0056611831f Reviewed-by: Mårten Nordheim --- src/qml/jsruntime/qv4include.cpp | 2 +- src/qml/qml/qqmlfile.cpp | 2 +- src/qml/qml/qqmltypeloader.cpp | 4 ++-- src/qml/qml/qqmlxmlhttprequest.cpp | 2 +- src/quick/items/qquickborderimage.cpp | 2 +- src/quick/util/qquickfontloader.cpp | 2 +- src/quick/util/qquickpixmapcache.cpp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 64ca719e29..92face6f94 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -163,7 +163,7 @@ void QV4Include::finished() QV4::Scope scope(v4); QV4::ScopedObject resultObj(scope, m_resultObject.value()); QV4::ScopedString status(scope, v4->newString(QStringLiteral("status"))); - if (m_reply->networkError() == QNetworkReply::NoError) { + if (m_reply->error() == QNetworkReply::NoError) { QByteArray data = m_reply->readAll(); QString code = QString::fromUtf8(data); diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp index ee54359d0f..465a342129 100644 --- a/src/qml/qml/qqmlfile.cpp +++ b/src/qml/qml/qqmlfile.cpp @@ -187,7 +187,7 @@ void QQmlFileNetworkReply::networkFinished() } } - if (m_reply->networkError()) { + if (m_reply->error()) { m_p->errorString = m_reply->errorString(); m_p->error = QQmlFilePrivate::Network; } else { diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index f910fe1140..13ad22126f 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -357,8 +357,8 @@ void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply) } } - if (reply->networkError()) { - blob->networkError(reply->networkError()); + if (reply->error()) { + blob->networkError(reply->error()); } else { QByteArray data = reply->readAll(); setData(blob, data); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index c820499703..2afbdb616b 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1291,7 +1291,7 @@ void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url) if (m_network->bytesAvailable() > 0) readyRead(); - QNetworkReply::NetworkError networkError = m_network->networkError(); + QNetworkReply::NetworkError networkError = m_network->error(); if (networkError != QNetworkReply::NoError) { error(networkError); } else { diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp index 32407a474f..3679df37d1 100644 --- a/src/quick/items/qquickborderimage.cpp +++ b/src/quick/items/qquickborderimage.cpp @@ -478,7 +478,7 @@ void QQuickBorderImage::sciRequestFinished() } d->redirectCount=0; - if (d->sciReply->networkError() != QNetworkReply::NoError) { + if (d->sciReply->error() != QNetworkReply::NoError) { d->status = Error; d->sciReply->deleteLater(); d->sciReply = nullptr; diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp index 505c70df7c..2de9768243 100644 --- a/src/quick/util/qquickfontloader.cpp +++ b/src/quick/util/qquickfontloader.cpp @@ -121,7 +121,7 @@ void QQuickFontObject::replyFinished() } redirectCount = 0; - if (!reply->networkError()) { + if (!reply->error()) { id = QFontDatabase::addApplicationFontFromData(reply->readAll()); if (id != -1) emit fontDownloaded(QFontDatabase::applicationFontFamilies(id).at(0), QQuickFontLoader::Ready); diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 8846edcd44..d96ebe70b2 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -578,7 +578,7 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply) QQuickPixmapReply::ReadError error = QQuickPixmapReply::NoError; QString errorString; QSize readSize; - if (reply->networkError()) { + if (reply->error()) { error = QQuickPixmapReply::Loading; errorString = reply->errorString(); } else { -- cgit v1.2.3 From 94901065ddd0c0c65e0db7c2151c0eb9eb3f64c5 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 25 Feb 2020 09:33:15 +0100 Subject: QQuickColorSpaceValueType: Version import Change-Id: I9396157f4b85ac075343426b22fff98b436e80d6 Reviewed-by: Ulf Hermann --- src/quick/util/qquickvaluetypes_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quick/util/qquickvaluetypes_p.h b/src/quick/util/qquickvaluetypes_p.h index b6cbc37adb..638fdd2773 100644 --- a/src/quick/util/qquickvaluetypes_p.h +++ b/src/quick/util/qquickvaluetypes_p.h @@ -420,6 +420,7 @@ class QQuickColorSpaceValueType Q_PROPERTY(float gamma READ gamma WRITE setGamma FINAL) QML_NAMED_ELEMENT(ColorSpace) + QML_ADDED_IN_MINOR_VERSION(15) Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") public: -- cgit v1.2.3 From 11ff5c314682258b6eb26e90847210662eb0f533 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 12 Feb 2020 17:49:31 +0100 Subject: Provide a way to statically register namespaces Previously, qmltyperegistrar would stumble over any QML_* macros in namespaces, as the namespaces could not be used as template arguments. However, namespaces are intended to be usable by QML as uncreatable "types". Now, qmltyperegistrar checks the namespace flag that moc records in the JSON output, and if that is given, registers an uncreatable metaobject instead of a type. Therefore you can use QML_ELEMENT and friends to register namespaces, just like you would register classes (except that they're implicitly uncreatable, of course). Task-number: QTBUG-68796 Change-Id: I186d7e9425471c32fb1a1f29c0c0b946afb2a9d2 Reviewed-by: Fabian Kosmale --- src/qml/qml/qqml.h | 32 +++++++++++++++++ src/qmltyperegistrar/qmltyperegistrar.cpp | 38 +++++++++++++++----- .../qml/qqmllanguage/data/cppstaticnamespace.2.qml | 5 +++ .../qml/qqmllanguage/data/cppstaticnamespace.qml | 6 ++++ tests/auto/qml/qqmllanguage/qqmllanguage.pro | 5 ++- tests/auto/qml/qqmllanguage/testtypes.h | 41 ++++++++++++++++++++++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 31 ++++++++++------ 7 files changed, 138 insertions(+), 20 deletions(-) create mode 100644 tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index ef7fdd1945..a3e3f1c584 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -848,6 +848,38 @@ void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor) template<> inline void qmlRegisterTypesAndRevisions<>(const char *, int) {} +inline void qmlRegisterNamespaceAndRevisions(const QMetaObject *metaObject, + const char *uri, int versionMajor) +{ + QQmlPrivate::RegisterTypeAndRevisions type = { + 0, + 0, + 0, + 0, + nullptr, + + uri, + versionMajor, + + metaObject, + metaObject, + + nullptr, + nullptr, + + -1, + -1, + -1, + + nullptr, + nullptr, + + &qmlCreateCustomParser + }; + + qmlregister(QQmlPrivate::TypeAndRevisionsRegistration, &type); +} + int Q_QML_EXPORT qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName); QT_END_NAMESPACE diff --git a/src/qmltyperegistrar/qmltyperegistrar.cpp b/src/qmltyperegistrar/qmltyperegistrar.cpp index 49c9fccb66..6fe5a20092 100644 --- a/src/qmltyperegistrar/qmltyperegistrar.cpp +++ b/src/qmltyperegistrar/qmltyperegistrar.cpp @@ -47,14 +47,23 @@ struct ScopedPointerFileCloser static inline void cleanup(FILE *handle) { if (handle) fclose(handle); } }; -static bool acceptClassForQmlTypeRegistration(const QJsonObject &classDef) +enum RegistrationMode { + NoRegistration, + ClassRegistration, + NamespaceRegistration +}; + +static RegistrationMode qmlTypeRegistrationMode(const QJsonObject &classDef) { const QJsonArray classInfos = classDef[QLatin1String("classInfos")].toArray(); for (const QJsonValue &info: classInfos) { - if (info[QLatin1String("name")].toString() == QLatin1String("QML.Element")) - return true; + const QString name = info[QLatin1String("name")].toString(); + if (name == QLatin1String("QML.Element")) { + return classDef[QLatin1String("namespace")].toBool() ? NamespaceRegistration + : ClassRegistration; + } } - return false; + return NoRegistration; } static QVector foreignRelatedTypes(const QVector &types, @@ -284,7 +293,11 @@ int main(int argc, char **argv) const QJsonArray classes = metaObject[QLatin1String("classes")].toArray(); for (const auto &cls : classes) { QJsonObject classDef = cls.toObject(); - if (acceptClassForQmlTypeRegistration(classDef)) { + switch (qmlTypeRegistrationMode(classDef)) { + case NamespaceRegistration: + classDef.insert(QLatin1String("namespace"), true); + Q_FALLTHROUGH(); + case ClassRegistration: { const QString include = metaObject[QLatin1String("inputFile")].toString(); const bool declaredInHeader = include.endsWith(QLatin1String(".h")); if (declaredInHeader) { @@ -297,8 +310,11 @@ int main(int argc, char **argv) .toString())); } types.append(classDef); - } else { + break; + } + case NoRegistration: foreignTypes.append(classDef); + break; } } }; @@ -360,8 +376,14 @@ int main(int argc, char **argv) continue; const QString className = classDef[QLatin1String("qualifiedClassName")].toString(); - fprintf(output, "\n qmlRegisterTypesAndRevisions<%s>(\"%s\", %s);", qPrintable(className), - qPrintable(module), qPrintable(majorVersion)); + + if (classDef.value(QLatin1String("namespace")).toBool()) { + fprintf(output, "\n qmlRegisterNamespaceAndRevisions(&%s::staticMetaObject, \"%s\", %s);", + qPrintable(className), qPrintable(module), qPrintable(majorVersion)); + } else { + fprintf(output, "\n qmlRegisterTypesAndRevisions<%s>(\"%s\", %s);", + qPrintable(className), qPrintable(module), qPrintable(majorVersion)); + } } fprintf(output, "\n qmlRegisterModule(\"%s\", %s, %s);", diff --git a/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml new file mode 100644 index 0000000000..3b37c29b18 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml @@ -0,0 +1,5 @@ +import StaticTest 1.0 + +MyStaticSecondNamespacedType { + list: [ MyStaticNamespacedType {} ] +} diff --git a/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml new file mode 100644 index 0000000000..2778baadb9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml @@ -0,0 +1,6 @@ +import StaticTest 1.0 + +MyStaticNamespacedType { + myEnum: MyStaticNamespace.Key5 + property int intProperty: MyStaticNamespace.MyOtherNSEnum.OtherKey2 +} diff --git a/tests/auto/qml/qqmllanguage/qqmllanguage.pro b/tests/auto/qml/qqmllanguage/qqmllanguage.pro index 724a27320c..6c54525544 100644 --- a/tests/auto/qml/qqmllanguage/qqmllanguage.pro +++ b/tests/auto/qml/qqmllanguage/qqmllanguage.pro @@ -1,4 +1,7 @@ -CONFIG += testcase +CONFIG += testcase qmltypes +QML_IMPORT_NAME = StaticTest +QML_IMPORT_VERSION = 1.0 + TARGET = tst_qqmllanguage macx:CONFIG -= app_bundle diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index 148179cb9c..8852bf7af9 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -750,6 +750,47 @@ private: bool m_ownRWObj; }; +namespace MyStaticNamespace { + Q_NAMESPACE + QML_ELEMENT + + enum MyNSEnum { + Key1 = 1, + Key2, + Key5 = 5 + }; + Q_ENUM_NS(MyNSEnum); + + enum class MyOtherNSEnum { + OtherKey1 = 1, + OtherKey2 + }; + Q_ENUM_NS(MyOtherNSEnum); + + + class MyNamespacedType : public QObject + { + Q_OBJECT + Q_PROPERTY(MyStaticNamespace::MyNSEnum myEnum MEMBER m_myEnum) + QML_NAMED_ELEMENT(MyStaticNamespacedType) + MyStaticNamespace::MyNSEnum m_myEnum = MyNSEnum::Key1; + }; + + class MySecondNamespacedType : public QObject + { + Q_OBJECT + Q_PROPERTY(QQmlListProperty list READ list) + QML_NAMED_ELEMENT(MyStaticSecondNamespacedType) + public: + QQmlListProperty list() + { + return QQmlListProperty(this, &m_list); + } + + private: + QList m_list; + }; +} namespace MyNamespace { Q_NAMESPACE diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index bd23806e3a..4d4056ba3f 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -1858,21 +1858,30 @@ void tst_qqmllanguage::valueTypes() void tst_qqmllanguage::cppnamespace() { - { - QQmlComponent component(&engine, testFileUrl("cppnamespace.qml")); + QScopedPointer object; + + auto create = [&](const char *file) { + QQmlComponent component(&engine, testFileUrl(file)); VERIFY_ERRORS(0); - QScopedPointer object(component.create()); + object.reset(component.create()); QVERIFY(object != nullptr); + }; - QCOMPARE(object->property("intProperty").toInt(), (int)MyNamespace::MyOtherNSEnum::OtherKey2); - } + auto createAndCheck = [&](const char *file) { + create(file); + return !QTest::currentTestFailed(); + }; - { - QQmlComponent component(&engine, testFileUrl("cppnamespace.2.qml")); - VERIFY_ERRORS(0); - QScopedPointer object(component.create()); - QVERIFY(object != nullptr); - } + QVERIFY(createAndCheck("cppnamespace.qml")); + QCOMPARE(object->property("intProperty").toInt(), + (int)MyNamespace::MyOtherNSEnum::OtherKey2); + + QVERIFY(createAndCheck("cppstaticnamespace.qml")); + QCOMPARE(object->property("intProperty").toInt(), + (int)MyStaticNamespace::MyOtherNSEnum::OtherKey2); + + QVERIFY(createAndCheck("cppnamespace.2.qml")); + QVERIFY(createAndCheck("cppstaticnamespace.2.qml")); } void tst_qqmllanguage::aliasProperties() -- cgit v1.2.3 From bbe3f976c3426fea5dd305feff79288b9719fcd5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 25 Feb 2020 11:14:36 +0100 Subject: Export QQuickRootItem to QML It was exported in 5.14, so we should probably still do so. Change-Id: Id44783c72fff50aee63d7c5a72f12ff9ca895a6b Reviewed-by: Fabian Kosmale --- src/imports/window/plugin.h | 7 +++++++ src/quick/items/qquickwindow_p.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/imports/window/plugin.h b/src/imports/window/plugin.h index 9f58ca9ac7..3bc2d91ddb 100644 --- a/src/imports/window/plugin.h +++ b/src/imports/window/plugin.h @@ -116,6 +116,13 @@ struct QQuickWindowQmlImplForeign QML_ADDED_IN_MINOR_VERSION(1) }; +struct QQuickRootItemForeign +{ + Q_GADGET + QML_FOREIGN(QQuickRootItem) + QML_ANONYMOUS +}; + QT_END_NAMESPACE #endif // PLUGIN_H diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index 86bdaf6396..e1ee7daf1c 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -88,7 +88,7 @@ class QRhiRenderBuffer; class QRhiRenderPassDescriptor; //Make it easy to identify and customize the root item if needed -class QQuickRootItem : public QQuickItem +class Q_QUICK_PRIVATE_EXPORT QQuickRootItem : public QQuickItem { Q_OBJECT public: -- cgit v1.2.3 From a4b25aa3c16ba9ce6e2821e591f7c35bf675d961 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 25 Feb 2020 11:20:07 +0100 Subject: qmltyperegistrar: Correctly collect attached types Their revisions were missing from the qmltypes. Change-Id: Iec7a5ad1c56135c761f6a1fe66904cf25d039850 Reviewed-by: Fabian Kosmale --- src/qmltyperegistrar/qmltypesclassdescription.cpp | 53 +++++++++++++---------- src/qmltyperegistrar/qmltypesclassdescription.h | 10 ++++- src/qmltyperegistrar/qmltypescreator.cpp | 3 +- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/qmltyperegistrar/qmltypesclassdescription.cpp b/src/qmltyperegistrar/qmltypesclassdescription.cpp index 8189bcd52e..c6279998b7 100644 --- a/src/qmltyperegistrar/qmltypesclassdescription.cpp +++ b/src/qmltyperegistrar/qmltypesclassdescription.cpp @@ -60,7 +60,7 @@ const QJsonObject *QmlTypesClassDescription::findType(const QVector void QmlTypesClassDescription::collect(const QJsonObject *classDef, const QVector &types, const QVector &foreign, - bool topLevel) + CollectMode mode) { const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray(); for (const QJsonValue &classInfo : classInfos) { @@ -69,10 +69,10 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, const QString value = obj[QLatin1String("value")].toString(); if (name == QLatin1String("DefaultProperty")) { - if (defaultProp.isEmpty()) + if (mode != AttachedType && defaultProp.isEmpty()) defaultProp = value; } else if (name == QLatin1String("QML.AddedInMinorVersion")) { - if (topLevel) { + if (mode == TopLevel) { addedInRevision = value.toInt(); revisions.append(value.toInt()); } else if (!elementName.isEmpty()) { @@ -80,7 +80,7 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, } } - if (!topLevel) + if (mode != TopLevel) continue; // These only apply to the original class @@ -94,27 +94,23 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, } else if (name == QLatin1String("QML.Creatable")) { isCreatable = (value != QLatin1String("false")); } else if (name == QLatin1String("QML.Attached")) { - attachedType = value; - if (const QJsonObject *other = findType(types, attachedType)) - collect(other, types, foreign, false); - else if (const QJsonObject *other = findType(foreign, attachedType)) - collect(other, types, foreign, false); + collectAttached(value, types, foreign); } else if (name == QLatin1String("QML.Singleton")) { if (value == QLatin1String("true")) isSingleton = true; } else if (name == QLatin1String("QML.Foreign")) { if (const QJsonObject *other = findType(foreign, value)) { classDef = other; - if (defaultProp.isEmpty()) { - // Foreign type can have a default property - const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray(); - for (const QJsonValue &classInfo : classInfos) { - QJsonObject obj = classInfo.toObject(); - if (obj[QLatin1String("name")].toString() == QLatin1String("DefaultProperty")) { - defaultProp = obj[QLatin1String("value")].toString(); - break; - } - } + // Foreign type can have a default property or an attached types + const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray(); + for (const QJsonValue &classInfo : classInfos) { + const QJsonObject obj = classInfo.toObject(); + const QString foreignName = obj[QLatin1String("name")].toString(); + const QString foreignValue = obj[QLatin1String("value")].toString(); + if (defaultProp.isEmpty() && foreignName == QLatin1String("DefaultProperty")) + defaultProp = foreignValue; + else if (foreignName == QLatin1String("QML.Attached")) + collectAttached(foreignValue, types, foreign); } } } else if (name == QLatin1String("QML.Root")) { @@ -125,7 +121,7 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, } } - if (!elementName.isEmpty()) { + if (mode == AttachedType || !elementName.isEmpty()) { collectExtraVersions(classDef, QString::fromLatin1("properties"), revisions); collectExtraVersions(classDef, QString::fromLatin1("slots"), revisions); collectExtraVersions(classDef, QString::fromLatin1("methods"), revisions); @@ -137,13 +133,13 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, const QJsonObject superObject = supers.first().toObject(); if (superObject[QLatin1String("access")].toString() == QLatin1String("public")) { const QString superName = superObject[QLatin1String("name")].toString(); - if (topLevel && superClass.isEmpty()) + if (mode == TopLevel && superClass.isEmpty()) superClass = superName; if (const QJsonObject *other = findType(types, superName)) - collect(other, types, foreign, false); + collect(other, types, foreign, mode == TopLevel ? SuperClass : AttachedType); else if (const QJsonObject *other = findType(foreign, superName)) - collect(other, types, foreign, false); + collect(other, types, foreign, mode == TopLevel ? SuperClass : AttachedType); } } @@ -159,3 +155,14 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, resolvedClass = classDef; } + +void QmlTypesClassDescription::collectAttached(const QString &attached, + const QVector &types, + const QVector &foreign) +{ + attachedType = attached; + if (const QJsonObject *other = findType(types, attachedType)) + collect(other, types, foreign, AttachedType); + else if (const QJsonObject *other = findType(foreign, attachedType)) + collect(other, types, foreign, AttachedType); +} diff --git a/src/qmltyperegistrar/qmltypesclassdescription.h b/src/qmltyperegistrar/qmltypesclassdescription.h index 8f3a6ea124..d468612beb 100644 --- a/src/qmltyperegistrar/qmltypesclassdescription.h +++ b/src/qmltyperegistrar/qmltypesclassdescription.h @@ -49,8 +49,16 @@ struct QmlTypesClassDescription bool isRootClass = false; bool isBuiltin = false; + enum CollectMode { + TopLevel, + SuperClass, + AttachedType + }; + void collect(const QJsonObject *classDef, const QVector &types, - const QVector &foreign, bool topLevel); + const QVector &foreign, CollectMode mode); + void collectAttached(const QString &attached, const QVector &types, + const QVector &foreign); static const QJsonObject *findType(const QVector &types, const QString &name); }; diff --git a/src/qmltyperegistrar/qmltypescreator.cpp b/src/qmltyperegistrar/qmltypescreator.cpp index 911120027e..292841541b 100644 --- a/src/qmltyperegistrar/qmltypescreator.cpp +++ b/src/qmltyperegistrar/qmltypescreator.cpp @@ -245,7 +245,8 @@ void QmlTypesCreator::writeComponents() m_qml.writeStartObject(componentElement); QmlTypesClassDescription collector; - collector.collect(&component, m_ownTypes, m_foreignTypes, true); + collector.collect(&component, m_ownTypes, m_foreignTypes, + QmlTypesClassDescription::TopLevel); writeClassProperties(collector); -- cgit v1.2.3 From 685d2ca3c7a9f221ac12f6db61e02bab40371f5f Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 14 Feb 2020 13:56:59 +0100 Subject: Propagate the LanguageChange events from the QQuickWindow to the items Fixes: QTBUG-78141 Task-number: QTBUG-82020 Change-Id: Id47f8efe77cd3f6bfd330c8759059e19de5a86d2 Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitem.cpp | 4 +++ src/quick/items/qquickwindow.cpp | 4 +++ tests/auto/quick/qquickitem/data/hellotr_la.qm | Bin 0 -> 237 bytes tests/auto/quick/qquickitem/tst_qquickitem.cpp | 35 +++++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 tests/auto/quick/qquickitem/data/hellotr_la.qm diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index fe8df6fb64..bc68d46075 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -8254,6 +8254,10 @@ bool QQuickItem::event(QEvent *ev) ev->ignore(); break; #endif // gestures + case QEvent::LanguageChange: + for (QQuickItem *item : d->childItems) + QCoreApplication::sendEvent(item, ev); + break; default: return QObject::event(ev); } diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 426a30dfca..55292d2157 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1767,6 +1767,10 @@ bool QQuickWindow::event(QEvent *e) if (d->activeFocusItem) QCoreApplication::sendEvent(d->activeFocusItem, e); return true; + case QEvent::LanguageChange: + if (d->contentItem) + QCoreApplication::sendEvent(d->contentItem, e); + break; default: break; } diff --git a/tests/auto/quick/qquickitem/data/hellotr_la.qm b/tests/auto/quick/qquickitem/data/hellotr_la.qm new file mode 100644 index 0000000000..25c0aad583 Binary files /dev/null and b/tests/auto/quick/qquickitem/data/hellotr_la.qm differ diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 8aab13e095..b5e001a2b7 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -40,6 +40,7 @@ #include "../../shared/util.h" #include "../shared/viewtestutil.h" #include +#include #ifdef TEST_QTBUG_60123 #include @@ -70,6 +71,7 @@ public: ulong timestamp; QPoint lastWheelEventPos; QPoint lastWheelEventGlobalPos; + int languageChangeEventCount = 0; protected: virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } @@ -86,6 +88,12 @@ protected: lastWheelEventPos = event->position().toPoint(); lastWheelEventGlobalPos = event->globalPosition().toPoint(); } + bool event(QEvent *e) override + { + if (e->type() == QEvent::LanguageChange) + languageChangeEventCount++; + return QQuickItem::event(e); + } }; class TestWindow: public QQuickWindow @@ -198,6 +206,7 @@ private slots: #endif void setParentCalledInOnWindowChanged(); + void receivesLanguageChangeEvent(); private: @@ -2155,6 +2164,32 @@ void tst_qquickitem::setParentCalledInOnWindowChanged() QVERIFY(ensureFocus(&view)); // should not crash } +void tst_qquickitem::receivesLanguageChangeEvent() +{ + QQuickWindow window; + window.setFramePosition(QPoint(100, 100)); + window.resize(200, 200); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QScopedPointer child1(new TestItem); + child1->setObjectName(QStringLiteral("child1")); + child1->setSize(QSizeF(200, 100)); + child1->setParentItem(window.contentItem()); + + QScopedPointer child2(new TestItem); + child2->setObjectName(QStringLiteral("child2")); + child2->setSize(QSizeF(50, 50)); + child2->setParentItem(child1.data()); + + QTranslator t; + QVERIFY(t.load("hellotr_la.qm", dataDirectory())); + QVERIFY(QCoreApplication::installTranslator(&t)); + + QTRY_COMPARE(child1->languageChangeEventCount, 1); + QCOMPARE(child2->languageChangeEventCount, 1); +} + QTEST_MAIN(tst_qquickitem) #include "tst_qquickitem.moc" -- cgit v1.2.3 From d832a67b9d9500fc19c7e6607f2f2f594b1d4bdc Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 25 Feb 2020 15:00:21 +0100 Subject: Move dependencies.json files into the right places The workerscript and models qmltypes are built from the library directory, the testlib qmltypes are built from the plugin directory. Change-Id: Ifc497aaf8204616ca817ee08ad86383ab2cbbdae Reviewed-by: Fabian Kosmale --- src/imports/models/dependencies.json | 2 -- src/imports/testlib/dependencies.json | 1 + src/imports/workerscript/dependencies.json | 2 -- src/qmlmodels/dependencies.json | 2 ++ src/qmltest/dependencies.json | 1 - src/qmlworkerscript/dependencies.json | 2 ++ 6 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 src/imports/models/dependencies.json create mode 100644 src/imports/testlib/dependencies.json delete mode 100644 src/imports/workerscript/dependencies.json create mode 100644 src/qmlmodels/dependencies.json delete mode 100644 src/qmltest/dependencies.json create mode 100644 src/qmlworkerscript/dependencies.json diff --git a/src/imports/models/dependencies.json b/src/imports/models/dependencies.json deleted file mode 100644 index 0d4f101c7a..0000000000 --- a/src/imports/models/dependencies.json +++ /dev/null @@ -1,2 +0,0 @@ -[ -] diff --git a/src/imports/testlib/dependencies.json b/src/imports/testlib/dependencies.json new file mode 100644 index 0000000000..b2c4125178 --- /dev/null +++ b/src/imports/testlib/dependencies.json @@ -0,0 +1 @@ +["QtQuick 2.0", "QtQuick.Window 2.0"] diff --git a/src/imports/workerscript/dependencies.json b/src/imports/workerscript/dependencies.json deleted file mode 100644 index 0d4f101c7a..0000000000 --- a/src/imports/workerscript/dependencies.json +++ /dev/null @@ -1,2 +0,0 @@ -[ -] diff --git a/src/qmlmodels/dependencies.json b/src/qmlmodels/dependencies.json new file mode 100644 index 0000000000..0d4f101c7a --- /dev/null +++ b/src/qmlmodels/dependencies.json @@ -0,0 +1,2 @@ +[ +] diff --git a/src/qmltest/dependencies.json b/src/qmltest/dependencies.json deleted file mode 100644 index b2c4125178..0000000000 --- a/src/qmltest/dependencies.json +++ /dev/null @@ -1 +0,0 @@ -["QtQuick 2.0", "QtQuick.Window 2.0"] diff --git a/src/qmlworkerscript/dependencies.json b/src/qmlworkerscript/dependencies.json new file mode 100644 index 0000000000..0d4f101c7a --- /dev/null +++ b/src/qmlworkerscript/dependencies.json @@ -0,0 +1,2 @@ +[ +] -- cgit v1.2.3 From 63aee8b66712601b6c34e4f2df99614f2d092c9d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 25 Feb 2020 15:28:46 +0100 Subject: Add revision to QQmlTypeNotAvailable Change-Id: Ic5ce3c50a4a7e43c7d3ba6b105de3ed08021227b Reviewed-by: Shawn Rutledge --- src/qml/qml/qqmltypenotavailable_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qml/qml/qqmltypenotavailable_p.h b/src/qml/qml/qqmltypenotavailable_p.h index 9bb19ed86c..d8427f2961 100644 --- a/src/qml/qml/qqmltypenotavailable_p.h +++ b/src/qml/qml/qqmltypenotavailable_p.h @@ -59,6 +59,7 @@ class QQmlTypeNotAvailable : public QObject { Q_OBJECT QML_NAMED_ELEMENT(TypeNotAvailable) QML_UNCREATABLE("Type not available.") + QML_ADDED_IN_MINOR_VERSION(15) }; QT_END_NAMESPACE -- cgit v1.2.3 From 8dd18850714b9a8e7a51891a2c48f8ca94ffe014 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 25 Feb 2020 13:32:55 +0100 Subject: Revision properties and methods added in 5.15 Change-Id: I00e3f9535e819d9d0d547c9d3cf50be469cf9339 Reviewed-by: Fabian Kosmale --- src/qmlmodels/qqmlobjectmodel_p.h | 4 ++-- src/qmlworkerscript/qquickworkerscript_p.h | 4 ++-- src/quick/items/qquickanimatedsprite_p.h | 2 +- src/quick/items/qquickitemview_p.h | 4 ++-- src/quick/items/qquicktext_p.h | 4 ++-- tests/auto/qml/qquickworkerscript/data/BaseWorker.qml | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/qmlmodels/qqmlobjectmodel_p.h b/src/qmlmodels/qqmlobjectmodel_p.h index 7fb4f64676..866d010cd3 100644 --- a/src/qmlmodels/qqmlobjectmodel_p.h +++ b/src/qmlmodels/qqmlobjectmodel_p.h @@ -104,8 +104,8 @@ Q_SIGNALS: void createdItem(int index, QObject *object); void initItem(int index, QObject *object); void destroyingItem(QObject *object); - void itemPooled(int index, QObject *object); - void itemReused(int index, QObject *object); + Q_REVISION(15) void itemPooled(int index, QObject *object); + Q_REVISION(15) void itemReused(int index, QObject *object); protected: QQmlInstanceModel(QObjectPrivate &dd, QObject *parent = nullptr) diff --git a/src/qmlworkerscript/qquickworkerscript_p.h b/src/qmlworkerscript/qquickworkerscript_p.h index 22a205cfe4..e56ce84b6d 100644 --- a/src/qmlworkerscript/qquickworkerscript_p.h +++ b/src/qmlworkerscript/qquickworkerscript_p.h @@ -88,7 +88,7 @@ class Q_AUTOTEST_EXPORT QQuickWorkerScript : public QObject, public QQmlParserSt { Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(bool ready READ ready NOTIFY readyChanged) + Q_PROPERTY(bool ready READ ready NOTIFY readyChanged REVISION 15) QML_NAMED_ELEMENT(WorkerScript); @@ -107,7 +107,7 @@ public Q_SLOTS: Q_SIGNALS: void sourceChanged(); - void readyChanged(); + Q_REVISION(15) void readyChanged(); void message(const QJSValue &messageObject); protected: diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h index c28b6ce3af..546598a409 100644 --- a/src/quick/items/qquickanimatedsprite_p.h +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -124,6 +124,7 @@ public: bool paused() const; int currentFrame() const; FinishBehavior finishBehavior() const; + void setFinishBehavior(FinishBehavior arg); Q_SIGNALS: @@ -172,7 +173,6 @@ public Q_SLOTS: void resetFrameDuration(); void setLoops(int arg); void setCurrentFrame(int arg); - void setFinishBehavior(FinishBehavior arg); private Q_SLOTS: void createEngine(); diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h index 521580d292..3f83383cd5 100644 --- a/src/quick/items/qquickitemview_p.h +++ b/src/quick/items/qquickitemview_p.h @@ -303,8 +303,8 @@ protected Q_SLOTS: virtual void initItem(int index, QObject *item); void modelUpdated(const QQmlChangeSet &changeSet, bool reset); void destroyingItem(QObject *item); - void onItemPooled(int modelIndex, QObject *object); - void onItemReused(int modelIndex, QObject *object); + Q_REVISION(15) void onItemPooled(int modelIndex, QObject *object); + Q_REVISION(15) void onItemReused(int modelIndex, QObject *object); void animStopped(); void trackedPositionChanged(); diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h index d310db508e..b64751b6f4 100644 --- a/src/quick/items/qquicktext_p.h +++ b/src/quick/items/qquicktext_p.h @@ -330,8 +330,8 @@ class QQuickTextLine : public QObject Q_PROPERTY(qreal height READ height WRITE setHeight) Q_PROPERTY(qreal x READ x WRITE setX) Q_PROPERTY(qreal y READ y WRITE setY) - Q_PROPERTY(qreal implicitWidth READ implicitWidth) - Q_PROPERTY(bool isLast READ isLast) + Q_PROPERTY(qreal implicitWidth READ implicitWidth REVISION 15) + Q_PROPERTY(bool isLast READ isLast REVISION 15) QML_ANONYMOUS public: diff --git a/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml index 59af114379..1d3420e186 100644 --- a/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml +++ b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml @@ -1,4 +1,5 @@ import QtQuick 2.0 +import QtQml.WorkerScript 2.15 WorkerScript { id: worker -- cgit v1.2.3 From 639196d0939ab2ce4f42671682cdddc91fee58ac Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 27 Feb 2020 09:30:06 +0100 Subject: Robustify QQuickListView test We should check for the window's root item before accessing it. Change-Id: I196d9cb4d0e525ffb62b3fd347fd986033cab3dd Reviewed-by: Fabian Kosmale --- tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index b141e235d5..49b68a8473 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -9867,6 +9867,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() window->resize(640, 480); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); + QVERIFY(window->rootObject() != nullptr); QQuickListView *listView = findItem(window->rootObject(), "list"); QTRY_VERIFY(listView != nullptr); -- cgit v1.2.3 From 83fdcbf3be0ddbbee1fd2c8c9ff1a4e3c707e3f0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 18 Feb 2020 15:16:54 +0100 Subject: QQmlTableInstanceModel: Fix refcounting of metatypes The reusable items pool should only hold unreferenced objects. Therefore, we can immediately delete them when draining. release() is not suitable here because it unconditionally decreases and therefore underflows the refcount. Furthermore, the metatype is also refcounted, which means we should keep it in a QQmlRefCounter in order to not leak references. Task-number: QTBUG-82000 Change-Id: Iefdaaecc34342eb2e3b1e5a3281f2e46ac472347 Reviewed-by: Joni Poikelin Reviewed-by: Simon Hausmann --- src/qmlmodels/qqmltableinstancemodel.cpp | 16 +++++++++++++--- src/qmlmodels/qqmltableinstancemodel_p.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp index fb2f7ee98b..9800eb8c72 100644 --- a/src/qmlmodels/qqmltableinstancemodel.cpp +++ b/src/qmlmodels/qqmltableinstancemodel.cpp @@ -78,7 +78,10 @@ void QQmlTableInstanceModel::deleteModelItemLater(QQmlDelegateModelItem *modelIt QQmlTableInstanceModel::QQmlTableInstanceModel(QQmlContext *qmlContext, QObject *parent) : QQmlInstanceModel(*(new QObjectPrivate()), parent) , m_qmlContext(qmlContext) - , m_metaType(new QQmlDelegateModelItemMetaType(m_qmlContext->engine()->handle(), nullptr, QStringList())) + , m_metaType( + new QQmlDelegateModelItemMetaType(m_qmlContext->engine()->handle(), nullptr, + QStringList()), + QQmlRefPointer::Adopt) { } @@ -149,7 +152,7 @@ QQmlDelegateModelItem *QQmlTableInstanceModel::resolveModelItem(int index) } // Create a new item from scratch - modelItem = m_adaptorModel.createItem(m_metaType, index); + modelItem = m_adaptorModel.createItem(m_metaType.data(), index); if (modelItem) { modelItem->delegate = delegate; m_modelItems.insert(index, modelItem); @@ -333,7 +336,14 @@ void QQmlTableInstanceModel::drainReusableItemsPool(int maxPoolTime) ++it; } else { it = m_reusableItemsPool.erase(it); - release(modelItem->object, NotReusable); + + Q_ASSERT(!modelItem->incubationTask); + Q_ASSERT(!modelItem->isObjectReferenced()); + Q_ASSERT(!modelItem->isReferenced()); + Q_ASSERT(modelItem->object); + emit destroyingItem(modelItem->object); + delete modelItem->object; + delete modelItem; } } } diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h index 1ea5ee7401..fd5968d872 100644 --- a/src/qmlmodels/qqmltableinstancemodel_p.h +++ b/src/qmlmodels/qqmltableinstancemodel_p.h @@ -142,7 +142,7 @@ private: QQmlAbstractDelegateComponent *m_delegateChooser = nullptr; QQmlComponent *m_delegate = nullptr; QPointer m_qmlContext; - QQmlDelegateModelItemMetaType *m_metaType; + QQmlRefPointer m_metaType; QHash m_modelItems; QList m_reusableItemsPool; -- cgit v1.2.3 From 40f2dbd5557da2103e03a3fb7682bbfda3ffd122 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 27 Feb 2020 09:27:40 +0100 Subject: QQmlDelegateModel: Avoid use-after-free The iterator may be invalidated by addCacheItem(). We can retrieve the relevant properties before, though. Change-Id: Ia3bbc50d16a7563097239177a75c9e2eab777a33 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann Reviewed-by: Shawn Rutledge --- src/qmlmodels/qqmldelegatemodel.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index c32caafaa6..3a05bf1689 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -1211,11 +1211,13 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ } Compositor::iterator it = m_compositor.find(group, index); + const auto flags = it->flags; + const auto modelIndex = it.modelIndex(); QQmlDelegateModelItem *cacheItem = it->inCache() ? m_cache.at(it.cacheIndex) : 0; if (!cacheItem || !cacheItem->delegate) { - QQmlComponent *delegate = resolveDelegate(it.modelIndex()); + QQmlComponent *delegate = resolveDelegate(modelIndex); if (!delegate) return nullptr; @@ -1226,17 +1228,17 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ // all related properties, and return the object (which // has already been incubated, otherwise it wouldn't be in the pool). addCacheItem(cacheItem, it); - reuseItem(cacheItem, index, it->flags); + reuseItem(cacheItem, index, flags); cacheItem->referenceObject(); return cacheItem->object; } // Since we could't find an available item in the pool, we create a new one - cacheItem = m_adaptorModel.createItem(m_cacheMetaType, it.modelIndex()); + cacheItem = m_adaptorModel.createItem(m_cacheMetaType, modelIndex); if (!cacheItem) return nullptr; - cacheItem->groups = it->flags; + cacheItem->groups = flags; addCacheItem(cacheItem, it); } -- cgit v1.2.3 From 2b5e0f90112fe85872894fb16e811203d4d3671f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 17 Feb 2020 15:30:54 +0100 Subject: V4: Fix mark stack overruns Instead of applying a heuristic on when to call drain() in unrelated code, we check the stack limit on each push(). If the soft limit is reached we try to drain. As drain() itself can push again, we try to limit the stack size by allowing at most 65 recursions of drain(). If none of that helps, we crash with a meaningful error message. This allows us to remove all the hacky drain() calls in other parts of the code. Change-Id: Ib979339470da0e85981de8131e7997755b757c71 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 15 ++++-------- src/qml/jsruntime/qv4persistent.cpp | 1 - src/qml/jsruntime/qv4qobjectwrapper.cpp | 7 +++--- src/qml/jsruntime/qv4value_p.h | 25 ++------------------ src/qml/memory/qv4mm.cpp | 21 +++++++---------- src/qml/memory/qv4mmdefs_p.h | 42 ++++++++++++++++++++++++--------- src/qml/qml/qqmlvmemetaobject.cpp | 2 +- 7 files changed, 51 insertions(+), 62 deletions(-) diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index f1b20ce53b..e9cc789607 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1266,20 +1266,15 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file) void ExecutionEngine::markObjects(MarkStack *markStack) { - for (int i = 0; i < NClasses; ++i) - if (classes[i]) { - classes[i]->mark(markStack); - if (markStack->top >= markStack->limit) - markStack->drain(); - } - markStack->drain(); + for (int i = 0; i < NClasses; ++i) { + if (Heap::InternalClass *c = classes[i]) + c->mark(markStack); + } identifierTable->markObjects(markStack); - for (auto compilationUnit: compilationUnits) { + for (auto compilationUnit: compilationUnits) compilationUnit->markObjects(markStack); - markStack->drain(); - } } ReturnedValue ExecutionEngine::throwError(const Value &value) diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index 79c372348f..f4901e3e4d 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -240,7 +240,6 @@ void PersistentValueStorage::mark(MarkStack *markStack) if (Managed *m = p->values[i].as()) m->mark(markStack); } - markStack->drain(); p = p->header.next; } diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 9613d064c4..66b79aa0e8 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -638,10 +638,11 @@ void QObjectWrapper::markWrapper(QObject *object, MarkStack *markStack) if (!ddata) return; - if (ddata->jsEngineId == markStack->engine->m_engineId) + const QV4::ExecutionEngine *engine = markStack->engine(); + if (ddata->jsEngineId == engine->m_engineId) ddata->jsWrapper.markOnce(markStack); - else if (markStack->engine->m_multiplyWrappedQObjects && ddata->hasTaintedV4Object) - markStack->engine->m_multiplyWrappedQObjects->mark(object, markStack); + else if (engine->m_multiplyWrappedQObjects && ddata->hasTaintedV4Object) + engine->m_multiplyWrappedQObjects->mark(object, markStack); } void QObjectWrapper::setProperty(ExecutionEngine *engine, int propertyIndex, const Value &value) diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index ae12033eb4..42e97b1d36 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -537,29 +537,8 @@ struct ValueArray { } void mark(MarkStack *markStack) { - Value *v = values; - const Value *end = v + alloc; - if (alloc > 32*1024) { - // drain from time to time to avoid overflows in the js stack - Value::HeapBasePtr *currentBase = markStack->top; - while (v < end) { - v->mark(markStack); - ++v; - if (markStack->top >= currentBase + 32*1024) { - Value::HeapBasePtr *oldBase = markStack->base; - markStack->base = currentBase; - markStack->drain(); - markStack->base = oldBase; - } - } - } else { - while (v < end) { - v->mark(markStack); - if (markStack->top >= markStack->limit) - markStack->drain(); - ++v; - } - } + for (Value *v = values, *end = values + alloc; v < end; ++v) + v->mark(markStack); } }; diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 35b2ff2749..3ed1bc48fd 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -848,16 +848,18 @@ Heap::Object *MemoryManager::allocObjectWithMemberData(const QV4::VTable *vtable static uint markStackSize = 0; MarkStack::MarkStack(ExecutionEngine *engine) - : engine(engine) + : m_engine(engine) { - base = (Heap::Base **)engine->gcStack->base(); - top = base; - limit = base + engine->maxGCStackSize()/sizeof(Heap::Base)*3/4; + m_base = (Heap::Base **)engine->gcStack->base(); + m_top = m_base; + const size_t size = engine->maxGCStackSize() / sizeof(Heap::Base); + m_hardLimit = m_base + size; + m_softLimit = m_base + size * 3 / 4; } void MarkStack::drain() { - while (top > base) { + while (m_top > m_base) { Heap::Base *h = pop(); ++markStackSize; Q_ASSERT(h); // at this point we should only have Heap::Base objects in this area on the stack. If not, weird things might happen. @@ -904,20 +906,15 @@ void MemoryManager::collectRoots(MarkStack *markStack) if (keepAlive) qobjectWrapper->mark(markStack); - - if (markStack->top >= markStack->limit) - markStack->drain(); } } void MemoryManager::mark() { markStackSize = 0; - MarkStack markStack(engine); collectRoots(&markStack); - - markStack.drain(); + // dtor of MarkStack drains } void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPtr) @@ -1220,8 +1217,6 @@ void MemoryManager::collectFromJSStack(MarkStack *markStack) const Q_ASSERT(m->inUse()); // Skip pointers to already freed objects, they are bogus as well m->mark(markStack); - if (markStack->top >= markStack->limit) - markStack->drain(); } ++v; } diff --git a/src/qml/memory/qv4mmdefs_p.h b/src/qml/memory/qv4mmdefs_p.h index 8a53492822..117e8f4360 100644 --- a/src/qml/memory/qv4mmdefs_p.h +++ b/src/qml/memory/qv4mmdefs_p.h @@ -53,6 +53,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -270,22 +271,41 @@ Q_STATIC_ASSERT(sizeof(HeapItem) == Chunk::SlotSize); Q_STATIC_ASSERT(QT_POINTER_SIZE*8 == Chunk::Bits); Q_STATIC_ASSERT((1 << Chunk::BitShift) == Chunk::Bits); -struct MarkStack { +struct Q_QML_PRIVATE_EXPORT MarkStack { MarkStack(ExecutionEngine *engine); - Heap::Base **top = nullptr; - Heap::Base **base = nullptr; - Heap::Base **limit = nullptr; - ExecutionEngine *engine; + ~MarkStack() { drain(); } + void push(Heap::Base *m) { - *top = m; - ++top; - } - Heap::Base *pop() { - --top; - return *top; + *(m_top++) = m; + + if (m_top < m_softLimit) + return; + + // If at or above soft limit, partition the remaining space into at most 64 segments and + // allow one C++ recursion of drain() per segment, plus one for the fence post. + const quintptr segmentSize = qNextPowerOfTwo(quintptr(m_hardLimit - m_softLimit) / 64u); + if (m_drainRecursion * segmentSize <= quintptr(m_top - m_softLimit)) { + ++m_drainRecursion; + drain(); + --m_drainRecursion; + } else if (m_top == m_hardLimit) { + qFatal("GC mark stack overrun. Either simplify your application or" + "increase QV4_GC_MAX_STACK_SIZE"); + } } + + ExecutionEngine *engine() const { return m_engine; } + +private: + Heap::Base *pop() { return *(--m_top); } void drain(); + Heap::Base **m_top = nullptr; + Heap::Base **m_base = nullptr; + Heap::Base **m_softLimit = nullptr; + Heap::Base **m_hardLimit = nullptr; + ExecutionEngine *m_engine = nullptr; + quintptr m_drainRecursion = 0; }; // Some helper to automate the generation of our diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index edf9657f53..aa9f4bc1bd 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -1238,7 +1238,7 @@ void QQmlVMEMetaObject::ensureQObjectWrapper() void QQmlVMEMetaObject::mark(QV4::MarkStack *markStack) { - if (engine != markStack->engine) + if (engine != markStack->engine()) return; propertyAndMethodStorage.markOnce(markStack); -- cgit v1.2.3 From 391bd68b4045268b389780f4b08d2f07951b45bf Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Thu, 27 Feb 2020 12:05:32 +0100 Subject: error -> networkError to fix deprecation warning Change-Id: I80d518a1b21185baba0d4934ebf486809e086f9f Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4include.cpp | 2 +- src/qml/qml/qqmltypeloader.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 92face6f94..64ca719e29 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -163,7 +163,7 @@ void QV4Include::finished() QV4::Scope scope(v4); QV4::ScopedObject resultObj(scope, m_resultObject.value()); QV4::ScopedString status(scope, v4->newString(QStringLiteral("status"))); - if (m_reply->error() == QNetworkReply::NoError) { + if (m_reply->networkError() == QNetworkReply::NoError) { QByteArray data = m_reply->readAll(); QString code = QString::fromUtf8(data); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 13ad22126f..f910fe1140 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -357,8 +357,8 @@ void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply) } } - if (reply->error()) { - blob->networkError(reply->error()); + if (reply->networkError()) { + blob->networkError(reply->networkError()); } else { QByteArray data = reply->readAll(); setData(blob, data); -- cgit v1.2.3 From 46162c304195db2376706f2e1a9da2b2c938e97b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 19 Feb 2020 14:00:46 +0100 Subject: QQuickTableView: Immediately delete delegates when possible In the dtor we don't need to care about any side effects a direct delete may have. Rather, any deleteLater() may not take effect anymore as the event loop may be gone already. Task-number: QTBUG-82000 Change-Id: I97935dc47fbbfd0c050e80c333c36a05f685c45d Reviewed-by: Joni Poikelin Reviewed-by: Simon Hausmann Reviewed-by: Ulf Hermann --- src/qmlmodels/qqmltableinstancemodel.cpp | 19 +++++++++++++++++++ src/qmlmodels/qqmltableinstancemodel_p.h | 1 + src/quick/items/qquicktableview.cpp | 11 ++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp index 9800eb8c72..e2cecfef79 100644 --- a/src/qmlmodels/qqmltableinstancemodel.cpp +++ b/src/qmlmodels/qqmltableinstancemodel.cpp @@ -240,6 +240,25 @@ QQmlInstanceModel::ReleaseFlags QQmlTableInstanceModel::release(QObject *object, return QQmlInstanceModel::Destroyed; } +void QQmlTableInstanceModel::dispose(QObject *object) +{ + Q_ASSERT(object); + auto modelItem = qvariant_cast(object->property(kModelItemTag)); + Q_ASSERT(modelItem); + + modelItem->releaseObject(); + + // The item is not referenced by anyone + Q_ASSERT(!modelItem->isObjectReferenced()); + Q_ASSERT(!modelItem->isReferenced()); + + m_modelItems.remove(modelItem->index); + + emit destroyingItem(object); + delete object; + delete modelItem; +} + void QQmlTableInstanceModel::cancel(int index) { auto modelItem = m_modelItems.value(index); diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h index fd5968d872..4ea1d85d16 100644 --- a/src/qmlmodels/qqmltableinstancemodel_p.h +++ b/src/qmlmodels/qqmltableinstancemodel_p.h @@ -117,6 +117,7 @@ public: QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; ReleaseFlags release(QObject *object) override { return release(object, NotReusable); } ReleaseFlags release(QObject *object, ReusableFlag reusable); + void dispose(QObject *object); void cancel(int) override; void insertIntoReusableItemsPool(QQmlDelegateModelItem *modelItem); diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 4b34e3b2c1..4105996b31 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -441,7 +441,16 @@ QQuickTableViewPrivate::QQuickTableViewPrivate() QQuickTableViewPrivate::~QQuickTableViewPrivate() { - releaseLoadedItems(QQmlTableInstanceModel::NotReusable); + for (auto *fxTableItem : loadedItems) { + if (auto item = fxTableItem->item) { + if (fxTableItem->ownItem) + delete item; + else if (tableModel) + tableModel->dispose(item); + } + delete fxTableItem; + } + if (tableModel) delete tableModel; } -- cgit v1.2.3 From e0bbea53f92648e004b162428e36dcdd8cf95cf1 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 28 Feb 2020 11:15:01 +0000 Subject: Revert "error -> networkError to fix deprecation warning" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 391bd68b4045268b389780f4b08d2f07951b45bf. Reason for revert: this warning is only temporary, the patch fixing it - is coming. But the original change of error->networkError was reverted in 5.15 to make the new patch, changing signal name instead, work. Now qtdeclarative does not compile - it calls non-existing function. Change-Id: I276562564c8954f67dcdf4fd5d08afd5f3f9dc8b Reviewed-by: Topi Reiniö Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4include.cpp | 2 +- src/qml/qml/qqmltypeloader.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 64ca719e29..92face6f94 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -163,7 +163,7 @@ void QV4Include::finished() QV4::Scope scope(v4); QV4::ScopedObject resultObj(scope, m_resultObject.value()); QV4::ScopedString status(scope, v4->newString(QStringLiteral("status"))); - if (m_reply->networkError() == QNetworkReply::NoError) { + if (m_reply->error() == QNetworkReply::NoError) { QByteArray data = m_reply->readAll(); QString code = QString::fromUtf8(data); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index f910fe1140..13ad22126f 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -357,8 +357,8 @@ void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply) } } - if (reply->networkError()) { - blob->networkError(reply->networkError()); + if (reply->error()) { + blob->networkError(reply->error()); } else { QByteArray data = reply->readAll(); setData(blob, data); -- cgit v1.2.3 From 8319597ae30219c71aef9d2086e8e8294802686c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Tue, 25 Feb 2020 16:42:15 +0100 Subject: Properly deprecate QQuickText::doLayout() and get rid of it for Qt6 It was only deprecated through its documentation. Change-Id: I0b7bdeec4ed965c3df627a03ab0e539c4e9c2018 Reviewed-by: Shawn Rutledge --- src/quick/items/qquicktext.cpp | 4 ++++ src/quick/items/qquicktext_p.h | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 1c7f1ca6aa..f39e8e0316 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -2969,6 +2969,8 @@ void QQuickText::setRenderType(QQuickText::RenderType renderType) d->updateLayout(); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_DEPRECATED_SINCE(5, 15) /*! \qmlmethod QtQuick::Text::doLayout() \deprecated @@ -2980,6 +2982,8 @@ void QQuickText::doLayout() forceLayout(); } +#endif +#endif /*! \qmlmethod QtQuick::Text::forceLayout() \since 5.9 diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h index b64751b6f4..0fffc1fb9a 100644 --- a/src/quick/items/qquicktext_p.h +++ b/src/quick/items/qquicktext_p.h @@ -223,7 +223,12 @@ public: QRectF boundingRect() const override; QRectF clipRect() const override; - Q_INVOKABLE void doLayout(); // ### Qt 6: remove +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use forceLayout() instead") + Q_INVOKABLE void doLayout(); +#endif +#endif Q_REVISION(9) Q_INVOKABLE void forceLayout(); RenderType renderType() const; -- cgit v1.2.3 From d8f6f41c334d14c4712b1dc16554f80bb1290e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 26 Feb 2020 09:35:10 +0100 Subject: Deprecate non-const version of saveToFile() It will be removed in Qt 6 Change-Id: I7d8853ce3008bb2c594caa5a23e2964158717fe4 Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitemgrabresult.cpp | 2 ++ src/quick/items/qquickitemgrabresult.h | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/quick/items/qquickitemgrabresult.cpp b/src/quick/items/qquickitemgrabresult.cpp index f298803c7f..00e84536e9 100644 --- a/src/quick/items/qquickitemgrabresult.cpp +++ b/src/quick/items/qquickitemgrabresult.cpp @@ -195,6 +195,7 @@ bool QQuickItemGrabResult::saveToFile(const QString &fileName) const } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_DEPRECATED_SINCE(5, 15) /*! * \overload * \internal @@ -203,6 +204,7 @@ bool QQuickItemGrabResult::saveToFile(const QString &fileName) { return qAsConst(*this).saveToFile(fileName); } +#endif #endif // < Qt 6 QUrl QQuickItemGrabResult::url() const diff --git a/src/quick/items/qquickitemgrabresult.h b/src/quick/items/qquickitemgrabresult.h index c92a8c52f4..a45ed62ed5 100644 --- a/src/quick/items/qquickitemgrabresult.h +++ b/src/quick/items/qquickitemgrabresult.h @@ -68,7 +68,10 @@ public: QUrl url() const; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - Q_INVOKABLE bool saveToFile(const QString &fileName); // ### Qt 6: remove +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("This overload is deprecated. Use the const member function instead") + Q_INVOKABLE bool saveToFile(const QString &fileName); +#endif #endif Q_INVOKABLE bool saveToFile(const QString &fileName) const; -- cgit v1.2.3 From 8ab237edf170f5b0482dccf5169868e5c7c47771 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 27 Feb 2020 10:49:14 +0100 Subject: Restore offset/length in QQmlJS::DiagnosticMessage This is needed in a few places outside of declarative, so this change restores the loc member in DiagnosticMessage and moves QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory. QQmlError is unaffected and retains only line/column. Amends d4d197d06279f9257647628f7e1ccc9ec763a6bb Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2 Reviewed-by: Fabian Kosmale --- src/qml/common/common.pri | 1 + src/qml/common/qqmlapiversion_p.h | 2 +- src/qml/common/qqmljsdiagnosticmessage_p.h | 5 +- src/qml/common/qqmljssourcelocation_p.h | 85 +++++++++++++++++++++ src/qml/compiler/qqmlirbuilder.cpp | 61 ++++++++------- src/qml/compiler/qqmlirbuilder_p.h | 30 ++++---- src/qml/compiler/qv4bytecodegenerator.cpp | 2 +- src/qml/compiler/qv4bytecodegenerator_p.h | 4 +- src/qml/compiler/qv4codegen.cpp | 5 +- src/qml/compiler/qv4codegen_p.h | 12 +-- src/qml/compiler/qv4compilercontext.cpp | 5 +- src/qml/compiler/qv4compilercontext_p.h | 12 +-- src/qml/compiler/qv4compilerscanfunctions.cpp | 6 +- src/qml/compiler/qv4compilerscanfunctions_p.h | 2 +- src/qml/jsruntime/qv4engine.cpp | 4 +- src/qml/jsruntime/qv4runtimecodegen.cpp | 4 +- src/qml/jsruntime/qv4runtimecodegen_p.h | 4 +- src/qml/jsruntime/qv4script.cpp | 9 ++- src/qml/parser/parser.pri | 3 +- src/qml/parser/qqmljs.g | 37 +++++---- src/qml/parser/qqmljsastfwd_p.h | 2 +- src/qml/parser/qqmljsengine_p.cpp | 4 +- src/qml/parser/qqmljsengine_p.h | 6 +- src/qml/parser/qqmljslexer.cpp | 8 +- src/qml/parser/qqmljssourcelocation_p.h | 87 ---------------------- src/qml/qml/qqmlcomponent.cpp | 5 +- src/qml/qml/qqmlcustomparser.cpp | 9 ++- src/qml/qml/qqmlcustomparser_p.h | 4 +- src/qml/qml/qqmldatablob.cpp | 12 ++- src/qml/qml/qqmldatablob_p.h | 2 +- src/qml/qml/qqmlengine.cpp | 7 +- src/qml/qml/qqmlerror.cpp | 15 ++-- src/qml/qml/qqmlinfo.cpp | 5 +- src/qml/qml/qqmlirloader.cpp | 6 +- src/qml/qml/qqmljavascriptexpression.cpp | 5 +- src/qml/qml/qqmlobjectcreator.cpp | 5 +- src/qml/qml/qqmlpropertycachecreator_p.h | 61 +++++++-------- src/qml/qml/qqmlpropertyvalidator.cpp | 36 ++++----- src/qml/qml/qqmlpropertyvalidator_p.h | 13 ++-- src/qml/qml/qqmlscriptblob.cpp | 5 +- src/qml/qml/qqmltypecompiler.cpp | 23 ++++-- src/qml/qml/qqmltypecompiler_p.h | 7 +- src/qml/qml/qqmltypedata.cpp | 42 +++++------ src/qml/qml/qqmltypedata_p.h | 2 +- src/qml/qml/qqmltypeloader.cpp | 5 +- src/qml/qml/qqmltypeloaderqmldircontent.cpp | 9 ++- src/qml/qmldirparser/qqmldirparser.cpp | 6 +- tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp | 8 +- tests/auto/shared/qqmljsastdumper.cpp | 2 +- tests/auto/shared/qqmljsastdumper.h | 2 +- tools/qmlcachegen/qmlcachegen.cpp | 6 +- tools/qmlformat/commentastvisitor.h | 1 + tools/qmlformat/dumpastvisitor.h | 1 + tools/qmlformat/main.cpp | 4 +- tools/qmlimportscanner/main.cpp | 2 +- tools/qmllint/main.cpp | 2 +- tools/qmllint/scopetree.cpp | 12 +-- tools/qmllint/scopetree.h | 16 ++-- tools/qmllint/typedescriptionreader.h | 4 +- 59 files changed, 380 insertions(+), 364 deletions(-) create mode 100644 src/qml/common/qqmljssourcelocation_p.h delete mode 100644 src/qml/parser/qqmljssourcelocation_p.h diff --git a/src/qml/common/common.pri b/src/qml/common/common.pri index bcc3ea0fa0..b333c0f6d9 100644 --- a/src/qml/common/common.pri +++ b/src/qml/common/common.pri @@ -28,6 +28,7 @@ HEADERS += \ $$PWD/qqmljsdiagnosticmessage_p.h \ $$PWD/qqmljsfixedpoolarray_p.h \ $$PWD/qqmljsmemorypool_p.h \ + $$PWD/qqmljssourcelocation_p.h \ $$PWD/qv4alloca_p.h \ $$PWD/qv4calldata_p.h \ $$PWD/qv4compileddata_p.h \ diff --git a/src/qml/common/qqmlapiversion_p.h b/src/qml/common/qqmlapiversion_p.h index 4baf37e11c..44d8e3f236 100644 --- a/src/qml/common/qqmlapiversion_p.h +++ b/src/qml/common/qqmlapiversion_p.h @@ -51,6 +51,6 @@ // We mean it. // -#define Q_QML_PRIVATE_API_VERSION 7 +#define Q_QML_PRIVATE_API_VERSION 8 #endif // QQMLAPIVERSION_P_H diff --git a/src/qml/common/qqmljsdiagnosticmessage_p.h b/src/qml/common/qqmljsdiagnosticmessage_p.h index 763332ba76..9f5380ae0c 100644 --- a/src/qml/common/qqmljsdiagnosticmessage_p.h +++ b/src/qml/common/qqmljsdiagnosticmessage_p.h @@ -58,6 +58,8 @@ // QQmlSourceLocation -> line/column change. #include +#include "qqmljssourcelocation_p.h" + QT_BEGIN_NAMESPACE namespace QQmlJS { @@ -65,8 +67,7 @@ struct DiagnosticMessage { QString message; QtMsgType type = QtCriticalMsg; - quint32 line = 0; - quint32 column = 0; + SourceLocation loc; bool isError() const { diff --git a/src/qml/common/qqmljssourcelocation_p.h b/src/qml/common/qqmljssourcelocation_p.h new file mode 100644 index 0000000000..7c75541eb1 --- /dev/null +++ b/src/qml/common/qqmljssourcelocation_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml 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$ +** +****************************************************************************/ + +#ifndef QQMLJSSOURCELOCATION_P_H +#define QQMLJSSOURCELOCATION_P_H + +#include + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +class SourceLocation +{ +public: + explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) + : offset(offset), length(length), + startLine(line), startColumn(column) + { } + + bool isValid() const { return length != 0; } + + quint32 begin() const { return offset; } + quint32 end() const { return offset + length; } + +// attributes + // ### encode + quint32 offset; + quint32 length; + quint32 startLine; + quint32 startColumn; +}; + +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index a3ee431e90..f43d7bc06f 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -169,7 +169,7 @@ QV4::CompiledData::BuiltinType Parameter::stringToBuiltinType(const QString &typ return QV4::CompiledData::BuiltinType::InvalidBuiltin; } -void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::AST::SourceLocation &loc) +void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::SourceLocation &loc) { inheritedTypeNameIndex = typeNameIndex; @@ -193,7 +193,7 @@ void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, cons declarationsOverride = nullptr; } -QString IRBuilder::sanityCheckFunctionNames(Object *obj, const QSet &illegalNames, QQmlJS::AST::SourceLocation *errorLocation) +QString IRBuilder::sanityCheckFunctionNames(Object *obj, const QSet &illegalNames, QQmlJS::SourceLocation *errorLocation) { QSet functionNames; for (auto functionit = obj->functionsBegin(); functionit != obj->functionsEnd(); ++functionit) { @@ -249,7 +249,7 @@ QString Object::appendSignal(Signal *signal) return QString(); // no error } -QString Object::appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation) +QString Object::appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation) { Object *target = declarationsOverride; if (!target) @@ -273,7 +273,7 @@ QString Object::appendProperty(Property *prop, const QString &propertyName, bool return QString(); // no error } -QString Object::appendAlias(Alias *alias, const QString &aliasName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation) +QString Object::appendAlias(Alias *alias, const QString &aliasName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation) { Object *target = declarationsOverride; if (!target) @@ -358,8 +358,8 @@ QString Object::bindingAsString(Document *doc, int scriptIndex) const QQmlJS::AST::Node *node = foe->node; if (QQmlJS::AST::ExpressionStatement *exprStmt = QQmlJS::AST::cast(node)) node = exprStmt->expression; - QQmlJS::AST::SourceLocation start = node->firstSourceLocation(); - QQmlJS::AST::SourceLocation end = node->lastSourceLocation(); + QQmlJS::SourceLocation start = node->firstSourceLocation(); + QQmlJS::SourceLocation end = node->lastSourceLocation(); return doc->code.mid(start.offset, end.offset + end.length - start.offset); } @@ -442,7 +442,7 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen // Extract errors from the parser for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) { if (m.isWarning()) { - qWarning("%s:%d : %s", qPrintable(url), m.line, qPrintable(m.message)); + qWarning("%s:%d : %s", qPrintable(url), m.loc.startLine, qPrintable(m.message)); continue; } @@ -470,7 +470,7 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen accept(program->headers); if (program->members->next) { - QQmlJS::AST::SourceLocation loc = program->members->next->firstSourceLocation(); + QQmlJS::SourceLocation loc = program->members->next->firstSourceLocation(); recordError(loc, QCoreApplication::translate("QQmlParser", "Unexpected object definition")); return false; } @@ -535,7 +535,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiObjectDefinition *node) int idx = 0; if (!defineQMLObject(&idx, node)) return false; - const QQmlJS::AST::SourceLocation nameLocation = node->qualifiedTypeNameId->identifierToken; + const QQmlJS::SourceLocation nameLocation = node->qualifiedTypeNameId->identifierToken; appendBinding(nameLocation, nameLocation, emptyStringIndex, idx); } else { int idx = 0; @@ -590,7 +590,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiScriptBinding *node) bool IRBuilder::visit(QQmlJS::AST::UiArrayBinding *node) { - const QQmlJS::AST::SourceLocation qualifiedNameLocation = node->qualifiedId->identifierToken; + const QQmlJS::SourceLocation qualifiedNameLocation = node->qualifiedId->identifierToken; Object *object = nullptr; QQmlJS::AST::UiQualifiedId *name = node->qualifiedId; if (!resolveQualifiedId(&name, &object)) @@ -655,7 +655,7 @@ void IRBuilder::accept(QQmlJS::AST::Node *node) QQmlJS::AST::Node::accept(node, this); } -bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::AST::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride) +bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride) { if (QQmlJS::AST::UiQualifiedId *lastName = qualifiedTypeNameId) { while (lastName->next) @@ -691,7 +691,7 @@ bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qu if (!errors.isEmpty()) return false; - QQmlJS::AST::SourceLocation loc; + QQmlJS::SourceLocation loc; QString error = sanityCheckFunctionNames(obj, illegalNames, &loc); if (!error.isEmpty()) { recordError(loc, error); @@ -871,7 +871,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node) const QString signalName = node->name.toString(); signal->nameIndex = registerString(signalName); - QQmlJS::AST::SourceLocation loc = node->typeToken; + QQmlJS::SourceLocation loc = node->typeToken; signal->location.line = loc.startLine; signal->location.column = loc.startColumn; @@ -954,11 +954,11 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node) const QString propName = name.toString(); property->nameIndex = registerString(propName); - QQmlJS::AST::SourceLocation loc = node->firstSourceLocation(); + QQmlJS::SourceLocation loc = node->firstSourceLocation(); property->location.line = loc.startLine; property->location.column = loc.startColumn; - QQmlJS::AST::SourceLocation errorLocation; + QQmlJS::SourceLocation errorLocation; QString error; if (illegalNames.contains(propName)) @@ -999,7 +999,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiSourceElement *node) const int index = _object->functionsAndExpressions->append(foe); Function *f = New(); - QQmlJS::AST::SourceLocation loc = funDecl->identifierToken; + QQmlJS::SourceLocation loc = funDecl->identifierToken; f->location.line = loc.startLine; f->location.column = loc.startColumn; f->index = index; @@ -1073,14 +1073,14 @@ void IRBuilder::extractVersion(const QStringRef &string, int *maj, int *min) } } -QStringRef IRBuilder::textRefAt(const QQmlJS::AST::SourceLocation &first, const QQmlJS::AST::SourceLocation &last) const +QStringRef IRBuilder::textRefAt(const QQmlJS::SourceLocation &first, const QQmlJS::SourceLocation &last) const { return QStringRef(&sourceCode, first.offset, last.offset + last.length - first.offset); } void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode) { - QQmlJS::AST::SourceLocation loc = statement->firstSourceLocation(); + QQmlJS::SourceLocation loc = statement->firstSourceLocation(); binding->valueLocation.line = loc.startLine; binding->valueLocation.column = loc.startColumn; binding->type = QV4::CompiledData::Binding::Type_Invalid; @@ -1257,7 +1257,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode) { - const QQmlJS::AST::SourceLocation qualifiedNameLocation = name->identifierToken; + const QQmlJS::SourceLocation qualifiedNameLocation = name->identifierToken; Object *object = nullptr; if (!resolveQualifiedId(&name, &object)) return; @@ -1272,7 +1272,7 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Sta void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment) { - const QQmlJS::AST::SourceLocation qualifiedNameLocation = name->identifierToken; + const QQmlJS::SourceLocation qualifiedNameLocation = name->identifierToken; Object *object = nullptr; if (!resolveQualifiedId(&name, &object, isOnAssignment)) return; @@ -1281,7 +1281,7 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, qSwap(_object, object); } -void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, +void IRBuilder::appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode) { Binding *binding = New(); @@ -1297,7 +1297,7 @@ void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLo } } -void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem, bool isOnAssignment) +void IRBuilder::appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem, bool isOnAssignment) { if (stringAt(propertyNameIndex) == QLatin1String("id")) { recordError(nameLocation, tr("Invalid component id specification")); @@ -1346,7 +1346,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node) const QString propName = node->name.toString(); alias->nameIndex = registerString(propName); - QQmlJS::AST::SourceLocation loc = node->firstSourceLocation(); + QQmlJS::SourceLocation loc = node->firstSourceLocation(); alias->location.line = loc.startLine; alias->location.column = loc.startColumn; @@ -1355,7 +1355,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node) if (!node->statement && !node->binding) COMPILE_EXCEPTION(loc, tr("No property alias location")); - QQmlJS::AST::SourceLocation rhsLoc; + QQmlJS::SourceLocation rhsLoc; if (node->binding) rhsLoc = node->binding->firstSourceLocation(); else if (node->statement) @@ -1390,7 +1390,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node) propertyValue += QLatin1Char('.') + aliasReference.at(2); alias->propertyNameIndex = registerString(propertyValue); - QQmlJS::AST::SourceLocation errorLocation; + QQmlJS::SourceLocation errorLocation; QString error; if (illegalNames.contains(propName)) @@ -1416,9 +1416,9 @@ Object *IRBuilder::bindingsTarget() const return _object; } -bool IRBuilder::setId(const QQmlJS::AST::SourceLocation &idLocation, QQmlJS::AST::Statement *value) +bool IRBuilder::setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value) { - QQmlJS::AST::SourceLocation loc = value->firstSourceLocation(); + QQmlJS::SourceLocation loc = value->firstSourceLocation(); QStringRef str; QQmlJS::AST::Node *node = value; @@ -1520,7 +1520,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O binding->type = QV4::CompiledData::Binding::Type_GroupProperty; int objIndex = 0; - if (!defineQMLObject(&objIndex, nullptr, QQmlJS::AST::SourceLocation(), nullptr, nullptr)) + if (!defineQMLObject(&objIndex, nullptr, QQmlJS::SourceLocation(), nullptr, nullptr)) return false; binding->value.objectIndex = objIndex; @@ -1543,11 +1543,10 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O return true; } -void IRBuilder::recordError(const QQmlJS::AST::SourceLocation &location, const QString &description) +void IRBuilder::recordError(const QQmlJS::SourceLocation &location, const QString &description) { QQmlJS::DiagnosticMessage error; - error.line = location.startLine; - error.column = location.startColumn; + error.loc = location; error.message = description; errors << error; } diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index 32921638af..8f6c623818 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -371,12 +371,12 @@ public: // specified object. Used for declarations inside group properties. Object *declarationsOverride; - void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::AST::SourceLocation &location = QQmlJS::AST::SourceLocation()); + void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::SourceLocation &location = QQmlJS::SourceLocation()); QString appendEnum(Enum *enumeration); QString appendSignal(Signal *signal); - QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation); - QString appendAlias(Alias *prop, const QString &aliasName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation); + QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation); + QString appendAlias(Alias *prop, const QString &aliasName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation); void appendFunction(QmlIR::Function *f); void appendInlineComponent(InlineComponent *ic); void appendRequiredPropertyExtraData(RequiredPropertyExtraData *extraData); @@ -485,24 +485,24 @@ public: void throwRecursionDepthError() override { - recordError(QQmlJS::AST::SourceLocation(), + recordError(QQmlJS::SourceLocation(), QStringLiteral("Maximum statement or expression depth exceeded")); } void accept(QQmlJS::AST::Node *node); // returns index in _objects - bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::AST::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride = nullptr); + bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride = nullptr); bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiObjectDefinition *node, Object *declarationsOverride = nullptr) { return defineQMLObject(objectIndex, node->qualifiedTypeNameId, node->qualifiedTypeNameId->firstSourceLocation(), node->initializer, declarationsOverride); } static QString asString(QQmlJS::AST::UiQualifiedId *node); QStringRef asStringRef(QQmlJS::AST::Node *node); static void extractVersion(const QStringRef &string, int *maj, int *min); - QStringRef textRefAt(const QQmlJS::AST::SourceLocation &loc) const + QStringRef textRefAt(const QQmlJS::SourceLocation &loc) const { return QStringRef(&sourceCode, loc.offset, loc.length); } - QStringRef textRefAt(const QQmlJS::AST::SourceLocation &first, - const QQmlJS::AST::SourceLocation &last) const; + QStringRef textRefAt(const QQmlJS::SourceLocation &first, + const QQmlJS::SourceLocation &last) const; void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode); @@ -511,24 +511,24 @@ public: void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode); void appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment = false); - void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, - const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, + void appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, + const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode); - void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, - const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, + void appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, + const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem = false, bool isOnAssignment = false); bool appendAlias(QQmlJS::AST::UiPublicMember *node); Object *bindingsTarget() const; - bool setId(const QQmlJS::AST::SourceLocation &idLocation, QQmlJS::AST::Statement *value); + bool setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value); // resolves qualified name (font.pixelSize for example) and returns the last name along // with the object any right-hand-side of a binding should apply to. bool resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, Object **object, bool onAssignment = false); - void recordError(const QQmlJS::AST::SourceLocation &location, const QString &description); + void recordError(const QQmlJS::SourceLocation &location, const QString &description); quint32 registerString(const QString &str) const { return jsGenerator->registerString(str); } template _Tp *New() { return pool->New<_Tp>(); } @@ -538,7 +538,7 @@ public: static bool isStatementNodeScript(QQmlJS::AST::Statement *statement); static bool isRedundantNullInitializerForPropertyDeclaration(Property *property, QQmlJS::AST::Statement *statement); - QString sanityCheckFunctionNames(Object *obj, const QSet &illegalNames, QQmlJS::AST::SourceLocation *errorLocation); + QString sanityCheckFunctionNames(Object *obj, const QSet &illegalNames, QQmlJS::SourceLocation *errorLocation); QList errors; diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp index 7df1614ffe..f8a41edb6a 100644 --- a/src/qml/compiler/qv4bytecodegenerator.cpp +++ b/src/qml/compiler/qv4bytecodegenerator.cpp @@ -45,7 +45,7 @@ QT_USE_NAMESPACE using namespace QV4; using namespace Moth; -void BytecodeGenerator::setLocation(const QQmlJS::AST::SourceLocation &loc) +void BytecodeGenerator::setLocation(const QQmlJS::SourceLocation &loc) { currentLine = static_cast(loc.startLine); } diff --git a/src/qml/compiler/qv4bytecodegenerator_p.h b/src/qml/compiler/qv4bytecodegenerator_p.h index 8c509dd9f1..1895a34a68 100644 --- a/src/qml/compiler/qv4bytecodegenerator_p.h +++ b/src/qml/compiler/qv4bytecodegenerator_p.h @@ -56,10 +56,8 @@ QT_BEGIN_NAMESPACE namespace QQmlJS { -namespace AST { class SourceLocation; } -} namespace QV4 { @@ -244,7 +242,7 @@ QT_WARNING_POP - void setLocation(const QQmlJS::AST::SourceLocation &loc); + void setLocation(const QQmlJS::SourceLocation &loc); ExceptionHandler *exceptionHandler() const { return currentExceptionHandler; diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index d61456f38d..4588690307 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -3821,8 +3821,7 @@ void Codegen::throwError(ErrorType errorType, const SourceLocation &loc, const Q _errorType = errorType; _error.message = detail; - _error.line = loc.startLine; - _error.column = loc.startColumn; + _error.loc = loc; } void Codegen::throwSyntaxError(const SourceLocation &loc, const QString &detail) @@ -4105,7 +4104,7 @@ Codegen::Reference Codegen::Reference::asLValue() const case Accumulator: Q_UNREACHABLE(); case Super: - codegen->throwSyntaxError(AST::SourceLocation(), QStringLiteral("Super lvalues not implemented.")); + codegen->throwSyntaxError(SourceLocation(), QStringLiteral("Super lvalues not implemented.")); return *this; case Member: if (!propertyBase.isStackSlot()) { diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index 82a4fc3289..255698d790 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -661,12 +661,12 @@ protected: bool visit(QQmlJS::AST::UiSourceElement *ast) override; bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(const Reference &r, - const QQmlJS::AST::SourceLocation &loc); - virtual void throwSyntaxError(const QQmlJS::AST::SourceLocation &loc, const QString &detail); - virtual void throwReferenceError(const QQmlJS::AST::SourceLocation &loc, const QString &detail); + const QQmlJS::SourceLocation &loc); + virtual void throwSyntaxError(const QQmlJS::SourceLocation &loc, const QString &detail); + virtual void throwReferenceError(const QQmlJS::SourceLocation &loc, const QString &detail); void throwRecursionDepthError() override { - throwSyntaxError(QQmlJS::AST::SourceLocation(), + throwSyntaxError(QQmlJS::SourceLocation(), QStringLiteral("Maximum statement or expression depth exceeded")); } @@ -700,7 +700,7 @@ public: Reference referenceForName( const QString &name, bool lhs, - const QQmlJS::AST::SourceLocation &accessLocation = QQmlJS::AST::SourceLocation()); + const QQmlJS::SourceLocation &accessLocation = QQmlJS::SourceLocation()); QV4::CompiledData::CompilationUnit generateCompilationUnit(bool generateUnitData = true); static QV4::CompiledData::CompilationUnit compileModule( @@ -810,7 +810,7 @@ protected: private: VolatileMemoryLocations scanVolatileMemoryLocations(QQmlJS::AST::Node *ast); void handleConstruct(const Reference &base, QQmlJS::AST::ArgumentList *args); - void throwError(ErrorType errorType, const QQmlJS::AST::SourceLocation &loc, + void throwError(ErrorType errorType, const QQmlJS::SourceLocation &loc, const QString &detail); }; diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp index 88837b0feb..872fc94dc9 100644 --- a/src/qml/compiler/qv4compilercontext.cpp +++ b/src/qml/compiler/qv4compilercontext.cpp @@ -45,6 +45,7 @@ QT_USE_NAMESPACE using namespace QV4; using namespace QV4::Compiler; using namespace QQmlJS::AST; +using namespace QQmlJS; QT_BEGIN_NAMESPACE @@ -86,7 +87,7 @@ bool Context::Member::requiresTDZCheck(const SourceLocation &accessLocation, boo } bool Context::addLocalVar(const QString &name, Context::MemberType type, VariableScope scope, FunctionExpression *function, - const QQmlJS::AST::SourceLocation &endOfInitializer) + const QQmlJS::SourceLocation &endOfInitializer) { // ### can this happen? if (name.isEmpty()) @@ -122,7 +123,7 @@ bool Context::addLocalVar(const QString &name, Context::MemberType type, Variabl return true; } -Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::AST::SourceLocation &accessLocation) +Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::SourceLocation &accessLocation) { int scope = 0; Context *c = this; diff --git a/src/qml/compiler/qv4compilercontext_p.h b/src/qml/compiler/qv4compilercontext_p.h index 8c124ac409..4a14009c35 100644 --- a/src/qml/compiler/qv4compilercontext_p.h +++ b/src/qml/compiler/qv4compilercontext_p.h @@ -183,10 +183,10 @@ struct Context { QQmlJS::AST::VariableScope scope = QQmlJS::AST::VariableScope::Var; mutable bool canEscape = false; QQmlJS::AST::FunctionExpression *function = nullptr; - QQmlJS::AST::SourceLocation endOfInitializerLocation; + QQmlJS::SourceLocation endOfInitializerLocation; bool isLexicallyScoped() const { return this->scope != QQmlJS::AST::VariableScope::Var; } - bool requiresTDZCheck(const QQmlJS::AST::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const; + bool requiresTDZCheck(const QQmlJS::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const; }; typedef QMap MemberMap; @@ -227,7 +227,7 @@ struct Context { bool isWithBlock = false; bool isCatchBlock = false; QString caughtVariable; - QQmlJS::AST::SourceLocation lastBlockInitializerLocation; + QQmlJS::SourceLocation lastBlockInitializerLocation; enum UsesArgumentsObject { ArgumentsObjectUnknown, @@ -331,7 +331,7 @@ struct Context { } bool addLocalVar(const QString &name, MemberType contextType, QQmlJS::AST::VariableScope scope, QQmlJS::AST::FunctionExpression *function = nullptr, - const QQmlJS::AST::SourceLocation &endOfInitializer = QQmlJS::AST::SourceLocation()); + const QQmlJS::SourceLocation &endOfInitializer = QQmlJS::SourceLocation()); struct ResolvedName { enum Type { @@ -348,10 +348,10 @@ struct Context { bool requiresTDZCheck = false; int scope = -1; int index = -1; - QQmlJS::AST::SourceLocation endOfDeclarationLocation; + QQmlJS::SourceLocation endOfDeclarationLocation; bool isValid() const { return type != Unresolved; } }; - ResolvedName resolveName(const QString &name, const QQmlJS::AST::SourceLocation &accessLocation); + ResolvedName resolveName(const QString &name, const QQmlJS::SourceLocation &accessLocation); void emitBlockHeader(Compiler::Codegen *codegen); void emitBlockFooter(Compiler::Codegen *codegen); diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index ab0ebf3d4b..a1ddee8234 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -55,7 +55,7 @@ using namespace QV4::Compiler; using namespace QQmlJS; using namespace QQmlJS::AST; -static CompiledData::Location location(const QQmlJS::AST::SourceLocation &astLocation) +static CompiledData::Location location(const QQmlJS::SourceLocation &astLocation) { CompiledData::Location target; target.line = astLocation.startLine; @@ -129,7 +129,7 @@ void ScanFunctions::checkDirectivePrologue(StatementList *ast) } } -void ScanFunctions::checkName(const QStringRef &name, const SourceLocation &loc) +void ScanFunctions::checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc) { if (_context->isStrict) { if (name == QLatin1String("implements") @@ -330,7 +330,7 @@ bool ScanFunctions::visit(PatternElement *ast) BoundNames names; ast->boundNames(&names); - QQmlJS::AST::SourceLocation lastInitializerLocation = ast->lastSourceLocation(); + QQmlJS::SourceLocation lastInitializerLocation = ast->lastSourceLocation(); if (_context->lastBlockInitializerLocation.isValid()) lastInitializerLocation = _context->lastBlockInitializerLocation; diff --git a/src/qml/compiler/qv4compilerscanfunctions_p.h b/src/qml/compiler/qv4compilerscanfunctions_p.h index 2de80eac44..e39aa2454e 100644 --- a/src/qml/compiler/qv4compilerscanfunctions_p.h +++ b/src/qml/compiler/qv4compilerscanfunctions_p.h @@ -97,7 +97,7 @@ protected: void checkDirectivePrologue(QQmlJS::AST::StatementList *ast); - void checkName(const QStringRef &name, const QQmlJS::AST::SourceLocation &loc); + void checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc); bool visit(QQmlJS::AST::Program *ast) override; void endVisit(QQmlJS::AST::Program *) override; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index e9cc789607..86f0d6d83c 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1910,10 +1910,10 @@ QQmlRefPointer ExecutionEngine::compileModule( sourceCode, sourceTimeStamp, &diagnostics); for (const QQmlJS::DiagnosticMessage &m : diagnostics) { if (m.isError()) { - throwSyntaxError(m.message, url.toString(), m.line, m.column); + throwSyntaxError(m.message, url.toString(), m.loc.startLine, m.loc.startColumn); return nullptr; } else { - qWarning() << url << ':' << m.line << ':' << m.column + qWarning() << url << ':' << m.loc.startLine << ':' << m.loc.startColumn << ": warning: " << m.message; } } diff --git a/src/qml/jsruntime/qv4runtimecodegen.cpp b/src/qml/jsruntime/qv4runtimecodegen.cpp index 162d75db63..b7737982b7 100644 --- a/src/qml/jsruntime/qv4runtimecodegen.cpp +++ b/src/qml/jsruntime/qv4runtimecodegen.cpp @@ -67,7 +67,7 @@ void RuntimeCodegen::generateFromFunctionExpression(const QString &fileName, _module->rootContext = _module->functions.at(index); } -void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QString &detail) +void RuntimeCodegen::throwSyntaxError(const SourceLocation &loc, const QString &detail) { if (hasError()) return; @@ -76,7 +76,7 @@ void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QStr engine->throwSyntaxError(detail, _module->fileName, loc.startLine, loc.startColumn); } -void RuntimeCodegen::throwReferenceError(const AST::SourceLocation &loc, const QString &detail) +void RuntimeCodegen::throwReferenceError(const SourceLocation &loc, const QString &detail) { if (hasError()) return; diff --git a/src/qml/jsruntime/qv4runtimecodegen_p.h b/src/qml/jsruntime/qv4runtimecodegen_p.h index 71aaf1fb55..d3a30ce35d 100644 --- a/src/qml/jsruntime/qv4runtimecodegen_p.h +++ b/src/qml/jsruntime/qv4runtimecodegen_p.h @@ -69,8 +69,8 @@ public: QQmlJS::AST::FunctionExpression *ast, Compiler::Module *module); - void throwSyntaxError(const QQmlJS::AST::SourceLocation &loc, const QString &detail) override; - void throwReferenceError(const QQmlJS::AST::SourceLocation &loc, const QString &detail) override; + void throwSyntaxError(const QQmlJS::SourceLocation &loc, const QString &detail) override; + void throwReferenceError(const QQmlJS::SourceLocation &loc, const QString &detail) override; private: ExecutionEngine *engine; diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 2fab9e4b7b..2add1222ea 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -109,10 +110,10 @@ void Script::parse() const auto diagnosticMessages = parser.diagnosticMessages(); for (const DiagnosticMessage &m : diagnosticMessages) { if (m.isError()) { - valueScope.engine->throwSyntaxError(m.message, sourceFile, m.line, m.column); + valueScope.engine->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn); return; } else { - qWarning() << sourceFile << ':' << m.line << ':' << m.column + qWarning() << sourceFile << ':' << m.loc.startLine << ':' << m.loc.startColumn << ": warning: " << m.message; } } @@ -209,8 +210,8 @@ QV4::CompiledData::CompilationUnit Script::precompile( const auto v4Error = cg.error(); QQmlError error; error.setUrl(cg.url()); - error.setLine(v4Error.line); - error.setColumn(v4Error.column); + error.setLine(qmlConvertSourceCoordinate(v4Error.loc.startLine)); + error.setColumn(qmlConvertSourceCoordinate(v4Error.loc.startColumn)); error.setDescription(v4Error.message); reportedErrors->append(error); } diff --git a/src/qml/parser/parser.pri b/src/qml/parser/parser.pri index e15730f5d1..1ac867fe59 100644 --- a/src/qml/parser/parser.pri +++ b/src/qml/parser/parser.pri @@ -6,8 +6,7 @@ HEADERS += \ $$PWD/qqmljslexer_p.h \ $$PWD/qqmljsglobal_p.h \ $$PWD/qqmljskeywords_p.h \ - $$PWD/qqmljsengine_p.h \ - $$PWD/qqmljssourcelocation_p.h + $$PWD/qqmljsengine_p.h SOURCES += \ $$PWD/qqmljsast.cpp \ diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index f6d8bcf9c3..e4b7198b30 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -390,10 +390,10 @@ public: { return diagnosticMessage().message; } inline int errorLineNumber() const - { return diagnosticMessage().line; } + { return diagnosticMessage().loc.startLine; } inline int errorColumnNumber() const - { return diagnosticMessage().column; } + { return diagnosticMessage().loc.startColumn; } protected: bool parse(int startToken); @@ -409,7 +409,7 @@ protected: inline QStringRef &rawStringRef(int index) { return rawString_stack [tos + index - 1]; } - inline AST::SourceLocation &loc(int index) + inline SourceLocation &loc(int index) { return location_stack [tos + index - 1]; } AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); @@ -417,21 +417,20 @@ protected: void pushToken(int token); int lookaheadToken(Lexer *lexer); - static DiagnosticMessage compileError(const AST::SourceLocation &location, + static DiagnosticMessage compileError(const SourceLocation &location, const QString &message, QtMsgType kind = QtCriticalMsg) { DiagnosticMessage error; - error.line = location.startLine; - error.column = location.startColumn; + error.loc = location; error.message = message; error.type = kind; return error; } - void syntaxError(const AST::SourceLocation &location, const char *message) { + void syntaxError(const SourceLocation &location, const char *message) { diagnostic_messages.append(compileError(location, QLatin1String(message))); } - void syntaxError(const AST::SourceLocation &location, const QString &message) { + void syntaxError(const SourceLocation &location, const QString &message) { diagnostic_messages.append(compileError(location, message)); } @@ -444,7 +443,7 @@ protected: int stack_size = 0; Value *sym_stack = nullptr; int *state_stack = nullptr; - AST::SourceLocation *location_stack = nullptr; + SourceLocation *location_stack = nullptr; QVector string_stack; QVector rawString_stack; @@ -456,7 +455,7 @@ protected: struct SavedToken { int token; double dval; - AST::SourceLocation loc; + SourceLocation loc; QStringRef spell; QStringRef raw; }; @@ -465,8 +464,8 @@ protected: double yylval = 0.; QStringRef yytokenspell; QStringRef yytokenraw; - AST::SourceLocation yylloc; - AST::SourceLocation yyprevlloc; + SourceLocation yylloc; + SourceLocation yyprevlloc; SavedToken token_buffer[TOKEN_BUFFER_SIZE]; SavedToken *first_token = nullptr; @@ -479,7 +478,7 @@ protected: CE_ParenthesizedExpression, CE_FormalParameterList }; - AST::SourceLocation coverExpressionErrorLocation; + SourceLocation coverExpressionErrorLocation; CoverExpressionType coverExpressionType = CE_Invalid; QList diagnostic_messages; @@ -524,7 +523,7 @@ void Parser::reallocateStack() sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); - location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); + location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(SourceLocation))); string_stack.resize(stack_size); rawString_stack.resize(stack_size); } @@ -544,9 +543,9 @@ Parser::~Parser() } } -static inline AST::SourceLocation location(Lexer *lexer) +static inline SourceLocation location(Lexer *lexer) { - AST::SourceLocation loc; + SourceLocation loc; loc.offset = lexer->tokenOffset(); loc.length = lexer->tokenLength(); loc.startLine = lexer->tokenStartLine(); @@ -557,7 +556,7 @@ static inline AST::SourceLocation location(Lexer *lexer) AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) { QVarLengthArray nameIds; - QVarLengthArray locations; + QVarLengthArray locations; AST::ExpressionNode *it = expr; while (AST::FieldMemberExpression *m = AST::cast(it)) { @@ -2842,7 +2841,7 @@ AssignmentExpression_In: LeftHandSideExpression T_EQ AssignmentExpression_In; case $rule_number: { // need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral if (AST::Pattern *p = sym(1).Expression->patternCast()) { - AST::SourceLocation errorLoc; + SourceLocation errorLoc; QString errorMsg; if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) { syntaxError(errorLoc, errorMsg); @@ -3508,7 +3507,7 @@ IterationStatement: T_FOR T_LPAREN LeftHandSideExpression InOrOf Expression_In T case $rule_number: { // need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral if (AST::Pattern *p = sym(3).Expression->patternCast()) { - AST::SourceLocation errorLoc; + SourceLocation errorLoc; QString errorMsg; if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) { syntaxError(errorLoc, errorMsg); diff --git a/src/qml/parser/qqmljsastfwd_p.h b/src/qml/parser/qqmljsastfwd_p.h index 8df0be7590..ef37e8072f 100644 --- a/src/qml/parser/qqmljsastfwd_p.h +++ b/src/qml/parser/qqmljsastfwd_p.h @@ -41,7 +41,7 @@ #define QQMLJSAST_FWD_P_H #include "qqmljsglobal_p.h" -#include "qqmljssourcelocation_p.h" +#include #include diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp index bb27f3992e..cb6b0375e6 100644 --- a/src/qml/parser/qqmljsengine_p.cpp +++ b/src/qml/parser/qqmljsengine_p.cpp @@ -123,9 +123,9 @@ void Engine::setCode(const QString &code) { _code = code; } void Engine::addComment(int pos, int len, int line, int col) -{ if (len > 0) _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col)); } +{ if (len > 0) _comments.append(QQmlJS::SourceLocation(pos, len, line, col)); } -QList Engine::comments() const +QList Engine::comments() const { return _comments; } Lexer *Engine::lexer() const diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h index 8a3e2db6a1..a34922fa1e 100644 --- a/src/qml/parser/qqmljsengine_p.h +++ b/src/qml/parser/qqmljsengine_p.h @@ -52,7 +52,7 @@ // #include "qqmljsglobal_p.h" -#include "qqmljssourcelocation_p.h" +#include #include @@ -97,7 +97,7 @@ class QML_PARSER_EXPORT Engine Lexer *_lexer; Directives *_directives; MemoryPool _pool; - QList _comments; + QList _comments; QString _extraCode; QString _code; @@ -109,7 +109,7 @@ public: const QString &code() const { return _code; } void addComment(int pos, int len, int line, int col); - QList comments() const; + QList comments() const; Lexer *lexer() const; void setLexer(Lexer *lexer); diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp index 0c61679f0b..243fc5bd30 100644 --- a/src/qml/parser/qqmljslexer.cpp +++ b/src/qml/parser/qqmljslexer.cpp @@ -1480,8 +1480,8 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error) { auto setError = [error, this](QString message) { error->message = std::move(message); - error->line = tokenStartLine(); - error->column = tokenStartColumn(); + error->loc.startLine = tokenStartLine(); + error->loc.startColumn = tokenStartColumn(); }; QScopedValueRollback directivesGuard(_handlingDirectives, true); @@ -1596,8 +1596,8 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error) else setError(QCoreApplication::translate("QQmlParser", "Module import requires a qualifier")); if (tokenStartLine() != lineNumber) { - error->line = lineNumber; - error->line = column; + error->loc.startLine = lineNumber; + error->loc.startColumn = column; } return false; // expected `as' } diff --git a/src/qml/parser/qqmljssourcelocation_p.h b/src/qml/parser/qqmljssourcelocation_p.h deleted file mode 100644 index d76e701d49..0000000000 --- a/src/qml/parser/qqmljssourcelocation_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml 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$ -** -****************************************************************************/ - -#ifndef QQMLJSSOURCELOCATION_P_H -#define QQMLJSSOURCELOCATION_P_H - -#include "qqmljsglobal_p.h" - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_NAMESPACE - -namespace QQmlJS { namespace AST { - -class SourceLocation -{ -public: - explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) - : offset(offset), length(length), - startLine(line), startColumn(column) - { } - - bool isValid() const { return length != 0; } - - quint32 begin() const { return offset; } - quint32 end() const { return offset + length; } - -// attributes - // ### encode - quint32 offset; - quint32 length; - quint32 startLine; - quint32 startColumn; -}; - -} } // namespace AST - -QT_END_NAMESPACE - -#endif diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 279998b5de..ede2816d5f 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -50,6 +50,7 @@ #include "qqmlincubator.h" #include "qqmlincubator_p.h" #include +#include #include #include @@ -1424,8 +1425,8 @@ QQmlError QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(const RequiredP } error.setDescription(description); error.setUrl(unsetRequiredProperty.fileUrl); - error.setLine(unsetRequiredProperty.location.line); - error.setColumn(unsetRequiredProperty.location.column); + error.setLine(qmlConvertSourceCoordinate(unsetRequiredProperty.location.line)); + error.setColumn(qmlConvertSourceCoordinate(unsetRequiredProperty.location.column)); return error; } diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp index ecd5020482..5e6e1187e2 100644 --- a/src/qml/qml/qqmlcustomparser.cpp +++ b/src/qml/qml/qqmlcustomparser.cpp @@ -40,6 +40,7 @@ #include "qqmlcustomparser_p.h" #include +#include #include @@ -100,10 +101,10 @@ void QQmlCustomParser::clearErrors() */ void QQmlCustomParser::error(const QV4::CompiledData::Location &location, const QString &description) { - QQmlJS::DiagnosticMessage error; - error.line = location.line; - error.column = location.column; - error.message = description; + QQmlError error; + error.setLine(qmlConvertSourceCoordinate(location.line)); + error.setColumn(qmlConvertSourceCoordinate(location.column)); + error.setDescription(description); exceptions << error; } diff --git a/src/qml/qml/qqmlcustomparser_p.h b/src/qml/qml/qqmlcustomparser_p.h index abac90d6ad..4eb709228e 100644 --- a/src/qml/qml/qqmlcustomparser_p.h +++ b/src/qml/qml/qqmlcustomparser_p.h @@ -83,7 +83,7 @@ public: virtual void verifyBindings(const QQmlRefPointer &, const QList &) = 0; virtual void applyBindings(QObject *, const QQmlRefPointer &, const QList &) = 0; - QVector errors() const { return exceptions; } + QVector errors() const { return exceptions; } protected: void error(const QV4::CompiledData::Binding *binding, const QString& description) @@ -97,7 +97,7 @@ protected: const QMetaObject *resolveType(const QString&) const; private: - QVector exceptions; + QVector exceptions; QQmlEnginePrivate *engine; const QQmlPropertyValidator *validator; Flags m_flags; diff --git a/src/qml/qml/qqmldatablob.cpp b/src/qml/qml/qqmldatablob.cpp index 1ab6002f0a..b22e46b69c 100644 --- a/src/qml/qml/qqmldatablob.cpp +++ b/src/qml/qml/qqmldatablob.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -306,22 +307,19 @@ void QQmlDataBlob::setError(const QList &errors) void QQmlDataBlob::setError(const QQmlJS::DiagnosticMessage &error) { QQmlError e; - e.setColumn(error.column); - e.setLine(error.line); + e.setColumn(qmlConvertSourceCoordinate(error.loc.startColumn)); + e.setLine(qmlConvertSourceCoordinate(error.loc.startLine)); e.setDescription(error.message); e.setUrl(url()); setError(e); } -void QQmlDataBlob::setError(const QVector &errors) +void QQmlDataBlob::setError(const QVector &errors) { QList finalErrors; finalErrors.reserve(errors.count()); for (const auto &error : errors) { - QQmlError e; - e.setColumn(error.column); - e.setLine(error.line); - e.setDescription(error.message); + QQmlError e = error; e.setUrl(url()); finalErrors << e; } diff --git a/src/qml/qml/qqmldatablob_p.h b/src/qml/qml/qqmldatablob_p.h index 0450e94c02..cc066d29a1 100644 --- a/src/qml/qml/qqmldatablob_p.h +++ b/src/qml/qml/qqmldatablob_p.h @@ -132,7 +132,7 @@ protected: void setError(const QQmlError &); void setError(const QList &errors); void setError(const QQmlJS::DiagnosticMessage &error); - void setError(const QVector &errors); + void setError(const QVector &errors); void setError(const QString &description); void addDependency(QQmlDataBlob *); diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index ad57b1f74b..5823ff8963 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -57,6 +57,7 @@ #include "qqmlnotifier_p.h" #include "qqmlincubator.h" #include "qqmlabstracturlinterceptor.h" +#include "qqmlsourcecoordinate_p.h" #include #include #include @@ -2124,15 +2125,15 @@ QList QQmlEnginePrivate::qmlErrorFromDiagnostics( QList errors; for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) { if (m.isWarning()) { - qWarning("%s:%d : %s", qPrintable(fileName), m.line, qPrintable(m.message)); + qWarning("%s:%d : %s", qPrintable(fileName), m.loc.startLine, qPrintable(m.message)); continue; } QQmlError error; error.setUrl(QUrl(fileName)); error.setDescription(m.message); - error.setLine(m.line); - error.setColumn(m.column); + error.setLine(qmlConvertSourceCoordinate(m.loc.startLine)); + error.setColumn(qmlConvertSourceCoordinate(m.loc.startColumn)); errors << error; } return errors; diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp index 0b94ed3b49..da585d2126 100644 --- a/src/qml/qml/qqmlerror.cpp +++ b/src/qml/qml/qqmlerror.cpp @@ -77,12 +77,15 @@ QT_BEGIN_NAMESPACE \sa QQuickView::errors(), QQmlComponent::errors() */ -class QQmlErrorPrivate : public QQmlJS::DiagnosticMessage +class QQmlErrorPrivate { public: - QQmlErrorPrivate() { type = QtWarningMsg; } QUrl url; QPointer object; + QString message; + QtMsgType type = QtWarningMsg; + int line = -1; + int column = -1; }; /*! @@ -185,7 +188,7 @@ void QQmlError::setDescription(const QString &description) int QQmlError::line() const { if (d) - return qmlConvertSourceCoordinate(d->line); + return d->line; return -1; } @@ -196,7 +199,7 @@ void QQmlError::setLine(int line) { if (!d) d = new QQmlErrorPrivate; - d->line = qmlConvertSourceCoordinate(line); + d->line = line; } /*! @@ -205,7 +208,7 @@ void QQmlError::setLine(int line) int QQmlError::column() const { if (d) - return qmlConvertSourceCoordinate(d->column); + return d->column; return -1; } @@ -216,7 +219,7 @@ void QQmlError::setColumn(int column) { if (!d) d = new QQmlErrorPrivate; - d->column = qmlConvertSourceCoordinate(column); + d->column = column; } /*! diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp index dd401bdb20..7204d5ccd2 100644 --- a/src/qml/qml/qqmlinfo.cpp +++ b/src/qml/qml/qqmlinfo.cpp @@ -44,6 +44,7 @@ #include "qqmlcontext_p.h" #include "qqmlmetatype_p.h" #include "qqmlengine_p.h" +#include "qqmlsourcecoordinate_p.h" #include @@ -218,8 +219,8 @@ QQmlInfo::~QQmlInfo() QQmlData *ddata = QQmlData::get(object, false); if (ddata && ddata->outerContext) { error.setUrl(ddata->outerContext->url()); - error.setLine(ddata->lineNumber); - error.setColumn(ddata->columnNumber); + error.setLine(qmlConvertSourceCoordinate(ddata->lineNumber)); + error.setColumn(qmlConvertSourceCoordinate(ddata->columnNumber)); } } diff --git a/src/qml/qml/qqmlirloader.cpp b/src/qml/qml/qqmlirloader.cpp index b284e44fdf..f66094fad7 100644 --- a/src/qml/qml/qqmlirloader.cpp +++ b/src/qml/qml/qqmlirloader.cpp @@ -78,14 +78,14 @@ struct FakeExpression : public QQmlJS::AST::NullExpression : location(start, length) {} - virtual QQmlJS::AST::SourceLocation firstSourceLocation() const + virtual QQmlJS::SourceLocation firstSourceLocation() const { return location; } - virtual QQmlJS::AST::SourceLocation lastSourceLocation() const + virtual QQmlJS::SourceLocation lastSourceLocation() const { return location; } private: - QQmlJS::AST::SourceLocation location; + QQmlJS::SourceLocation location; }; QmlIR::Object *QQmlIRLoader::loadObject(const QV4::CompiledData::Object *serializedObject) diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 8661ebcc13..6a9ef06159 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -50,6 +50,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -72,8 +73,8 @@ bool QQmlDelayedError::addError(QQmlEnginePrivate *e) void QQmlDelayedError::setErrorLocation(const QQmlSourceLocation &sourceLocation) { m_error.setUrl(QUrl(sourceLocation.sourceFile)); - m_error.setLine(sourceLocation.line); - m_error.setColumn(sourceLocation.column); + m_error.setLine(qmlConvertSourceCoordinate(sourceLocation.line)); + m_error.setColumn(qmlConvertSourceCoordinate(sourceLocation.column)); } void QQmlDelayedError::setErrorDescription(const QString &description) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index aff982012d..76f387bbdc 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -1135,8 +1136,8 @@ void QQmlObjectCreator::recordError(const QV4::CompiledData::Location &location, { QQmlError error; error.setUrl(compilationUnit->url()); - error.setLine(location.line); - error.setColumn(location.column); + error.setLine(qmlConvertSourceCoordinate(location.line)); + error.setColumn(qmlConvertSourceCoordinate(location.column)); error.setDescription(description); errors << error; } diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index d99f5b6e98..5669f9e13d 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -56,19 +56,20 @@ #include #include #include +#include #include #include QT_BEGIN_NAMESPACE -inline QQmlJS::DiagnosticMessage qQmlCompileError(const QV4::CompiledData::Location &location, +inline QQmlError qQmlCompileError(const QV4::CompiledData::Location &location, const QString &description) { - QQmlJS::DiagnosticMessage error; - error.line = location.line; - error.column = location.column; - error.message = description; + QQmlError error; + error.setLine(qmlConvertSourceCoordinate(location.line)); + error.setColumn(qmlConvertSourceCoordinate(location.column)); + error.setDescription(description); return error; } @@ -117,16 +118,16 @@ public: const ObjectContainer *objectContainer, const QQmlImports *imports, const QByteArray &typeClassName); - QQmlJS::DiagnosticMessage buildMetaObjects(); + QQmlError buildMetaObjects(); enum class VMEMetaObjectIsRequired { Maybe, Always }; protected: - QQmlJS::DiagnosticMessage buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired); - QQmlRefPointer propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlJS::DiagnosticMessage *error) const; - QQmlJS::DiagnosticMessage createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer &baseTypeCache); + QQmlError buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired); + QQmlRefPointer propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const; + QQmlError createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer &baseTypeCache); int metaTypeForParameter(const QV4::CompiledData::ParameterType ¶m, QString *customTypeName = nullptr); @@ -159,7 +160,7 @@ inline QQmlPropertyCacheCreator::QQmlPropertyCacheCreator(QQmlP } template -inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buildMetaObjects() +inline QQmlError QQmlPropertyCacheCreator::buildMetaObjects() { using namespace icutils; QQmlBindingInstantiationContext context; @@ -186,8 +187,8 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil auto nodesSorted = topoSort(nodes, adjacencyList, hasCycle); if (hasCycle) { - QQmlJS::DiagnosticMessage diag; - diag.message = QLatin1String("Inline components form a cycle!"); + QQmlError diag; + diag.setDescription(QLatin1String("Inline components form a cycle!")); return diag; } @@ -201,7 +202,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil QByteArray icTypeName { objectContainer->stringAt(ic.nameIndex).toUtf8() }; QScopedValueRollback nameChange {typeClassName, icTypeName}; QScopedValueRollback rootChange {currentRoot, ic.objectIndex}; - QQmlJS::DiagnosticMessage diag = buildMetaObjectRecursively(ic.objectIndex, context, VMEMetaObjectIsRequired::Always); + QQmlError diag = buildMetaObjectRecursively(ic.objectIndex, context, VMEMetaObjectIsRequired::Always); if (diag.isValid()) { return diag; } @@ -213,7 +214,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil } template -inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired) +inline QQmlError QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired) { auto isAddressable = [](const QUrl &url) { const QString fileName = url.fileName(); @@ -242,7 +243,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil auto *typeRef = objectContainer->resolvedType(obj->inheritedTypeNameIndex); Q_ASSERT(typeRef); QQmlRefPointer baseTypeCache = typeRef->createPropertyCache(QQmlEnginePrivate::get(enginePrivate)); - QQmlJS::DiagnosticMessage error = createMetaObject(context.referencingObjectIndex, obj, baseTypeCache); + QQmlError error = createMetaObject(context.referencingObjectIndex, obj, baseTypeCache); if (error.isValid()) return error; } @@ -257,7 +258,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil QQmlRefPointer baseTypeCache; { - QQmlJS::DiagnosticMessage error; + QQmlError error; baseTypeCache = propertyCacheForObject(obj, context, &error); if (error.isValid()) return error; @@ -265,7 +266,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil if (baseTypeCache) { if (needVMEMetaObject) { - QQmlJS::DiagnosticMessage error = createMetaObject(objectIndex, obj, baseTypeCache); + QQmlError error = createMetaObject(objectIndex, obj, baseTypeCache); if (error.isValid()) return error; } else { @@ -287,18 +288,18 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil if (!context.resolveInstantiatingProperty()) pendingGroupPropertyBindings->append(context); - QQmlJS::DiagnosticMessage error = buildMetaObjectRecursively(binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe); + QQmlError error = buildMetaObjectRecursively(binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe); if (error.isValid()) return error; } } - QQmlJS::DiagnosticMessage noError; + QQmlError noError; return noError; } template -inline QQmlRefPointer QQmlPropertyCacheCreator::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlJS::DiagnosticMessage *error) const +inline QQmlRefPointer QQmlPropertyCacheCreator::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const { if (context.instantiatingProperty) { return context.instantiatingPropertyCache(enginePrivate); @@ -344,7 +345,7 @@ inline QQmlRefPointer QQmlPropertyCacheCreator -inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer &baseTypeCache) +inline QQmlError QQmlPropertyCacheCreator::createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer &baseTypeCache) { QQmlRefPointer cache; cache.adopt(baseTypeCache->copyAndReserve(obj->propertyCount() + obj->aliasCount(), @@ -622,7 +623,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::crea effectiveSignalIndex++; } - QQmlJS::DiagnosticMessage noError; + QQmlError noError; return noError; } @@ -670,11 +671,11 @@ public: void appendAliasPropertiesToMetaObjects(QQmlEnginePrivate *enginePriv); - QQmlJS::DiagnosticMessage appendAliasesToPropertyCache(const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv); + QQmlError appendAliasesToPropertyCache(const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv); private: void appendAliasPropertiesInMetaObjectsWithinComponent(const CompiledObject &component, int firstObjectIndex, QQmlEnginePrivate *enginePriv); - QQmlJS::DiagnosticMessage propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *rev, QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv); + QQmlError propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *rev, QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv); void collectObjectsWithAliasesRecursively(int objectIndex, QVector *objectsWithAliases) const; @@ -785,7 +786,7 @@ inline void QQmlPropertyCacheAliasCreator::collectObjectsWithAl } template -inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator::propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *minorVersion, +inline QQmlError QQmlPropertyCacheAliasCreator::propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *minorVersion, QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv) { *type = 0; @@ -896,16 +897,16 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator: propertyFlags->setIsWritable(!(alias.flags & QV4::CompiledData::Alias::IsReadOnly) && writable); propertyFlags->setIsResettable(resettable); - return QQmlJS::DiagnosticMessage(); + return QQmlError(); } template -inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator::appendAliasesToPropertyCache( +inline QQmlError QQmlPropertyCacheAliasCreator::appendAliasesToPropertyCache( const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv) { const CompiledObject &object = *objectContainer->objectAt(objectIndex); if (!object.aliasCount()) - return QQmlJS::DiagnosticMessage(); + return QQmlError(); QQmlPropertyCache *propertyCache = propertyCaches->at(objectIndex); Q_ASSERT(propertyCache); @@ -922,7 +923,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator: int type = 0; int minorVersion = 0; QQmlPropertyData::Flags propertyFlags; - QQmlJS::DiagnosticMessage error = propertyDataForAlias(component, *alias, &type, &minorVersion, &propertyFlags, enginePriv); + QQmlError error = propertyDataForAlias(component, *alias, &type, &minorVersion, &propertyFlags, enginePriv); if (error.isValid()) return error; @@ -935,7 +936,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator: type, minorVersion, effectiveSignalIndex++); } - return QQmlJS::DiagnosticMessage(); + return QQmlError(); } template diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp index c897ac8751..3587609301 100644 --- a/src/qml/qml/qqmlpropertyvalidator.cpp +++ b/src/qml/qml/qqmlpropertyvalidator.cpp @@ -73,7 +73,7 @@ QQmlPropertyValidator::QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, c bindingPropertyDataPerObject->resize(compilationUnit->objectCount()); } -QVector QQmlPropertyValidator::validate() +QVector QQmlPropertyValidator::validate() { return validateObject(/*root object*/0, /*instantiatingBinding*/nullptr); } @@ -96,7 +96,7 @@ struct BindingFinder } }; -QVector QQmlPropertyValidator::validateObject( +QVector QQmlPropertyValidator::validateObject( int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding, bool populatingValueTypeGroupProperty) const { const QV4::CompiledData::Object *obj = compilationUnit->objectAt(objectIndex); @@ -113,7 +113,7 @@ QVector QQmlPropertyValidator::validateObject( QQmlPropertyCache *propertyCache = propertyCaches.at(objectIndex); if (!propertyCache) - return QVector(); + return QVector(); QQmlCustomParser *customParser = nullptr; if (auto typeRef = resolvedType(obj->inheritedTypeNameIndex)) { @@ -223,7 +223,7 @@ QVector QQmlPropertyValidator::validateObject( = pd && QQmlValueTypeFactory::metaObjectForMetaType(pd->propType()) && !(binding->flags & QV4::CompiledData::Binding::IsOnAssignment); - const QVector subObjectValidatorErrors + const QVector subObjectValidatorErrors = validateObject(binding->value.objectIndex, binding, populatingValueTypeGroupProperty); if (!subObjectValidatorErrors.isEmpty()) @@ -280,11 +280,11 @@ QVector QQmlPropertyValidator::validateObject( } if (binding->type < QV4::CompiledData::Binding::Type_Script) { - QQmlJS::DiagnosticMessage bindingError = validateLiteralBinding(propertyCache, pd, binding); + QQmlError bindingError = validateLiteralBinding(propertyCache, pd, binding); if (bindingError.isValid()) return recordError(bindingError); } else if (binding->type == QV4::CompiledData::Binding::Type_Object) { - QQmlJS::DiagnosticMessage bindingError = validateObjectBinding(pd, name, binding); + QQmlError bindingError = validateObjectBinding(pd, name, binding); if (bindingError.isValid()) return recordError(bindingError); } else if (binding->isGroupProperty()) { @@ -346,24 +346,24 @@ QVector QQmlPropertyValidator::validateObject( customParser->validator = nullptr; customParser->engine = nullptr; customParser->imports = (QQmlImports*)nullptr; - QVector parserErrors = customParser->errors(); + QVector parserErrors = customParser->errors(); if (!parserErrors.isEmpty()) return parserErrors; } (*bindingPropertyDataPerObject)[objectIndex] = collectedBindingPropertyData; - QVector noError; + QVector noError; return noError; } -QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const +QQmlError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const { if (property->isQList()) { return qQmlCompileError(binding->valueLocation, tr("Cannot assign primitives to lists")); } - QQmlJS::DiagnosticMessage noError; + QQmlError noError; if (property->isEnum()) { if (binding->flags & QV4::CompiledData::Binding::IsResolvedEnum) @@ -387,8 +387,8 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp if (binding->type == QV4::CompiledData::Binding::Type_Null) { QQmlError warning; warning.setUrl(compilationUnit->url()); - warning.setLine(binding->valueLocation.line); - warning.setColumn(binding->valueLocation.column); + warning.setLine(qmlConvertSourceCoordinate(binding->valueLocation.line)); + warning.setColumn(qmlConvertSourceCoordinate(binding->valueLocation.column)); warning.setDescription(error + tr(" - Assigning null to incompatible properties in QML " "is deprecated. This will become a compile error in " "future versions of Qt.")); @@ -659,23 +659,23 @@ bool QQmlPropertyValidator::canCoerce(int to, QQmlPropertyCache *fromMo) const return false; } -QVector QQmlPropertyValidator::recordError(const QV4::CompiledData::Location &location, const QString &description) const +QVector QQmlPropertyValidator::recordError(const QV4::CompiledData::Location &location, const QString &description) const { - QVector errors; + QVector errors; errors.append(qQmlCompileError(location, description)); return errors; } -QVector QQmlPropertyValidator::recordError(const QQmlJS::DiagnosticMessage &error) const +QVector QQmlPropertyValidator::recordError(const QQmlError &error) const { - QVector errors; + QVector errors; errors.append(error); return errors; } -QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *property, const QString &propertyName, const QV4::CompiledData::Binding *binding) const +QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *property, const QString &propertyName, const QV4::CompiledData::Binding *binding) const { - QQmlJS::DiagnosticMessage noError; + QQmlError noError; if (binding->flags & QV4::CompiledData::Binding::IsOnAssignment) { Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Object); diff --git a/src/qml/qml/qqmlpropertyvalidator_p.h b/src/qml/qml/qqmlpropertyvalidator_p.h index 74a1281927..281472981c 100644 --- a/src/qml/qml/qqmlpropertyvalidator_p.h +++ b/src/qml/qml/qqmlpropertyvalidator_p.h @@ -66,25 +66,24 @@ class QQmlPropertyValidator public: QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, const QQmlImports &imports, const QQmlRefPointer &compilationUnit); - QVector validate(); + QVector validate(); private: - QVector validateObject( + QVector validateObject( int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding, bool populatingValueTypeGroupProperty = false) const; - QQmlJS::DiagnosticMessage validateLiteralBinding( + QQmlError validateLiteralBinding( QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const; - QQmlJS::DiagnosticMessage validateObjectBinding( + QQmlError validateObjectBinding( QQmlPropertyData *property, const QString &propertyName, const QV4::CompiledData::Binding *binding) const; bool canCoerce(int to, QQmlPropertyCache *fromMo) const; - Q_REQUIRED_RESULT QVector recordError( + Q_REQUIRED_RESULT QVector recordError( const QV4::CompiledData::Location &location, const QString &description) const; - Q_REQUIRED_RESULT QVector recordError( - const QQmlJS::DiagnosticMessage &error) const; + Q_REQUIRED_RESULT QVector recordError(const QQmlError &error) const; QString stringAt(int index) const { return compilationUnit->stringAt(index); } QV4::ResolvedTypeReference *resolvedType(int id) const { diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp index eb103dc434..dac21f7ee7 100644 --- a/src/qml/qml/qqmlscriptblob.cpp +++ b/src/qml/qml/qqmlscriptblob.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -167,8 +168,8 @@ void QQmlScriptBlob::done() QList errors = script.script->errors(); QQmlError error; error.setUrl(url()); - error.setLine(script.location.line); - error.setColumn(script.location.column); + error.setLine(qmlConvertSourceCoordinate(script.location.line)); + error.setColumn(qmlConvertSourceCoordinate(script.location.column)); error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->urlString())); errors.prepend(error); setError(errors); diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp index d527fe0335..f4737ba99d 100644 --- a/src/qml/qml/qqmltypecompiler.cpp +++ b/src/qml/qml/qqmltypecompiler.cpp @@ -82,7 +82,7 @@ QQmlRefPointer QQmlTypeCompiler::compile() { QQmlPropertyCacheCreator propertyCacheBuilder(&m_propertyCaches, &pendingGroupPropertyBindings, engine, this, imports(), typeData->typeClassName()); - QQmlJS::DiagnosticMessage error = propertyCacheBuilder.buildMetaObjects(); + QQmlError error = propertyCacheBuilder.buildMetaObjects(); if (error.isValid()) { recordError(error); return nullptr; @@ -174,8 +174,8 @@ QQmlRefPointer QQmlTypeCompiler::compile() void QQmlTypeCompiler::recordError(const QV4::CompiledData::Location &location, const QString &description) { QQmlError error; - error.setLine(location.line); - error.setColumn(location.column); + error.setLine(qmlConvertSourceCoordinate(location.line)); + error.setColumn(qmlConvertSourceCoordinate(location.column)); error.setDescription(description); error.setUrl(url()); errors << error; @@ -185,8 +185,15 @@ void QQmlTypeCompiler::recordError(const QQmlJS::DiagnosticMessage &message) { QQmlError error; error.setDescription(message.message); - error.setLine(message.line); - error.setColumn(message.column); + error.setLine(qmlConvertSourceCoordinate(message.loc.startLine)); + error.setColumn(qmlConvertSourceCoordinate(message.loc.startColumn)); + error.setUrl(url()); + errors << error; +} + +void QQmlTypeCompiler::recordError(const QQmlError &e) +{ + QQmlError error = e; error.setUrl(url()); errors << error; } @@ -1016,7 +1023,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex) for (int objectIndex: qAsConst(_objectsWithAliases)) { - QQmlJS::DiagnosticMessage error; + QQmlError error; const auto result = resolveAliasesInObject(objectIndex, &error); if (error.isValid()) { @@ -1025,7 +1032,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex) } if (result == AllAliasesResolved) { - QQmlJS::DiagnosticMessage error = aliasCacheCreator.appendAliasesToPropertyCache(*qmlObjects->at(componentIndex), objectIndex, enginePrivate); + QQmlError error = aliasCacheCreator.appendAliasesToPropertyCache(*qmlObjects->at(componentIndex), objectIndex, enginePrivate); if (error.isValid()) { recordError(error); return false; @@ -1056,7 +1063,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex) QQmlComponentAndAliasResolver::AliasResolutionResult QQmlComponentAndAliasResolver::resolveAliasesInObject(int objectIndex, - QQmlJS::DiagnosticMessage *error) + QQmlError *error) { const QmlIR::Object * const obj = qmlObjects->at(objectIndex); if (!obj->aliasCount()) diff --git a/src/qml/qml/qqmltypecompiler_p.h b/src/qml/qml/qqmltypecompiler_p.h index 319df8673b..057dd012c6 100644 --- a/src/qml/qml/qqmltypecompiler_p.h +++ b/src/qml/qml/qqmltypecompiler_p.h @@ -100,7 +100,8 @@ public: QList compilationErrors() const { return errors; } void recordError(const QV4::CompiledData::Location &location, const QString &description); - void recordError(const QQmlJS::DiagnosticMessage &error); + void recordError(const QQmlJS::DiagnosticMessage &message); + void recordError(const QQmlError &e); int registerString(const QString &str); int registerConstant(QV4::ReturnedValue v); @@ -157,7 +158,7 @@ struct QQmlCompilePass protected: void recordError(const QV4::CompiledData::Location &location, const QString &description) const { compiler->recordError(location, description); } - void recordError(const QQmlJS::DiagnosticMessage &error) + void recordError(const QQmlError &error) { compiler->recordError(error); } QV4::ResolvedTypeReference *resolvedType(int id) const @@ -280,7 +281,7 @@ protected: AllAliasesResolved }; - AliasResolutionResult resolveAliasesInObject(int objectIndex, QQmlJS::DiagnosticMessage *error); + AliasResolutionResult resolveAliasesInObject(int objectIndex, QQmlError *error); QQmlEnginePrivate *enginePrivate; QQmlJS::MemoryPool *pool; diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index ebe4e32b48..cd4e0acf39 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -203,8 +203,8 @@ bool QQmlTypeData::tryLoadFromDiskCache() Q_ASSERT(errors.size()); QQmlError error(errors.takeFirst()); error.setUrl(m_importCache.baseUrl()); - error.setLine(import->location.line); - error.setColumn(import->location.column); + error.setLine(qmlConvertSourceCoordinate(import->location.line)); + error.setColumn(qmlConvertSourceCoordinate(import->location.column)); errors.prepend(error); // put it back on the list after filling out information. setError(errors); return false; @@ -244,7 +244,7 @@ void QQmlTypeData::createTypeAndPropertyCaches( QQmlPropertyCacheCreator propertyCacheCreator( &m_compiledData->propertyCaches, &pendingGroupPropertyBindings, engine, m_compiledData.data(), &m_importCache, typeClassName()); - QQmlJS::DiagnosticMessage error = propertyCacheCreator.buildMetaObjects(); + QQmlError error = propertyCacheCreator.buildMetaObjects(); if (error.isValid()) { setError(error); return; @@ -325,8 +325,8 @@ void QQmlTypeData::done() QList errors = script.script->errors(); QQmlError error; error.setUrl(url()); - error.setLine(script.location.line); - error.setColumn(script.location.column); + error.setLine(qmlConvertSourceCoordinate(script.location.line)); + error.setColumn(qmlConvertSourceCoordinate(script.location.column)); error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->urlString())); errors.prepend(error); setError(errors); @@ -349,8 +349,8 @@ void QQmlTypeData::done() QList errors = type.typeData ? type.typeData->errors() : QList{}; QQmlError error; error.setUrl(url()); - error.setLine(type.location.line); - error.setColumn(type.location.column); + error.setLine(qmlConvertSourceCoordinate(type.location.line)); + error.setColumn(qmlConvertSourceCoordinate(type.location.column)); error.setDescription(QQmlTypeLoader::tr("Type %1 has no inline component type called %2").arg(typeName.leftRef(lastDot), type.type.pendingResolutionName())); errors.prepend(error); setError(errors); @@ -365,8 +365,8 @@ void QQmlTypeData::done() QList errors = type.typeData->errors(); QQmlError error; error.setUrl(url()); - error.setLine(type.location.line); - error.setColumn(type.location.column); + error.setLine(qmlConvertSourceCoordinate(type.location.line)); + error.setColumn(qmlConvertSourceCoordinate(type.location.column)); error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName)); errors.prepend(error); setError(errors); @@ -384,8 +384,8 @@ void QQmlTypeData::done() QList errors = type.typeData->errors(); QQmlError error; error.setUrl(url()); - error.setLine(type.location.line); - error.setColumn(type.location.column); + error.setLine(qmlConvertSourceCoordinate(type.location.line)); + error.setColumn(qmlConvertSourceCoordinate(type.location.column)); error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName)); errors.prepend(error); setError(errors); @@ -414,7 +414,7 @@ void QQmlTypeData::done() QV4::ResolvedTypeReferenceMap resolvedTypeCache; QQmlRefPointer typeNameCache; { - QQmlJS::DiagnosticMessage error = buildTypeResolutionCaches(&typeNameCache, &resolvedTypeCache); + QQmlError error = buildTypeResolutionCaches(&typeNameCache, &resolvedTypeCache); if (error.isValid()) { setError(error); qDeleteAll(resolvedTypeCache); @@ -461,7 +461,7 @@ void QQmlTypeData::done() { // Sanity check property bindings QQmlPropertyValidator validator(enginePrivate, m_importCache, m_compiledData); - QVector errors = validator.validate(); + QVector errors = validator.validate(); if (!errors.isEmpty()) { setError(errors); return; @@ -625,8 +625,8 @@ bool QQmlTypeData::loadFromSource() for (const QQmlJS::DiagnosticMessage &msg : qAsConst(compiler.errors)) { QQmlError e; e.setUrl(url()); - e.setLine(msg.line); - e.setColumn(msg.column); + e.setLine(qmlConvertSourceCoordinate(msg.loc.startLine)); + e.setColumn(qmlConvertSourceCoordinate(msg.loc.startColumn)); e.setDescription(msg.message); errors << e; } @@ -697,8 +697,8 @@ void QQmlTypeData::continueLoadFromIR() Q_ASSERT(errors.size()); QQmlError error(errors.takeFirst()); error.setUrl(m_importCache.baseUrl()); - error.setLine(import->location.line); - error.setColumn(import->location.column); + error.setLine(qmlConvertSourceCoordinate(import->location.line)); + error.setColumn(qmlConvertSourceCoordinate(import->location.column)); errors.prepend(error); // put it back on the list after filling out information. setError(errors); return; @@ -724,8 +724,8 @@ void QQmlTypeData::allDependenciesDone() QQmlError error; error.setDescription(QQmlTypeLoader::tr("module \"%1\" is not installed").arg(import->uri)); error.setUrl(m_importCache.baseUrl()); - error.setLine(import->location.line); - error.setColumn(import->location.column); + error.setLine(qmlConvertSourceCoordinate(import->location.line)); + error.setColumn(qmlConvertSourceCoordinate(import->location.column)); errors.prepend(error); } } @@ -894,7 +894,7 @@ void QQmlTypeData::resolveTypes() loadImplicitImport(); } -QQmlJS::DiagnosticMessage QQmlTypeData::buildTypeResolutionCaches( +QQmlError QQmlTypeData::buildTypeResolutionCaches( QQmlRefPointer *typeNameCache, QV4::ResolvedTypeReferenceMap *resolvedTypeCache ) const @@ -973,7 +973,7 @@ QQmlJS::DiagnosticMessage QQmlTypeData::buildTypeResolutionCaches( ref->doDynamicTypeCheck(); resolvedTypeCache->insert(resolvedType.key(), ref.take()); } - QQmlJS::DiagnosticMessage noError; + QQmlError noError; return noError; } diff --git a/src/qml/qml/qqmltypedata_p.h b/src/qml/qml/qqmltypedata_p.h index d894090b36..906a0ee171 100644 --- a/src/qml/qml/qqmltypedata_p.h +++ b/src/qml/qml/qqmltypedata_p.h @@ -125,7 +125,7 @@ private: void restoreIR(QV4::CompiledData::CompilationUnit &&unit); void continueLoadFromIR(); void resolveTypes(); - QQmlJS::DiagnosticMessage buildTypeResolutionCaches( + QQmlError buildTypeResolutionCaches( QQmlRefPointer *typeNameCache, QV4::ResolvedTypeReferenceMap *resolvedTypeCache ) const; diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 13ad22126f..1d66e756fa 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -696,8 +697,8 @@ void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob) Q_ASSERT(errors.size()); QQmlError error(errors.takeFirst()); error.setUrl(m_importCache.baseUrl()); - error.setLine(import->location.line); - error.setColumn(import->location.column); + error.setLine(qmlConvertSourceCoordinate(import->location.line)); + error.setColumn(qmlConvertSourceCoordinate(import->location.column)); errors.prepend(error); // put it back on the list after filling out information. setError(errors); } diff --git a/src/qml/qml/qqmltypeloaderqmldircontent.cpp b/src/qml/qml/qqmltypeloaderqmldircontent.cpp index 860971d296..714ea79e67 100644 --- a/src/qml/qml/qqmltypeloaderqmldircontent.cpp +++ b/src/qml/qml/qqmltypeloaderqmldircontent.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include +#include #include QT_BEGIN_NAMESPACE @@ -59,8 +60,8 @@ QList QQmlTypeLoaderQmldirContent::errors(const QString &uri) const for (const auto &parseError : parseErrors) { QQmlError error; error.setUrl(url); - error.setLine(parseError.line); - error.setColumn(parseError.column); + error.setLine(qmlConvertSourceCoordinate(parseError.loc.startLine)); + error.setColumn(qmlConvertSourceCoordinate(parseError.loc.startColumn)); error.setDescription(parseError.message); errors.append(error); } @@ -83,8 +84,8 @@ void QQmlTypeLoaderQmldirContent::setContent(const QString &location, const QStr void QQmlTypeLoaderQmldirContent::setError(const QQmlError &error) { QQmlJS::DiagnosticMessage parseError; - parseError.line = error.line(); - parseError.column = error.column(); + parseError.loc.startLine = error.line(); + parseError.loc.startColumn = error.column(); parseError.message = error.description(); m_parser.setError(parseError); } diff --git a/src/qml/qmldirparser/qqmldirparser.cpp b/src/qml/qmldirparser/qqmldirparser.cpp index 36b47a3302..152e840318 100644 --- a/src/qml/qmldirparser/qqmldirparser.cpp +++ b/src/qml/qmldirparser/qqmldirparser.cpp @@ -302,8 +302,8 @@ bool QQmlDirParser::parse(const QString &source) void QQmlDirParser::reportError(quint16 line, quint16 column, const QString &description) { QQmlJS::DiagnosticMessage error; - error.line = line; - error.column = column; + error.loc.startLine = line; + error.loc.startColumn = column; error.message = description; _errors.append(error); } @@ -319,7 +319,7 @@ bool QQmlDirParser::hasError() const void QQmlDirParser::setError(const QQmlJS::DiagnosticMessage &e) { _errors.clear(); - reportError(e.line, e.column, e.message); + reportError(e.loc.startLine, e.loc.startColumn, e.message); } QList QQmlDirParser::errors(const QString &uri) const diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp index bc4ba9437c..7e96205743 100644 --- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp +++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp @@ -63,10 +63,10 @@ namespace { for (const QQmlJS::DiagnosticMessage &e : errors) { QString errorString = QLatin1String("qmldir"); - if (e.line > 0) { - errorString += QLatin1Char(':') + QString::number(e.line); - if (e.column > 0) - errorString += QLatin1Char(':') + QString::number(e.column); + if (e.loc.startLine > 0) { + errorString += QLatin1Char(':') + QString::number(e.loc.startLine); + if (e.loc.startColumn > 0) + errorString += QLatin1Char(':') + QString::number(e.loc.startColumn); } errorString += QLatin1String(": ") + e.message; diff --git a/tests/auto/shared/qqmljsastdumper.cpp b/tests/auto/shared/qqmljsastdumper.cpp index 8a50e021f6..5da6be6bd0 100644 --- a/tests/auto/shared/qqmljsastdumper.cpp +++ b/tests/auto/shared/qqmljsastdumper.cpp @@ -216,7 +216,7 @@ QString AstDumper::qs(const QStringRef &s) { return qs(s.toString()); } -QString AstDumper::loc(const AST::SourceLocation &s) { +QString AstDumper::loc(const SourceLocation &s) { if (noLocations() || !s.isValid()) return QLatin1String("\"\""); else { diff --git a/tests/auto/shared/qqmljsastdumper.h b/tests/auto/shared/qqmljsastdumper.h index d8d19e351d..5e46e516f0 100644 --- a/tests/auto/shared/qqmljsastdumper.h +++ b/tests/auto/shared/qqmljsastdumper.h @@ -91,7 +91,7 @@ public: QString qs(const char *s); QString qs(const QStringRef &s); - QString loc(const AST::SourceLocation &s); + QString loc(const SourceLocation &s); QString boolStr(bool v); diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index b1670c940d..bc74e7b08e 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -84,9 +84,9 @@ Error Error::augment(const QString &contextErrorMessage) const QString diagnosticErrorMessage(const QString &fileName, const QQmlJS::DiagnosticMessage &m) { QString message; - message = fileName + QLatin1Char(':') + QString::number(m.line) + QLatin1Char(':'); - if (m.column > 0) - message += QString::number(m.column) + QLatin1Char(':'); + message = fileName + QLatin1Char(':') + QString::number(m.loc.startLine) + QLatin1Char(':'); + if (m.loc.startColumn > 0) + message += QString::number(m.loc.startColumn) + QLatin1Char(':'); if (m.isError()) message += QLatin1String(" error: "); diff --git a/tools/qmlformat/commentastvisitor.h b/tools/qmlformat/commentastvisitor.h index c756c4f820..d3de0a9b9d 100644 --- a/tools/qmlformat/commentastvisitor.h +++ b/tools/qmlformat/commentastvisitor.h @@ -38,6 +38,7 @@ #include using namespace QQmlJS::AST; +using namespace QQmlJS; struct Comment { diff --git a/tools/qmlformat/dumpastvisitor.h b/tools/qmlformat/dumpastvisitor.h index 1e25bd9190..faf067d400 100644 --- a/tools/qmlformat/dumpastvisitor.h +++ b/tools/qmlformat/dumpastvisitor.h @@ -38,6 +38,7 @@ #include "commentastvisitor.h" using namespace QQmlJS::AST; +using namespace QQmlJS; class DumpAstVisitor : protected Visitor { diff --git a/tools/qmlformat/main.cpp b/tools/qmlformat/main.cpp index 915389e3d2..da58ffd5d0 100644 --- a/tools/qmlformat/main.cpp +++ b/tools/qmlformat/main.cpp @@ -67,7 +67,7 @@ bool parseFile(const QString& filename, bool inplace, bool verbose, bool sortImp const auto diagnosticMessages = parser.diagnosticMessages(); for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) { qWarning().noquote() << QString::fromLatin1("%1:%2 : %3") - .arg(filename).arg(m.line).arg(m.message); + .arg(filename).arg(m.loc.startLine).arg(m.message); } qWarning().noquote() << "Failed to parse" << filename; @@ -112,7 +112,7 @@ bool parseFile(const QString& filename, bool inplace, bool verbose, bool sortImp const auto diagnosticMessages = parser.diagnosticMessages(); for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) { qWarning().noquote() << QString::fromLatin1(":%2 : %3") - .arg(m.line).arg(m.message); + .arg(m.loc.startLine).arg(m.message); } } diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index b563d7df95..e5d43a8e89 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -277,7 +277,7 @@ QVariantList findQmlImportsInQmlCode(const QString &filePath, const QString &cod const auto diagnosticMessages = parser.diagnosticMessages(); for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) { std::cerr << QDir::toNativeSeparators(filePath).toStdString() << ':' - << m.line << ':' << m.message.toStdString() << std::endl; + << m.loc.startLine << ':' << m.message.toStdString() << std::endl; } return QVariantList(); } diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp index 0a0e669e94..fa601986b2 100644 --- a/tools/qmllint/main.cpp +++ b/tools/qmllint/main.cpp @@ -78,7 +78,7 @@ static bool lint_file(const QString &filename, const bool silent, const bool war const auto diagnosticMessages = parser.diagnosticMessages(); for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) { qWarning().noquote() << QString::fromLatin1("%1:%2 : %3") - .arg(filename).arg(m.line).arg(m.message); + .arg(filename).arg(m.loc.startLine).arg(m.message); } } diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp index 2ca3ed9a67..e7e0113f35 100644 --- a/tools/qmllint/scopetree.cpp +++ b/tools/qmllint/scopetree.cpp @@ -62,7 +62,7 @@ void ScopeTree::insertJSIdentifier(const QString &id, QQmlJS::AST::VariableScope } void ScopeTree::insertSignalIdentifier(const QString &id, const MetaMethod &method, - const QQmlJS::AST::SourceLocation &loc, + const QQmlJS::SourceLocation &loc, bool hasMultilineHandlerBody) { Q_ASSERT(m_scopeType == ScopeType::QMLScope); @@ -77,7 +77,7 @@ void ScopeTree::insertPropertyIdentifier(const MetaProperty &property) } void ScopeTree::addUnmatchedSignalHandler(const QString &handler, - const QQmlJS::AST::SourceLocation &location) + const QQmlJS::SourceLocation &location) { m_unmatchedSignalHandlers.append(qMakePair(handler, location)); } @@ -87,13 +87,13 @@ bool ScopeTree::isIdInCurrentScope(const QString &id) const return isIdInCurrentQMlScopes(id) || isIdInCurrentJSScopes(id); } -void ScopeTree::addIdToAccessed(const QString &id, const QQmlJS::AST::SourceLocation &location) { +void ScopeTree::addIdToAccessed(const QString &id, const QQmlJS::SourceLocation &location) { m_currentFieldMember = new FieldMemberList {id, QString(), location, {}}; m_accessedIdentifiers.push_back(std::unique_ptr(m_currentFieldMember)); } void ScopeTree::accessMember(const QString &name, const QString &parentType, - const QQmlJS::AST::SourceLocation &location) + const QQmlJS::SourceLocation &location) { Q_ASSERT(m_currentFieldMember); auto *fieldMember = new FieldMemberList {name, parentType, location, {}}; @@ -115,7 +115,7 @@ bool ScopeTree::isVisualRootScope() const class IssueLocationWithContext { public: - IssueLocationWithContext(const QString &code, const QQmlJS::AST::SourceLocation &location) { + IssueLocationWithContext(const QString &code, const QQmlJS::SourceLocation &location) { int before = std::max(0,code.lastIndexOf('\n', location.offset)); m_beforeText = code.midRef(before + 1, int(location.offset - (before + 1))); m_issueText = code.midRef(location.offset, location.length); @@ -440,7 +440,7 @@ const ScopeTree *ScopeTree::currentQMLScope() const } void ScopeTree::printContext(ColorOutput &colorOut, const QString &code, - const QQmlJS::AST::SourceLocation &location) const + const QQmlJS::SourceLocation &location) const { IssueLocationWithContext issueLocationWithContext {code, location}; colorOut.write(issueLocationWithContext.beforeText().toString(), Normal); diff --git a/tools/qmllint/scopetree.h b/tools/qmllint/scopetree.h index f5d1155a49..63f4310bf8 100644 --- a/tools/qmllint/scopetree.h +++ b/tools/qmllint/scopetree.h @@ -68,7 +68,7 @@ enum class ScopeType struct MethodUsage { MetaMethod method; - QQmlJS::AST::SourceLocation loc; + QQmlJS::SourceLocation loc; bool hasMultilineHandlerBody; }; @@ -112,16 +112,16 @@ public: void insertJSIdentifier(const QString &id, QQmlJS::AST::VariableScope scope); void insertSignalIdentifier(const QString &id, const MetaMethod &method, - const QQmlJS::AST::SourceLocation &loc, bool hasMultilineHandlerBody); + const QQmlJS::SourceLocation &loc, bool hasMultilineHandlerBody); // inserts property as qml identifier as well as the corresponding void insertPropertyIdentifier(const MetaProperty &prop); void addUnmatchedSignalHandler(const QString &handler, - const QQmlJS::AST::SourceLocation &location); + const QQmlJS::SourceLocation &location); bool isIdInCurrentScope(const QString &id) const; - void addIdToAccessed(const QString &id, const QQmlJS::AST::SourceLocation &location); + void addIdToAccessed(const QString &id, const QQmlJS::SourceLocation &location); void accessMember(const QString &name, const QString &parentType, - const QQmlJS::AST::SourceLocation &location); + const QQmlJS::SourceLocation &location); void resetMemberScope(); bool isVisualRootScope() const; @@ -174,7 +174,7 @@ private: { QString m_name; QString m_parentType; - QQmlJS::AST::SourceLocation m_location; + QQmlJS::SourceLocation m_location; std::unique_ptr m_child; }; @@ -188,7 +188,7 @@ private: std::vector> m_accessedIdentifiers; FieldMemberList *m_currentFieldMember = nullptr; - QVector> m_unmatchedSignalHandlers; + QVector> m_unmatchedSignalHandlers; QVector m_childScopes; ScopeTree *m_parentScope; @@ -211,7 +211,7 @@ private: bool isIdInjectedFromSignal(const QString &id) const; const ScopeTree *currentQMLScope() const; void printContext(ColorOutput &colorOut, const QString &code, - const QQmlJS::AST::SourceLocation &location) const; + const QQmlJS::SourceLocation &location) const; bool checkMemberAccess( const QString &code, FieldMemberList *members, diff --git a/tools/qmllint/typedescriptionreader.h b/tools/qmllint/typedescriptionreader.h index 5fcbe3abc9..48c33bee3c 100644 --- a/tools/qmllint/typedescriptionreader.h +++ b/tools/qmllint/typedescriptionreader.h @@ -90,8 +90,8 @@ private: void readMetaObjectRevisions(QQmlJS::AST::UiScriptBinding *ast, const ScopeTree::Ptr &scope); void readEnumValues(QQmlJS::AST::UiScriptBinding *ast, MetaEnum *metaEnum); - void addError(const QQmlJS::AST::SourceLocation &loc, const QString &message); - void addWarning(const QQmlJS::AST::SourceLocation &loc, const QString &message); + void addError(const QQmlJS::SourceLocation &loc, const QString &message); + void addWarning(const QQmlJS::SourceLocation &loc, const QString &message); QString m_fileName; QString m_source; -- cgit v1.2.3 From be2c7864983b23b6337305b4653987b1efa8718e Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 2 Mar 2020 12:05:07 +0100 Subject: doc: fix typo in signal name Change-Id: I19b3a78ddbde481af8847a3d340e62d56240de29 Reviewed-by: Ulf Hermann --- src/quick/items/qquickwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 55292d2157..acc1df7496 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -4438,7 +4438,7 @@ QQmlIncubationController *QQuickWindow::incubationController() const OpenGL context is actually created. QQuickWindow::openglContext() will still return 0 for this window - until after the QQuickWindow::sceneGraphInitialize() has been + until after the QQuickWindow::sceneGraphInitialized() has been emitted. \note -- cgit v1.2.3 From 744246b1129f6042c0264eb578a6e5c86e09f80a Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 25 Feb 2020 16:10:40 +0100 Subject: Use Qt::SplitBehavior in preference to QString::SplitBehavior The Qt version was added in 5.14 "for use as eventual replacement for QString::SplitBehavior." Move another step cloaser to that goal. Change-Id: I3214ad6ccaca9dfd4a026589cabeb40cbf4a6298 Reviewed-by: Simon Hausmann --- src/imports/wavefrontmesh/qwavefrontmesh.cpp | 10 +++++----- .../qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp | 2 +- src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp | 2 +- src/qml/qml/qqmlimport.cpp | 6 +++--- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 2 +- tools/qmleasing/splineeditor.cpp | 2 +- tools/qmlimportscanner/main.cpp | 2 +- tools/qmllint/findunqualified.cpp | 2 +- tools/qmlprofiler/qmlprofilerapplication.cpp | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/imports/wavefrontmesh/qwavefrontmesh.cpp b/src/imports/wavefrontmesh/qwavefrontmesh.cpp index e973ef0103..1772c40c50 100644 --- a/src/imports/wavefrontmesh/qwavefrontmesh.cpp +++ b/src/imports/wavefrontmesh/qwavefrontmesh.cpp @@ -257,7 +257,7 @@ void QWavefrontMesh::readData() while (!stream.atEnd()) { stream.readLineInto(&buffer); - QVector tokens = buffer.splitRef(space, QString::SkipEmptyParts); + QVector tokens = buffer.splitRef(space, Qt::SkipEmptyParts); if (tokens.size() < 2) continue; @@ -316,7 +316,7 @@ void QWavefrontMesh::readData() if (tokens.size() >= 4 && tokens.size() <= 5) { { bool ok; - QVector faceTokens = tokens.at(1).split(slash, QString::SkipEmptyParts); + QVector faceTokens = tokens.at(1).split(slash, Qt::SkipEmptyParts); Q_ASSERT(!faceTokens.isEmpty()); p1 = faceTokens.at(0).toInt(&ok) - 1; @@ -336,7 +336,7 @@ void QWavefrontMesh::readData() { bool ok; - QVector faceTokens = tokens.at(2).split(slash, QString::SkipEmptyParts); + QVector faceTokens = tokens.at(2).split(slash, Qt::SkipEmptyParts); Q_ASSERT(!faceTokens.isEmpty()); p2 = faceTokens.at(0).toInt(&ok) - 1; @@ -356,7 +356,7 @@ void QWavefrontMesh::readData() { bool ok; - QVector faceTokens = tokens.at(3).split(slash, QString::SkipEmptyParts); + QVector faceTokens = tokens.at(3).split(slash, Qt::SkipEmptyParts); Q_ASSERT(!faceTokens.isEmpty()); p3 = faceTokens.at(0).toInt(&ok) - 1; @@ -394,7 +394,7 @@ void QWavefrontMesh::readData() if (tokens.size() == 5) { bool ok; - QVector faceTokens = tokens.at(4).split(slash, QString::SkipEmptyParts); + QVector faceTokens = tokens.at(4).split(slash, Qt::SkipEmptyParts); Q_ASSERT(!faceTokens.isEmpty()); int p4 = faceTokens.at(0).toInt(&ok) - 1; diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp index bf73440a39..c504ea605a 100644 --- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp +++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp @@ -183,7 +183,7 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector() : m_blockingMode(false) { const QString args = commandLineArguments(); - const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), QString::SkipEmptyParts); + const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), Qt::SkipEmptyParts); QStringList services; for (const QStringRef &strArgument : lstjsDebugArguments) { if (strArgument == QLatin1String("block")) { diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp index 33b6606b44..4d68a4508b 100644 --- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp +++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp @@ -345,7 +345,7 @@ void QQmlDebugServerImpl::parseArguments() QString fileName; QStringList services; - const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), QString::SkipEmptyParts); + const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), Qt::SkipEmptyParts); for (auto argsIt = lstjsDebugArguments.begin(), argsItEnd = lstjsDebugArguments.end(); argsIt != argsItEnd; ++argsIt) { const QStringRef &strArgument = *argsIt; if (strArgument.startsWith(QLatin1String("port:"))) { diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index e442f07527..2a6ede83c7 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -534,7 +534,7 @@ static QString joinStringRefs(const QVector &refs, const QChar &sep) */ QStringList QQmlImports::completeQmldirPaths(const QString &uri, const QStringList &basePaths, int vmaj, int vmin) { - const QVector parts = uri.splitRef(Dot, QString::SkipEmptyParts); + const QVector parts = uri.splitRef(Dot, Qt::SkipEmptyParts); QStringList qmlDirPathsPaths; // fully & partially versioned parts + 1 unversioned for each base path @@ -1881,7 +1881,7 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e) #else QLatin1Char pathSep(':'); #endif - QStringList paths = envImportPath.split(pathSep, QString::SkipEmptyParts); + QStringList paths = envImportPath.split(pathSep, Qt::SkipEmptyParts); for (int ii = paths.count() - 1; ii >= 0; --ii) addImportPath(paths.at(ii)); } @@ -1893,7 +1893,7 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e) if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_BUNDLED_LIBS_PATH"))) { const QString envImportPath = qEnvironmentVariable("QT_BUNDLED_LIBS_PATH"); QLatin1Char pathSep(':'); - QStringList paths = envImportPath.split(pathSep, QString::SkipEmptyParts); + QStringList paths = envImportPath.split(pathSep, Qt::SkipEmptyParts); for (int ii = paths.count() - 1; ii >= 0; --ii) addPluginPath(paths.at(ii)); } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 2a1457d818..4b0cbfa1aa 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -7304,7 +7304,7 @@ void tst_qqmlecmascript::forInLoop() QMetaObject::invokeMethod(object, "listProperty"); - QStringList r = object->property("listResult").toString().split("|", QString::SkipEmptyParts); + QStringList r = object->property("listResult").toString().split("|", Qt::SkipEmptyParts); QCOMPARE(r.size(), 3); QCOMPARE(r[0],QLatin1String("0=obj1")); QCOMPARE(r[1],QLatin1String("1=obj2")); diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp index 69850dc7a1..3657fe3f27 100644 --- a/tools/qmleasing/splineeditor.cpp +++ b/tools/qmleasing/splineeditor.cpp @@ -674,7 +674,7 @@ void SplineEditor::setEasingCurve(const QString &code) return; if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) { const QStringRef cleanCode(&code, 1, code.size() - 2); - const auto stringList = cleanCode.split(QLatin1Char(','), QString::SkipEmptyParts); + const auto stringList = cleanCode.split(QLatin1Char(','), Qt::SkipEmptyParts); if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) { QVector realList; realList.reserve(stringList.count()); diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index e5d43a8e89..aca11e2ca4 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -179,7 +179,7 @@ QPair resolveImportPath(const QString &uri, const QString &ver { const QLatin1Char dot('.'); const QLatin1Char slash('/'); - const QStringList parts = uri.split(dot, QString::SkipEmptyParts); + const QStringList parts = uri.split(dot, Qt::SkipEmptyParts); QString ver = version; while (true) { diff --git a/tools/qmllint/findunqualified.cpp b/tools/qmllint/findunqualified.cpp index 88466cfae9..ae23d6d5f8 100644 --- a/tools/qmllint/findunqualified.cpp +++ b/tools/qmllint/findunqualified.cpp @@ -124,7 +124,7 @@ QStringList completeImportPaths(const QString &uri, const QString &basePath, int static const QLatin1Char Slash('/'); static const QLatin1Char Backslash('\\'); - const QVector parts = uri.splitRef(QLatin1Char('.'), QString::SkipEmptyParts); + const QVector parts = uri.splitRef(QLatin1Char('.'), Qt::SkipEmptyParts); QStringList qmlDirPathsPaths; // fully & partially versioned parts + 1 unversioned for each base path diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp index 7b010546c3..7c92f428ae 100644 --- a/tools/qmlprofiler/qmlprofilerapplication.cpp +++ b/tools/qmlprofiler/qmlprofilerapplication.cpp @@ -354,7 +354,7 @@ bool QmlProfilerApplication::checkOutputFile(PendingRequest pending) void QmlProfilerApplication::userCommand(const QString &command) { - auto args = command.splitRef(QChar::Space, QString::SkipEmptyParts); + auto args = command.splitRef(QChar::Space, Qt::SkipEmptyParts); if (args.isEmpty()) { prompt(); return; -- cgit v1.2.3 From 9e2aa53c14b007fe26d30b63926d343fe5ffed7d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 2 Mar 2020 17:16:54 +0100 Subject: qmltyperegistrar: Mark non-QObject types as uncreatable qmlplugindump does so, and in fact they are uncreatable. Also, make qmlTypeRegistrationMode() more robust. Each classDef should really either be an object, a gadget, or a namespace. Change-Id: If39bbbf6f9a4fdb269d095ca10d60ad5d87ca62d Reviewed-by: Shawn Rutledge Reviewed-by: Simon Hausmann --- src/qmltyperegistrar/qmltyperegistrar.cpp | 21 +++++++++++++++------ src/qmltyperegistrar/qmltypesclassdescription.cpp | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/qmltyperegistrar/qmltyperegistrar.cpp b/src/qmltyperegistrar/qmltyperegistrar.cpp index 6fe5a20092..6154d87e99 100644 --- a/src/qmltyperegistrar/qmltyperegistrar.cpp +++ b/src/qmltyperegistrar/qmltyperegistrar.cpp @@ -49,7 +49,8 @@ struct ScopedPointerFileCloser enum RegistrationMode { NoRegistration, - ClassRegistration, + ObjectRegistration, + GadgetRegistration, NamespaceRegistration }; @@ -59,8 +60,16 @@ static RegistrationMode qmlTypeRegistrationMode(const QJsonObject &classDef) for (const QJsonValue &info: classInfos) { const QString name = info[QLatin1String("name")].toString(); if (name == QLatin1String("QML.Element")) { - return classDef[QLatin1String("namespace")].toBool() ? NamespaceRegistration - : ClassRegistration; + if (classDef[QLatin1String("object")].toBool()) + return ObjectRegistration; + if (classDef[QLatin1String("gadget")].toBool()) + return GadgetRegistration; + if (classDef[QLatin1String("namespace")].toBool()) + return NamespaceRegistration; + qWarning() << "Not registering classInfo which is neither an object, " + "nor a gadget, nor a namespace:" + << name; + break; } } return NoRegistration; @@ -295,9 +304,8 @@ int main(int argc, char **argv) QJsonObject classDef = cls.toObject(); switch (qmlTypeRegistrationMode(classDef)) { case NamespaceRegistration: - classDef.insert(QLatin1String("namespace"), true); - Q_FALLTHROUGH(); - case ClassRegistration: { + case GadgetRegistration: + case ObjectRegistration: { const QString include = metaObject[QLatin1String("inputFile")].toString(); const bool declaredInHeader = include.endsWith(QLatin1String(".h")); if (declaredInHeader) { @@ -309,6 +317,7 @@ int main(int argc, char **argv) qPrintable(classDef.value(QLatin1String("qualifiedClassName")) .toString())); } + types.append(classDef); break; } diff --git a/src/qmltyperegistrar/qmltypesclassdescription.cpp b/src/qmltyperegistrar/qmltypesclassdescription.cpp index c6279998b7..3442dc9d64 100644 --- a/src/qmltyperegistrar/qmltypesclassdescription.cpp +++ b/src/qmltyperegistrar/qmltypesclassdescription.cpp @@ -154,6 +154,9 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, revisions.erase(end, revisions.end()); resolvedClass = classDef; + + // If it's not a QObject, it's not creatable + isCreatable = isCreatable && classDef->value(QLatin1String("object")).toBool(); } void QmlTypesClassDescription::collectAttached(const QString &attached, -- cgit v1.2.3 From b760d972459fd3b0c41e4c85076fa933ba5c0d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sun, 1 Mar 2020 15:14:34 +0100 Subject: Fix building qtdeclarative without QMovie support Change-Id: Id8e8b04e722bd9fc84b6b78530f75cf8d6d96da7 Reviewed-by: Ulf Hermann Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitemsmodule_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quick/items/qquickitemsmodule_p.h b/src/quick/items/qquickitemsmodule_p.h index 28dff65dff..815c5ae644 100644 --- a/src/quick/items/qquickitemsmodule_p.h +++ b/src/quick/items/qquickitemsmodule_p.h @@ -78,7 +78,7 @@ struct QQuickAnimatedImageNotAvailable Q_GADGET QML_UNAVAILABLE QML_NAMED_ELEMENT(AnimatedImage) - QML_ADDED_IN_VERSION(2, 0) + QML_ADDED_IN_MINOR_VERSION(0) QML_UNCREATABLE("Qt was built without support for QMovie.") }; #endif -- cgit v1.2.3 From 254a56252874b63430701351dcd8c9bef8507353 Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Wed, 26 Feb 2020 21:14:50 +0800 Subject: QQuickItem: prevent endless loop in focus tab chain Since the commit a18ab2a3822e0d, we promote the [startItem] in focus tab chain when it is invisible to prevent endless loop. However the problem still happen if the [startItem] is equal to [firstFromItem] Fixes it by compare the [current] item with the original start item Fixes: QTBUG-81510 Change-Id: Iae0207f39e2b8c4fc6ed0cf36f0a855668accfba Reviewed-by: Mitch Curtis Reviewed-by: Liang Qi Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitem.cpp | 8 +++++++- .../qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml | 12 ++++++++++++ tests/auto/quick/qquickitem2/tst_qquickitem.cpp | 15 +++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 3785abc450..11c1f12e75 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2568,6 +2568,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo bool skip = false; QQuickItem *startItem = item; + QQuickItem *originalStartItem = startItem; // Protect from endless loop: // If we start on an invisible item we will not find it again. // If there is no other item which can become the focus item, we have a forever loop, @@ -2643,7 +2644,12 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo } } from = last; - if (current == startItem && from == firstFromItem) { + // if [from] item is equal to [firstFromItem], means we have traversed one path and + // jump back to parent of the chain, and then we have to check whether we have + // traversed all of the chain (by compare the [current] item with [startItem]) + // Since the [startItem] might be promoted to its parent if it is invisible, + // we still have to check [current] item with original start item + if ((current == startItem || current == originalStartItem) && from == firstFromItem) { // wrapped around, avoid endless loops if (item == contentItem) { qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem"; diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml new file mode 100644 index 0000000000..042f408753 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml @@ -0,0 +1,12 @@ +import QtQuick 2.14 + +Item { + width: 400 + height: 200 + Item { + objectName: "hiddenChild" + focus: true + activeFocusOnTab: true + visible: false + } +} diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 399535cfa6..767994ec7d 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -64,6 +64,7 @@ private slots: void activeFocusOnTab8(); void activeFocusOnTab9(); void activeFocusOnTab10(); + void activeFocusOnTab_infiniteLoop_data(); void activeFocusOnTab_infiniteLoop(); void nextItemInFocusChain(); @@ -1025,12 +1026,20 @@ void tst_QQuickItem::activeFocusOnTab10() delete window; } +void tst_QQuickItem::activeFocusOnTab_infiniteLoop_data() +{ + QTest::addColumn("source"); + QTest::newRow("infiniteLoop") << testFileUrl("activeFocusOnTab_infiniteLoop.qml"); // QTBUG-68271 + QTest::newRow("infiniteLoop2") << testFileUrl("activeFocusOnTab_infiniteLoop2.qml");// QTBUG-81510 +} + void tst_QQuickItem::activeFocusOnTab_infiniteLoop() { - // see QTBUG-68271 + QFETCH(QUrl, source); + // create a window where the currently focused item is not visible QScopedPointerwindow(new QQuickView()); - window->setSource(testFileUrl("activeFocusOnTab_infiniteLoop.qml")); + window->setSource(source); window->show(); auto *hiddenChild = findItem(window->rootObject(), "hiddenChild"); QVERIFY(hiddenChild); @@ -1039,6 +1048,8 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop() auto *item = hiddenChild->nextItemInFocusChain(); // focus is moved to the root object since there is no other candidate QCOMPARE(item, window->rootObject()); + item = hiddenChild->nextItemInFocusChain(false); + QCOMPARE(item, window->rootObject()); } void tst_QQuickItem::nextItemInFocusChain() -- cgit v1.2.3 From 3d31661447562537b35094d306de26d49d8bc8a5 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Tue, 3 Mar 2020 14:42:55 +0100 Subject: Get rid of extra space Change-Id: I11e5c9e95974e89f2fd1571ca4b97a0f2ac3309a Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/qml/parser/qqmljsast_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index 053e9fd2d3..9eba432e69 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -1068,7 +1068,7 @@ public: PatternPropertyList *next; }; -class QML_PARSER_EXPORT IdentifierPropertyName : public PropertyName +class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName { public: QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName) -- cgit v1.2.3 From 6381f6c87ff3eb3e15ba62f58a5393ce9026b99f Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Tue, 3 Mar 2020 16:45:44 +0100 Subject: Remove duplicate add of qqmljsengine_p.h to HEADERS in parser.pri Change-Id: I6848575df79be5f84e55e1e9ae9282216424afeb Reviewed-by: Simon Hausmann --- src/qml/parser/parser.pri | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qml/parser/parser.pri b/src/qml/parser/parser.pri index 1ac867fe59..57855a82f9 100644 --- a/src/qml/parser/parser.pri +++ b/src/qml/parser/parser.pri @@ -5,8 +5,7 @@ HEADERS += \ $$PWD/qqmljsengine_p.h \ $$PWD/qqmljslexer_p.h \ $$PWD/qqmljsglobal_p.h \ - $$PWD/qqmljskeywords_p.h \ - $$PWD/qqmljsengine_p.h + $$PWD/qqmljskeywords_p.h SOURCES += \ $$PWD/qqmljsast.cpp \ -- cgit v1.2.3 From 1fef24732bb5114392626a7fef956625a6cc66ac Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Thu, 27 Feb 2020 12:10:55 +0200 Subject: Examples: Add *.pro projects for existing *.qmlproject The *.qmlproject won't deploy and run on Android, thus adding normal .pro projects to allow deploying to Android. Task-number: QTBUG-80717 Change-Id: I8a79a56bec57add315c08088a2fca5995df76912 Reviewed-by: Ulf Hermann --- examples/qml/dynamicscene/dynamicscene.pro | 9 ++++ examples/qml/dynamicscene/dynamicscene.qrc | 19 ++++++++ examples/qml/dynamicscene/main.cpp | 51 ++++++++++++++++++++++ examples/quick/customitems/flipable/flipable.pro | 9 ++++ examples/quick/customitems/flipable/flipable.qrc | 9 ++++ examples/quick/customitems/flipable/main.cpp | 51 ++++++++++++++++++++++ examples/quick/customitems/scrollbar/main.cpp | 51 ++++++++++++++++++++++ examples/quick/customitems/scrollbar/scrollbar.pro | 9 ++++ examples/quick/customitems/scrollbar/scrollbar.qrc | 7 +++ examples/quick/customitems/searchbox/main.cpp | 51 ++++++++++++++++++++++ examples/quick/customitems/searchbox/searchbox.pro | 9 ++++ examples/quick/customitems/searchbox/searchbox.qrc | 9 ++++ examples/quick/customitems/spinner/main.cpp | 51 ++++++++++++++++++++++ examples/quick/customitems/spinner/spinner.pro | 9 ++++ examples/quick/customitems/spinner/spinner.qrc | 8 ++++ examples/quick/customitems/tabwidget/main.cpp | 51 ++++++++++++++++++++++ examples/quick/customitems/tabwidget/tabwidget.pro | 9 ++++ examples/quick/customitems/tabwidget/tabwidget.qrc | 8 ++++ .../dynamicview/dynamicview1/dynamicview1.pro | 9 ++++ .../dynamicview/dynamicview1/dynamicview1.qrc | 6 +++ .../tutorials/dynamicview/dynamicview1/main.cpp | 51 ++++++++++++++++++++++ .../dynamicview/dynamicview2/dynamicview2.pro | 9 ++++ .../dynamicview/dynamicview2/dynamicview2.qrc | 6 +++ .../tutorials/dynamicview/dynamicview2/main.cpp | 51 ++++++++++++++++++++++ .../dynamicview/dynamicview3/dynamicview3.pro | 9 ++++ .../dynamicview/dynamicview3/dynamicview3.qrc | 6 +++ .../tutorials/dynamicview/dynamicview3/main.cpp | 51 ++++++++++++++++++++++ .../dynamicview/dynamicview4/dynamicview4.pro | 9 ++++ .../dynamicview/dynamicview4/dynamicview4.qrc | 6 +++ .../tutorials/dynamicview/dynamicview4/main.cpp | 51 ++++++++++++++++++++++ .../quick/tutorials/samegame/samegame1/main.cpp | 51 ++++++++++++++++++++++ .../tutorials/samegame/samegame1/samegame1.pro | 11 +++++ .../tutorials/samegame/samegame1/samegame1.qrc | 7 +++ .../quick/tutorials/samegame/samegame2/main.cpp | 51 ++++++++++++++++++++++ .../tutorials/samegame/samegame2/samegame2.pro | 11 +++++ .../tutorials/samegame/samegame2/samegame2.qrc | 8 ++++ .../quick/tutorials/samegame/samegame3/main.cpp | 51 ++++++++++++++++++++++ .../tutorials/samegame/samegame3/samegame3.pro | 11 +++++ .../tutorials/samegame/samegame3/samegame3.qrc | 8 ++++ .../quick/tutorials/samegame/samegame4/main.cpp | 51 ++++++++++++++++++++++ .../tutorials/samegame/samegame4/samegame4.pro | 11 +++++ .../tutorials/samegame/samegame4/samegame4.qrc | 13 ++++++ .../tutorials/samegame/shared/pics/shared.qrc | 13 ++++++ examples/quick/views/delegatemodel/flipable.pro | 9 ++++ examples/quick/views/delegatemodel/flipable.qrc | 9 ++++ examples/quick/views/delegatemodel/main.cpp | 51 ++++++++++++++++++++++ 46 files changed, 1050 insertions(+) create mode 100644 examples/qml/dynamicscene/dynamicscene.pro create mode 100644 examples/qml/dynamicscene/dynamicscene.qrc create mode 100644 examples/qml/dynamicscene/main.cpp create mode 100644 examples/quick/customitems/flipable/flipable.pro create mode 100644 examples/quick/customitems/flipable/flipable.qrc create mode 100644 examples/quick/customitems/flipable/main.cpp create mode 100644 examples/quick/customitems/scrollbar/main.cpp create mode 100644 examples/quick/customitems/scrollbar/scrollbar.pro create mode 100644 examples/quick/customitems/scrollbar/scrollbar.qrc create mode 100644 examples/quick/customitems/searchbox/main.cpp create mode 100644 examples/quick/customitems/searchbox/searchbox.pro create mode 100644 examples/quick/customitems/searchbox/searchbox.qrc create mode 100644 examples/quick/customitems/spinner/main.cpp create mode 100644 examples/quick/customitems/spinner/spinner.pro create mode 100644 examples/quick/customitems/spinner/spinner.qrc create mode 100644 examples/quick/customitems/tabwidget/main.cpp create mode 100644 examples/quick/customitems/tabwidget/tabwidget.pro create mode 100644 examples/quick/customitems/tabwidget/tabwidget.qrc create mode 100644 examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.pro create mode 100644 examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.qrc create mode 100644 examples/quick/tutorials/dynamicview/dynamicview1/main.cpp create mode 100644 examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.pro create mode 100644 examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.qrc create mode 100644 examples/quick/tutorials/dynamicview/dynamicview2/main.cpp create mode 100644 examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.pro create mode 100644 examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.qrc create mode 100644 examples/quick/tutorials/dynamicview/dynamicview3/main.cpp create mode 100644 examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.pro create mode 100644 examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.qrc create mode 100644 examples/quick/tutorials/dynamicview/dynamicview4/main.cpp create mode 100644 examples/quick/tutorials/samegame/samegame1/main.cpp create mode 100644 examples/quick/tutorials/samegame/samegame1/samegame1.pro create mode 100644 examples/quick/tutorials/samegame/samegame1/samegame1.qrc create mode 100644 examples/quick/tutorials/samegame/samegame2/main.cpp create mode 100644 examples/quick/tutorials/samegame/samegame2/samegame2.pro create mode 100644 examples/quick/tutorials/samegame/samegame2/samegame2.qrc create mode 100644 examples/quick/tutorials/samegame/samegame3/main.cpp create mode 100644 examples/quick/tutorials/samegame/samegame3/samegame3.pro create mode 100644 examples/quick/tutorials/samegame/samegame3/samegame3.qrc create mode 100644 examples/quick/tutorials/samegame/samegame4/main.cpp create mode 100644 examples/quick/tutorials/samegame/samegame4/samegame4.pro create mode 100644 examples/quick/tutorials/samegame/samegame4/samegame4.qrc create mode 100644 examples/quick/tutorials/samegame/shared/pics/shared.qrc create mode 100644 examples/quick/views/delegatemodel/flipable.pro create mode 100644 examples/quick/views/delegatemodel/flipable.qrc create mode 100644 examples/quick/views/delegatemodel/main.cpp diff --git a/examples/qml/dynamicscene/dynamicscene.pro b/examples/qml/dynamicscene/dynamicscene.pro new file mode 100644 index 0000000000..29a3fa97e2 --- /dev/null +++ b/examples/qml/dynamicscene/dynamicscene.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += dynamicscene.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qml/dynamicscene +INSTALLS += target diff --git a/examples/qml/dynamicscene/dynamicscene.qrc b/examples/qml/dynamicscene/dynamicscene.qrc new file mode 100644 index 0000000000..ac9baa4941 --- /dev/null +++ b/examples/qml/dynamicscene/dynamicscene.qrc @@ -0,0 +1,19 @@ + + + dynamicscene.qml + content/images/face-smile.png + content/images/moon.png + content/images/NOTE + content/images/rabbit_brown.png + content/images/rabbit_bw.png + content/images/star.png + content/images/sun.png + content/images/tree_s.png + content/Button.qml + content/GenericSceneItem.qml + content/itemCreation.js + content/PaletteItem.qml + content/PerspectiveItem.qml + content/Sun.qml + + diff --git a/examples/qml/dynamicscene/main.cpp b/examples/qml/dynamicscene/main.cpp new file mode 100644 index 0000000000..e28375158d --- /dev/null +++ b/examples/qml/dynamicscene/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../quick/shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(dynamicscene) diff --git a/examples/quick/customitems/flipable/flipable.pro b/examples/quick/customitems/flipable/flipable.pro new file mode 100644 index 0000000000..ba00bf792c --- /dev/null +++ b/examples/quick/customitems/flipable/flipable.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += flipable.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/flipable +INSTALLS += target diff --git a/examples/quick/customitems/flipable/flipable.qrc b/examples/quick/customitems/flipable/flipable.qrc new file mode 100644 index 0000000000..7918ccf00e --- /dev/null +++ b/examples/quick/customitems/flipable/flipable.qrc @@ -0,0 +1,9 @@ + + + flipable.qml + content/5_heart.png + content/9_club.png + content/back.png + content/Card.qml + + diff --git a/examples/quick/customitems/flipable/main.cpp b/examples/quick/customitems/flipable/main.cpp new file mode 100644 index 0000000000..a0f0d67d45 --- /dev/null +++ b/examples/quick/customitems/flipable/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(flipable) diff --git a/examples/quick/customitems/scrollbar/main.cpp b/examples/quick/customitems/scrollbar/main.cpp new file mode 100644 index 0000000000..579db41efd --- /dev/null +++ b/examples/quick/customitems/scrollbar/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(main) diff --git a/examples/quick/customitems/scrollbar/scrollbar.pro b/examples/quick/customitems/scrollbar/scrollbar.pro new file mode 100644 index 0000000000..7e6ea3c2d6 --- /dev/null +++ b/examples/quick/customitems/scrollbar/scrollbar.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += scrollbar.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/scrollbar +INSTALLS += target diff --git a/examples/quick/customitems/scrollbar/scrollbar.qrc b/examples/quick/customitems/scrollbar/scrollbar.qrc new file mode 100644 index 0000000000..b1ba5f9211 --- /dev/null +++ b/examples/quick/customitems/scrollbar/scrollbar.qrc @@ -0,0 +1,7 @@ + + + main.qml + ScrollBar.qml + pics/niagara_falls.jpg + + diff --git a/examples/quick/customitems/searchbox/main.cpp b/examples/quick/customitems/searchbox/main.cpp new file mode 100644 index 0000000000..579db41efd --- /dev/null +++ b/examples/quick/customitems/searchbox/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(main) diff --git a/examples/quick/customitems/searchbox/searchbox.pro b/examples/quick/customitems/searchbox/searchbox.pro new file mode 100644 index 0000000000..c22fc117aa --- /dev/null +++ b/examples/quick/customitems/searchbox/searchbox.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += searchbox.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/searchbox +INSTALLS += target diff --git a/examples/quick/customitems/searchbox/searchbox.qrc b/examples/quick/customitems/searchbox/searchbox.qrc new file mode 100644 index 0000000000..f7a8602c9a --- /dev/null +++ b/examples/quick/customitems/searchbox/searchbox.qrc @@ -0,0 +1,9 @@ + + + main.qml + SearchBox.qml + images/clear.png + images/lineedit-bg-focus.png + images/lineedit-bg.png + + diff --git a/examples/quick/customitems/spinner/main.cpp b/examples/quick/customitems/spinner/main.cpp new file mode 100644 index 0000000000..579db41efd --- /dev/null +++ b/examples/quick/customitems/spinner/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(main) diff --git a/examples/quick/customitems/spinner/spinner.pro b/examples/quick/customitems/spinner/spinner.pro new file mode 100644 index 0000000000..b5be6884d2 --- /dev/null +++ b/examples/quick/customitems/spinner/spinner.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += spinner.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/spinner +INSTALLS += target diff --git a/examples/quick/customitems/spinner/spinner.qrc b/examples/quick/customitems/spinner/spinner.qrc new file mode 100644 index 0000000000..3a8e4b17fd --- /dev/null +++ b/examples/quick/customitems/spinner/spinner.qrc @@ -0,0 +1,8 @@ + + + main.qml + content/spinner-bg.png + content/spinner-select.png + content/Spinner.qml + + diff --git a/examples/quick/customitems/tabwidget/main.cpp b/examples/quick/customitems/tabwidget/main.cpp new file mode 100644 index 0000000000..579db41efd --- /dev/null +++ b/examples/quick/customitems/tabwidget/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(main) diff --git a/examples/quick/customitems/tabwidget/tabwidget.pro b/examples/quick/customitems/tabwidget/tabwidget.pro new file mode 100644 index 0000000000..b852bb4075 --- /dev/null +++ b/examples/quick/customitems/tabwidget/tabwidget.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += tabwidget.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/tabwidget +INSTALLS += target diff --git a/examples/quick/customitems/tabwidget/tabwidget.qrc b/examples/quick/customitems/tabwidget/tabwidget.qrc new file mode 100644 index 0000000000..ee71f677b1 --- /dev/null +++ b/examples/quick/customitems/tabwidget/tabwidget.qrc @@ -0,0 +1,8 @@ + + + main.qml + TabWidget.qml + doc/images/qml-tabwidget-example.png + doc/images/tab.png + + diff --git a/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.pro b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.pro new file mode 100644 index 0000000000..8ca003b6b4 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += dynamicview1.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/dynamicview/dynamicview1 +INSTALLS += target diff --git a/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.qrc b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.qrc new file mode 100644 index 0000000000..c89a5e3a97 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.qrc @@ -0,0 +1,6 @@ + + + dynamicview.qml + PetsModel.qml + + diff --git a/examples/quick/tutorials/dynamicview/dynamicview1/main.cpp b/examples/quick/tutorials/dynamicview/dynamicview1/main.cpp new file mode 100644 index 0000000000..72b8b667f5 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview1/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(dynamicview) diff --git a/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.pro b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.pro new file mode 100644 index 0000000000..a2b058c528 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += dynamicview2.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/dynamicview/dynamicview2 +INSTALLS += target diff --git a/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.qrc b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.qrc new file mode 100644 index 0000000000..c89a5e3a97 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.qrc @@ -0,0 +1,6 @@ + + + dynamicview.qml + PetsModel.qml + + diff --git a/examples/quick/tutorials/dynamicview/dynamicview2/main.cpp b/examples/quick/tutorials/dynamicview/dynamicview2/main.cpp new file mode 100644 index 0000000000..72b8b667f5 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview2/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(dynamicview) diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.pro b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.pro new file mode 100644 index 0000000000..ebc753f2a7 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += dynamicview3.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/dynamicview/dynamicview3 +INSTALLS += target diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.qrc b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.qrc new file mode 100644 index 0000000000..c89a5e3a97 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.qrc @@ -0,0 +1,6 @@ + + + dynamicview.qml + PetsModel.qml + + diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/main.cpp b/examples/quick/tutorials/dynamicview/dynamicview3/main.cpp new file mode 100644 index 0000000000..72b8b667f5 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview3/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(dynamicview) diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.pro b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.pro new file mode 100644 index 0000000000..a5cb99f665 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += dynamicview4.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/dynamicview/dynamicview4 +INSTALLS += target diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.qrc b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.qrc new file mode 100644 index 0000000000..c89a5e3a97 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.qrc @@ -0,0 +1,6 @@ + + + dynamicview.qml + PetsModel.qml + + diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/main.cpp b/examples/quick/tutorials/dynamicview/dynamicview4/main.cpp new file mode 100644 index 0000000000..72b8b667f5 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview4/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(dynamicview) diff --git a/examples/quick/tutorials/samegame/samegame1/main.cpp b/examples/quick/tutorials/samegame/samegame1/main.cpp new file mode 100644 index 0000000000..7589b92906 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame1/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(samegame) diff --git a/examples/quick/tutorials/samegame/samegame1/samegame1.pro b/examples/quick/tutorials/samegame/samegame1/samegame1.pro new file mode 100644 index 0000000000..9f316b6868 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame1/samegame1.pro @@ -0,0 +1,11 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += \ + samegame1.qrc \ + ../shared/pics/shared.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/samegame/samegame1 +INSTALLS += target diff --git a/examples/quick/tutorials/samegame/samegame1/samegame1.qrc b/examples/quick/tutorials/samegame/samegame1/samegame1.qrc new file mode 100644 index 0000000000..866cf899bf --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame1/samegame1.qrc @@ -0,0 +1,7 @@ + + + Button.qml + Block.qml + samegame.qml + + diff --git a/examples/quick/tutorials/samegame/samegame2/main.cpp b/examples/quick/tutorials/samegame/samegame2/main.cpp new file mode 100644 index 0000000000..7589b92906 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame2/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(samegame) diff --git a/examples/quick/tutorials/samegame/samegame2/samegame2.pro b/examples/quick/tutorials/samegame/samegame2/samegame2.pro new file mode 100644 index 0000000000..5ede9042cc --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame2/samegame2.pro @@ -0,0 +1,11 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += \ + samegame2.qrc \ + ../shared/pics/shared.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/samegame/samegame2 +INSTALLS += target diff --git a/examples/quick/tutorials/samegame/samegame2/samegame2.qrc b/examples/quick/tutorials/samegame/samegame2/samegame2.qrc new file mode 100644 index 0000000000..0f95174d83 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame2/samegame2.qrc @@ -0,0 +1,8 @@ + + + Button.qml + Block.qml + samegame.qml + samegame.js + + diff --git a/examples/quick/tutorials/samegame/samegame3/main.cpp b/examples/quick/tutorials/samegame/samegame3/main.cpp new file mode 100644 index 0000000000..7589b92906 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame3/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(samegame) diff --git a/examples/quick/tutorials/samegame/samegame3/samegame3.pro b/examples/quick/tutorials/samegame/samegame3/samegame3.pro new file mode 100644 index 0000000000..7b99673e57 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame3/samegame3.pro @@ -0,0 +1,11 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += \ + samegame3.qrc \ + ../shared/pics/shared.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/samegame/samegame3 +INSTALLS += target diff --git a/examples/quick/tutorials/samegame/samegame3/samegame3.qrc b/examples/quick/tutorials/samegame/samegame3/samegame3.qrc new file mode 100644 index 0000000000..0f95174d83 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame3/samegame3.qrc @@ -0,0 +1,8 @@ + + + Button.qml + Block.qml + samegame.qml + samegame.js + + diff --git a/examples/quick/tutorials/samegame/samegame4/main.cpp b/examples/quick/tutorials/samegame/samegame4/main.cpp new file mode 100644 index 0000000000..7589b92906 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(samegame) diff --git a/examples/quick/tutorials/samegame/samegame4/samegame4.pro b/examples/quick/tutorials/samegame/samegame4/samegame4.pro new file mode 100644 index 0000000000..5da0d46e19 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/samegame4.pro @@ -0,0 +1,11 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += \ + samegame4.qrc \ + ../shared/pics/shared.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/samegame/samegame4 +INSTALLS += target diff --git a/examples/quick/tutorials/samegame/samegame4/samegame4.qrc b/examples/quick/tutorials/samegame/samegame4/samegame4.qrc new file mode 100644 index 0000000000..8b130721f5 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame4/samegame4.qrc @@ -0,0 +1,13 @@ + + + samegame.qml + content/BoomBlock.qml + content/Button.qml + content/Dialog.qml + content/samegame.js + highscores/README + highscores/score_data.xml + highscores/score_style.xsl + highscores/scores.php + + diff --git a/examples/quick/tutorials/samegame/shared/pics/shared.qrc b/examples/quick/tutorials/samegame/shared/pics/shared.qrc new file mode 100644 index 0000000000..8982a9face --- /dev/null +++ b/examples/quick/tutorials/samegame/shared/pics/shared.qrc @@ -0,0 +1,13 @@ + + + background.jpg + blueStar.png + blueStone.png + greenStar.png + greenStone.png + redStar.png + redStone.png + star.png + yellowStone.png + + diff --git a/examples/quick/views/delegatemodel/flipable.pro b/examples/quick/views/delegatemodel/flipable.pro new file mode 100644 index 0000000000..ba00bf792c --- /dev/null +++ b/examples/quick/views/delegatemodel/flipable.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += flipable.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/flipable +INSTALLS += target diff --git a/examples/quick/views/delegatemodel/flipable.qrc b/examples/quick/views/delegatemodel/flipable.qrc new file mode 100644 index 0000000000..7918ccf00e --- /dev/null +++ b/examples/quick/views/delegatemodel/flipable.qrc @@ -0,0 +1,9 @@ + + + flipable.qml + content/5_heart.png + content/9_club.png + content/back.png + content/Card.qml + + diff --git a/examples/quick/views/delegatemodel/main.cpp b/examples/quick/views/delegatemodel/main.cpp new file mode 100644 index 0000000000..a0f0d67d45 --- /dev/null +++ b/examples/quick/views/delegatemodel/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(flipable) -- cgit v1.2.3 From 069afedec9e42c1d3ce6673a405337dfbc309992 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Wed, 4 Mar 2020 17:22:11 +0200 Subject: Examples: add .pro project for qml-i18n example Currently only the .qmlproject is available for this project, which won't deploy on Android, thus adding .pro project files. Also, since the translation won't work without the *.qm files being present as resources, those files are included by default with example. Task-number: QTBUG-80717 Change-Id: I86ac6c4097e4207b7f62d628f9a72439e78639db Reviewed-by: Ulf Hermann --- examples/qml/qml-i18n/doc/src/i18n.qdoc | 2 + examples/qml/qml-i18n/i18n/base.ts | 2 +- examples/qml/qml-i18n/i18n/qml_en_AU.ts | 2 +- examples/qml/qml-i18n/i18n/qml_fr.ts | 2 +- examples/qml/qml-i18n/main.cpp | 68 +++++++++++++++++++++++++++++++++ examples/qml/qml-i18n/qml-i18n.pro | 17 +++++++++ examples/qml/qml-i18n/qml-i18n.qml | 10 +++-- examples/qml/qml-i18n/qml-i18n.qrc | 5 +++ 8 files changed, 101 insertions(+), 7 deletions(-) create mode 100644 examples/qml/qml-i18n/main.cpp create mode 100644 examples/qml/qml-i18n/qml-i18n.pro create mode 100644 examples/qml/qml-i18n/qml-i18n.qrc diff --git a/examples/qml/qml-i18n/doc/src/i18n.qdoc b/examples/qml/qml-i18n/doc/src/i18n.qdoc index dbc4efa58c..48946aac9c 100644 --- a/examples/qml/qml-i18n/doc/src/i18n.qdoc +++ b/examples/qml/qml-i18n/doc/src/i18n.qdoc @@ -52,4 +52,6 @@ lrelease i18n/*.ts \endcode +\note On Android, please make sure to include the generated *.qm files as resources. + */ diff --git a/examples/qml/qml-i18n/i18n/base.ts b/examples/qml/qml-i18n/i18n/base.ts index 77c640f370..99ceeeb016 100644 --- a/examples/qml/qml-i18n/i18n/base.ts +++ b/examples/qml/qml-i18n/i18n/base.ts @@ -4,7 +4,7 @@ qml-i18n - + Hello diff --git a/examples/qml/qml-i18n/i18n/qml_en_AU.ts b/examples/qml/qml-i18n/i18n/qml_en_AU.ts index 86ccfb7bf8..feb4f9e9c0 100644 --- a/examples/qml/qml-i18n/i18n/qml_en_AU.ts +++ b/examples/qml/qml-i18n/i18n/qml_en_AU.ts @@ -4,7 +4,7 @@ qml-i18n - + Hello G'day diff --git a/examples/qml/qml-i18n/i18n/qml_fr.ts b/examples/qml/qml-i18n/i18n/qml_fr.ts index 363bebb395..c4872e63d0 100644 --- a/examples/qml/qml-i18n/i18n/qml_fr.ts +++ b/examples/qml/qml-i18n/i18n/qml_fr.ts @@ -4,7 +4,7 @@ qml-i18n - + Hello Bonjour diff --git a/examples/qml/qml-i18n/main.cpp b/examples/qml/qml-i18n/main.cpp new file mode 100644 index 0000000000..0680dc8b41 --- /dev/null +++ b/examples/qml/qml-i18n/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + const QUrl url(QStringLiteral("qrc:/qml-i18n.qml")); + + QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, + &app, [url](QObject *obj, const QUrl &objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/examples/qml/qml-i18n/qml-i18n.pro b/examples/qml/qml-i18n/qml-i18n.pro new file mode 100644 index 0000000000..847c741b00 --- /dev/null +++ b/examples/qml/qml-i18n/qml-i18n.pro @@ -0,0 +1,17 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +RESOURCES += qml-i18n.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qml/qml-i18n +INSTALLS += target + +CONFIG += lrelease embed_translations + +TRANSLATIONS += \ + i18n/base.ts \ + i18n/qml_en.ts \ + i18n/qml_en_AU.ts \ + i18n/qml_fr.ts diff --git a/examples/qml/qml-i18n/qml-i18n.qml b/examples/qml/qml-i18n/qml-i18n.qml index 217ffb56ae..85c4c44160 100644 --- a/examples/qml/qml-i18n/qml-i18n.qml +++ b/examples/qml/qml-i18n/qml-i18n.qml @@ -48,17 +48,19 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.12 +import QtQuick.Window 2.12 -Rectangle { +Window { + visible: true width: 640; height: 480 Column { anchors.fill: parent; spacing: 20 Text { - text: "If a translation is available for the system language (eg. French) then the "+ - "string below will translated (eg. 'Bonjour'). Otherwise it will show 'Hello'." + text: "If a translation is available for the system language (eg. French) then the " + + "string below will be translated (eg. 'Bonjour'). Otherwise it will show 'Hello'." width: parent.width; wrapMode: Text.WordWrap } diff --git a/examples/qml/qml-i18n/qml-i18n.qrc b/examples/qml/qml-i18n/qml-i18n.qrc new file mode 100644 index 0000000000..3a505b1665 --- /dev/null +++ b/examples/qml/qml-i18n/qml-i18n.qrc @@ -0,0 +1,5 @@ + + + qml-i18n.qml + + -- cgit v1.2.3 From ec33541cf3873bc311522d3ae24c75cf6aa28a6b Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 6 Mar 2020 08:07:56 +0100 Subject: Doc: clarify the fontSizeMode property in terms of Rich and Styled text Fixes: QTBUG-56650 Change-Id: I7b750031f3af368de7f7cebe64a5d1ce77f68408 Reviewed-by: Paul Wicking --- src/quick/items/qquicktext.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index f39e8e0316..216914197f 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -2650,6 +2650,12 @@ void QQuickText::setLineHeightMode(LineHeightMode mode) If the text does not fit within the item bounds with the minimum font size the text will be elided as per the \l elide property. + + If the \l textFormat property is set to \l Text.RichText, this will have no effect at all as the + property will be ignored completely. If \l textFormat is set to \l Text.StyledText, then the + property will be respected provided there is no font size tags inside the text. If there are + font size tags, the property will still respect those. This can cause it to not fully comply with + the fontSizeMode setting. */ QQuickText::FontSizeMode QQuickText::fontSizeMode() const -- cgit v1.2.3 From 12ddd8da1b2dcfbbca10a6915547456601a726c0 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 6 Mar 2020 11:11:32 +0100 Subject: Avoid using deprecated QTabletEvent::device() That member was removed in qtbase dev. Change-Id: Ia2e69ee53e154fdb9b8b4c707ac5a463011cf0c1 Reviewed-by: Shawn Rutledge --- src/quick/items/qquickevents.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 2b3ea7d63d..15f138583f 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -680,7 +680,7 @@ QQuickPointerDevice *QQuickPointerDevice::tabletDevice(const QTabletEvent *event // TODO Qt 6: we can't know for sure about XTilt or YTilt until we have a // QTabletDevice populated with capabilities provided by QPA plugins - switch (event->device()) { + switch (event->deviceType()) { case QTabletEvent::Stylus: type = QQuickPointerDevice::Stylus; buttonCount = 3; -- cgit v1.2.3