diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-10-22 12:05:18 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-10-22 12:26:28 +0200 |
commit | aceb0d0cd2da89aebbf17729869b9e977290c826 (patch) | |
tree | b29e815e32277710058bc32c571281937183fd43 /src | |
parent | 6ecbe6441f825489b5fafde1a274952933254c7f (diff) | |
parent | 1bb9c7b517e7995201d2a31cd1e852c02ad8c1bc (diff) |
Merge remote-tracking branch 'origin/dev' into HEAD
Conflicts:
src/qml/compiler/qv4codegen.cpp
src/qml/compiler/qv4compileddata.cpp
src/qml/compiler/qv4compileddata_p.h
src/qml/compiler/qv4isel_moth_p.h
src/qml/compiler/qv4ssa.cpp
src/qml/jit/qv4assembler_p.h
src/qml/jit/qv4isel_masm_p.h
src/qml/jit/qv4regalloc.cpp
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4qmlcontext_p.h
src/qml/jsruntime/qv4regexp.cpp
src/qml/jsruntime/qv4regexp_p.h
src/qml/jsruntime/qv4regexpobject.cpp
src/qml/jsruntime/qv4runtime.cpp
src/qml/jsruntime/qv4vme_moth.cpp
src/qml/qml/v8/qqmlbuiltinfunctions.cpp
tests/auto/qml/qml.pro
tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
tools/qmlcachegen/qmlcachegen.cpp
Change-Id: I1577e195c736f3414089036b957a01cb91a3ca23
Diffstat (limited to 'src')
202 files changed, 1649 insertions, 1016 deletions
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index ef719109bd..2b58a5677a 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -59,7 +59,7 @@ class QmlFolderListModelPlugin : public QQmlExtensionPlugin public: QmlFolderListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel")); qmlRegisterType<QQuickFolderListModel>(uri,1,0,"FolderListModel"); diff --git a/src/imports/handlers/plugin.cpp b/src/imports/handlers/plugin.cpp index bc1ae244d3..d26ef2b2d4 100644 --- a/src/imports/handlers/plugin.cpp +++ b/src/imports/handlers/plugin.cpp @@ -74,7 +74,7 @@ class QtQuickHandlersPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuickHandlersPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.handlers")); Q_UNUSED(uri); diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp index da5f264ab5..fc3938c5d8 100644 --- a/src/imports/layouts/plugin.cpp +++ b/src/imports/layouts/plugin.cpp @@ -61,7 +61,7 @@ public: { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Layouts")); Q_UNUSED(uri); diff --git a/src/imports/layouts/qquicklayout_p.h b/src/imports/layouts/qquicklayout_p.h index 113498eb2b..7984e1bd4d 100644 --- a/src/imports/layouts/qquicklayout_p.h +++ b/src/imports/layouts/qquicklayout_p.h @@ -75,7 +75,7 @@ public: static QQuickLayoutAttached *qmlAttachedProperties(QObject *object); - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; virtual QSizeF sizeHint(Qt::SizeHint whichSizeHint) const = 0; virtual void setAlignment(QQuickItem *item, Qt::Alignment align) = 0; virtual void invalidate(QQuickItem * childItem = 0); @@ -92,21 +92,21 @@ public: static QLayoutPolicy::Policy effectiveSizePolicy_helper(QQuickItem *item, Qt::Orientation orientation, QQuickLayoutAttached *info); bool shouldIgnoreItem(QQuickItem *child, QQuickLayoutAttached *&info, QSizeF *sizeHints) const; - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; bool isReady() const; void deactivateRecur(); /* QQuickItemChangeListener */ - void itemSiblingOrderChanged(QQuickItem *item) Q_DECL_OVERRIDE; - void itemImplicitWidthChanged(QQuickItem *item) Q_DECL_OVERRIDE; - void itemImplicitHeightChanged(QQuickItem *item) Q_DECL_OVERRIDE; - void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; - void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE; + void itemSiblingOrderChanged(QQuickItem *item) override; + void itemImplicitWidthChanged(QQuickItem *item) override; + void itemImplicitHeightChanged(QQuickItem *item) override; + void itemDestroyed(QQuickItem *item) override; + void itemVisibilityChanged(QQuickItem *item) override; protected: - void updatePolish() Q_DECL_OVERRIDE; + void updatePolish() override; enum Orientation { Vertical = 0, diff --git a/src/imports/layouts/qquicklayoutstyleinfo_p.h b/src/imports/layouts/qquicklayoutstyleinfo_p.h index ce86c2a37d..79f4ce2962 100644 --- a/src/imports/layouts/qquicklayoutstyleinfo_p.h +++ b/src/imports/layouts/qquicklayoutstyleinfo_p.h @@ -49,9 +49,9 @@ class QQuickLayoutStyleInfo : public QAbstractLayoutStyleInfo public: QQuickLayoutStyleInfo(); - qreal spacing(Qt::Orientation orientation) const Q_DECL_OVERRIDE; - qreal windowMargin(Qt::Orientation orientation) const Q_DECL_OVERRIDE; - bool hasChangedCore() const Q_DECL_OVERRIDE; + qreal spacing(Qt::Orientation orientation) const override; + qreal windowMargin(Qt::Orientation orientation) const override; + bool hasChangedCore() const override; }; diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h index f796c8a855..6706ebf9fa 100644 --- a/src/imports/layouts/qquicklinearlayout_p.h +++ b/src/imports/layouts/qquicklinearlayout_p.h @@ -67,26 +67,26 @@ public: QQuickItem *parent = 0); ~QQuickGridLayoutBase(); - void componentComplete() Q_DECL_OVERRIDE; - void invalidate(QQuickItem *childItem = 0) Q_DECL_OVERRIDE; + void componentComplete() override; + void invalidate(QQuickItem *childItem = 0) override; Qt::Orientation orientation() const; void setOrientation(Qt::Orientation orientation); - QSizeF sizeHint(Qt::SizeHint whichSizeHint) const Q_DECL_OVERRIDE; + QSizeF sizeHint(Qt::SizeHint whichSizeHint) const override; Qt::LayoutDirection layoutDirection() const; void setLayoutDirection(Qt::LayoutDirection dir); Qt::LayoutDirection effectiveLayoutDirection() const; - void setAlignment(QQuickItem *item, Qt::Alignment align) Q_DECL_OVERRIDE; + void setAlignment(QQuickItem *item, Qt::Alignment align) override; /* QQuickItemChangeListener */ - void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; - void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE; + void itemDestroyed(QQuickItem *item) override; + void itemVisibilityChanged(QQuickItem *item) override; protected: - void updateLayoutItems() Q_DECL_OVERRIDE; - QQuickItem *itemAt(int index) const Q_DECL_OVERRIDE; - int itemCount() const Q_DECL_OVERRIDE; + void updateLayoutItems() override; + QQuickItem *itemAt(int index) const override; + int itemCount() const override; - void rearrange(const QSizeF &size) Q_DECL_OVERRIDE; + void rearrange(const QSizeF &size) override; virtual void insertLayoutItems() {} signals: @@ -109,7 +109,7 @@ public: , m_layoutDirection(Qt::LeftToRight) {} - void mirrorChange() Q_DECL_OVERRIDE + void mirrorChange() override { Q_Q(QQuickGridLayoutBase); q->invalidate(); diff --git a/src/imports/layouts/qquickstacklayout_p.h b/src/imports/layouts/qquickstacklayout_p.h index 7b6400c3a3..8ba41720aa 100644 --- a/src/imports/layouts/qquickstacklayout_p.h +++ b/src/imports/layouts/qquickstacklayout_p.h @@ -56,16 +56,16 @@ public: int currentIndex() const; void setCurrentIndex(int index); - void componentComplete() Q_DECL_OVERRIDE; - QSizeF sizeHint(Qt::SizeHint whichSizeHint) const Q_DECL_OVERRIDE; - void setAlignment(QQuickItem *item, Qt::Alignment align) Q_DECL_OVERRIDE; - void invalidate(QQuickItem *childItem = 0) Q_DECL_OVERRIDE; - void updateLayoutItems() Q_DECL_OVERRIDE; - void rearrange(const QSizeF &) Q_DECL_OVERRIDE; + void componentComplete() override; + QSizeF sizeHint(Qt::SizeHint whichSizeHint) const override; + void setAlignment(QQuickItem *item, Qt::Alignment align) override; + void invalidate(QQuickItem *childItem = 0) override; + void updateLayoutItems() override; + void rearrange(const QSizeF &) override; // iterator - Q_INVOKABLE QQuickItem *itemAt(int index) const Q_DECL_OVERRIDE; - int itemCount() const Q_DECL_OVERRIDE; + Q_INVOKABLE QQuickItem *itemAt(int index) const override; + int itemCount() const override; int indexOf(QQuickItem *item) const; diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 4af3be715f..3781a776a1 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -794,7 +794,7 @@ public: { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.LocalStorage")); qmlRegisterSingletonType<QQuickLocalStorage>(uri, 2, 0, "LocalStorage", module_api_factory); diff --git a/src/imports/models/plugin.cpp b/src/imports/models/plugin.cpp index dbb62cd25d..5933128713 100644 --- a/src/imports/models/plugin.cpp +++ b/src/imports/models/plugin.cpp @@ -78,7 +78,7 @@ class QtQmlModelsPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQmlModelsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQml.Models")); Q_UNUSED(uri); diff --git a/src/imports/particles/plugin.cpp b/src/imports/particles/plugin.cpp index 28ce0f7796..f7a3472403 100644 --- a/src/imports/particles/plugin.cpp +++ b/src/imports/particles/plugin.cpp @@ -57,7 +57,7 @@ class QtQuick2ParticlesPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2ParticlesPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Particles")); Q_UNUSED(uri); diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp index d16467a5bb..a5b2c8c67e 100644 --- a/src/imports/qtquick2/plugin.cpp +++ b/src/imports/qtquick2/plugin.cpp @@ -57,7 +57,7 @@ class QtQuick2Plugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2Plugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick")); Q_UNUSED(uri); diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp index c422296446..70d24c12cd 100644 --- a/src/imports/settings/plugin.cpp +++ b/src/imports/settings/plugin.cpp @@ -58,7 +58,7 @@ class QmlSettingsPlugin : public QQmlExtensionPlugin public: QmlSettingsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QByteArray(uri) == QByteArray("Qt.labs.settings")); qmlRegisterType<QQmlSettings>(uri, 1, 0, "Settings"); diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index ed2f58e7c1..f6040e7a64 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -189,6 +189,9 @@ QT_BEGIN_NAMESPACE only provides a cleaner settings structure, but also prevents possible conflicts between setting keys. + If several categories are required, use several Settings objects, each with + their own category: + \qml Item { id: panel @@ -200,6 +203,12 @@ QT_BEGIN_NAMESPACE property alias visible: panel.visible // ... } + + Settings { + category: "General" + property alias fontSize: fontSizeSpinBox.value + // ... + } } \endqml diff --git a/src/imports/shapes/plugin.cpp b/src/imports/shapes/plugin.cpp index 239ef78e55..c509d28e33 100644 --- a/src/imports/shapes/plugin.cpp +++ b/src/imports/shapes/plugin.cpp @@ -59,7 +59,7 @@ class QmlShapesPlugin : public QQmlExtensionPlugin public: QmlShapesPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QByteArray(uri) == QByteArray("QtQuick.Shapes")); qmlRegisterType<QQuickShape>(uri, 1, 0, "Shape"); diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp index ae32f6446a..7308df8964 100644 --- a/src/imports/statemachine/plugin.cpp +++ b/src/imports/statemachine/plugin.cpp @@ -63,7 +63,7 @@ class QtQmlStateMachinePlugin : public QQmlExtensionPlugin public: QtQmlStateMachinePlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { qmlRegisterType<State>(uri, 1, 0, "State"); qmlRegisterType<StateMachine>(uri, 1, 0, "StateMachine"); diff --git a/src/imports/statemachine/signaltransition.h b/src/imports/statemachine/signaltransition.h index c6512e2b19..3b3a7dae79 100644 --- a/src/imports/statemachine/signaltransition.h +++ b/src/imports/statemachine/signaltransition.h @@ -64,8 +64,8 @@ public: QQmlScriptString guard() const; void setGuard(const QQmlScriptString &guard); - bool eventTest(QEvent *event) Q_DECL_OVERRIDE; - void onTransition(QEvent *event) Q_DECL_OVERRIDE; + bool eventTest(QEvent *event) override; + void onTransition(QEvent *event) override; const QJSValue &signal(); void setSignal(const QJSValue &signal); @@ -81,8 +81,8 @@ Q_SIGNALS: void qmlSignalChanged(); private: - void classBegin() Q_DECL_OVERRIDE { m_complete = false; } - void componentComplete() Q_DECL_OVERRIDE { m_complete = true; connectTriggered(); } + void classBegin() override { m_complete = false; } + void componentComplete() override { m_complete = true; connectTriggered(); } void connectTriggered(); friend class SignalTransitionParser; @@ -97,8 +97,8 @@ private: class SignalTransitionParser : public QQmlCustomParser { public: - void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) Q_DECL_OVERRIDE; - void applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) Q_DECL_OVERRIDE; + void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override; + void applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; }; QT_END_NAMESPACE diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 18af7e0ab0..0e7e09c65c 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -1739,11 +1739,6 @@ Item { /*! \internal */ function qtest_run() { - if (util.printAvailableFunctions) { - completed = true - return - } - if (TestLogger.log_start_test()) { qtest_results.reset() qtest_results.testCaseName = name @@ -1894,29 +1889,9 @@ Item { } } - Component.onCompleted: { QTestRootObject.hasTestCase = true; qtest_componentCompleted = true; - - if (util.printAvailableFunctions) { - var testList = [] - for (var prop in testCase) { - if (prop.indexOf("test_") != 0 && prop.indexOf("benchmark_") != 0) - continue - var tail = prop.lastIndexOf("_data"); - if (tail != -1 && tail == (prop.length - 5)) - continue - // Note: cannot run functions in TestCase elements - // that lack a name. - if (name.length > 0) - testList.push(name + "::" + prop + "()") - } - testList.sort() - for (var index in testList) - console.log(testList[index]) - return - } qtest_testId = TestLogger.log_register_test(name) if (optional) TestLogger.log_optional_test(qtest_testId) diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index fc013d5afc..2dbe8e08dc 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -151,7 +151,7 @@ class QTestQmlModule : public QQmlExtensionPlugin public: QTestQmlModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest")); qmlRegisterType<QuickTestResult, 0>(uri,1,0,"TestResult"); diff --git a/src/imports/window/plugin.cpp b/src/imports/window/plugin.cpp index 200f6f7b08..c4ea9a1d04 100644 --- a/src/imports/window/plugin.cpp +++ b/src/imports/window/plugin.cpp @@ -73,7 +73,7 @@ class QtQuick2WindowPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtQuick2WindowPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Window")); Q_UNUSED(uri); diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp index af7625c96a..dc6a02918b 100644 --- a/src/imports/xmllistmodel/plugin.cpp +++ b/src/imports/xmllistmodel/plugin.cpp @@ -58,7 +58,7 @@ class QmlXmlListModelPlugin : public QQmlExtensionPlugin public: QmlXmlListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.XmlListModel")); qmlRegisterType<QQuickXmlListModel>(uri,2,0,"XmlListModel"); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h index 2e40eb4de8..c0c24058eb 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h @@ -95,17 +95,17 @@ public: bool hasNotifySignal; }; - void engineAboutToBeAdded(QJSEngine *) Q_DECL_OVERRIDE; - void engineAboutToBeRemoved(QJSEngine *) Q_DECL_OVERRIDE; - void objectCreated(QJSEngine *, QObject *) Q_DECL_OVERRIDE; + void engineAboutToBeAdded(QJSEngine *) override; + void engineAboutToBeRemoved(QJSEngine *) override; + void objectCreated(QJSEngine *, QObject *) override; - void setStatesDelegate(QQmlDebugStatesDelegate *) Q_DECL_OVERRIDE; + void setStatesDelegate(QQmlDebugStatesDelegate *) override; signals: void scheduleMessage(const QByteArray &); protected: - virtual void messageReceived(const QByteArray &) Q_DECL_OVERRIDE; + void messageReceived(const QByteArray &) override; private: friend class QQmlDebuggerServiceFactory; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index ef62774d66..b4216663ac 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -426,7 +426,7 @@ QV4::ReturnedValue QV4DataCollector::getValue(Ref ref) QV4::Scope scope(engine()); QV4::ScopedObject array(scope, m_values.value()); Q_ASSERT(ref < array->getLength()); - return array->getIndexed(ref, Q_NULLPTR); + return array->getIndexed(ref, nullptr); } // TODO: Drop this method once we don't need to support namesAsObjects anymore diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h index 42f4534015..4a755f2b72 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h @@ -129,14 +129,14 @@ public: void runInEngine(QV4DebugJob *job); // compile-time interface - void maybeBreakAtInstruction() Q_DECL_OVERRIDE; + void maybeBreakAtInstruction() override; // execution hooks - void enteringFunction() Q_DECL_OVERRIDE; - void leavingFunction(const QV4::ReturnedValue &retVal) Q_DECL_OVERRIDE; - void aboutToThrow() Q_DECL_OVERRIDE; + void enteringFunction() override; + void leavingFunction(const QV4::ReturnedValue &retVal) override; + void aboutToThrow() override; - bool pauseAtNextOpportunity() const Q_DECL_OVERRIDE; + bool pauseAtNextOpportunity() const override; signals: void debuggerPaused(QV4Debugger *self, QV4Debugger::PauseReason reason); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h index bb13890ae4..8a01061ec2 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h @@ -73,14 +73,14 @@ class QV4DebugServiceImpl : public QQmlConfigurableDebugService<QV4DebugService> Q_OBJECT public: explicit QV4DebugServiceImpl(QObject *parent = 0); - ~QV4DebugServiceImpl() Q_DECL_OVERRIDE; + ~QV4DebugServiceImpl() override; - void engineAdded(QJSEngine *engine) Q_DECL_OVERRIDE; - void engineAboutToBeRemoved(QJSEngine *engine) Q_DECL_OVERRIDE; + void engineAdded(QJSEngine *engine) override; + void engineAboutToBeRemoved(QJSEngine *engine) override; - void stateAboutToBeChanged(State state) Q_DECL_OVERRIDE; + void stateAboutToBeChanged(State state) override; - void signalEmitted(const QString &signal) Q_DECL_OVERRIDE; + void signalEmitted(const QString &signal) override; void send(QJsonObject v8Payload); int selectedFrame() const; @@ -92,7 +92,7 @@ public: QV4DebuggerAgent debuggerAgent; protected: - void messageReceived(const QByteArray &) Q_DECL_OVERRIDE; + void messageReceived(const QByteArray &) override; void sendSomethingToSomebody(const char *type, int magicNumber = 1); private: diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp index ab1aeebf64..d0d8d62615 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp @@ -51,15 +51,15 @@ class QQmlInspectorServiceImpl : public QQmlInspectorService public: QQmlInspectorServiceImpl(QObject *parent = 0); - void addWindow(QQuickWindow *window) Q_DECL_OVERRIDE; - void setParentWindow(QQuickWindow *window, QWindow *parent) Q_DECL_OVERRIDE; - void removeWindow(QQuickWindow *window) Q_DECL_OVERRIDE; + void addWindow(QQuickWindow *window) override; + void setParentWindow(QQuickWindow *window, QWindow *parent) override; + void removeWindow(QQuickWindow *window) override; signals: void scheduleMessage(const QByteArray &message); protected: - virtual void messageReceived(const QByteArray &) Q_DECL_OVERRIDE; + void messageReceived(const QByteArray &) override; private: friend class QQmlInspectorServiceFactory; diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h index f8b7e1d527..a7f37b0f1e 100644 --- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h +++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h @@ -51,16 +51,16 @@ class QQmlNativeDebugConnector : public QQmlDebugConnector public: QQmlNativeDebugConnector(); - ~QQmlNativeDebugConnector() Q_DECL_OVERRIDE; + ~QQmlNativeDebugConnector() override; - bool blockingMode() const Q_DECL_OVERRIDE; - QQmlDebugService *service(const QString &name) const Q_DECL_OVERRIDE; - void addEngine(QJSEngine *engine) Q_DECL_OVERRIDE; - void removeEngine(QJSEngine *engine) Q_DECL_OVERRIDE; - bool hasEngine(QJSEngine *engine) const Q_DECL_OVERRIDE; - bool addService(const QString &name, QQmlDebugService *service) Q_DECL_OVERRIDE; - bool removeService(const QString &name) Q_DECL_OVERRIDE; - bool open(const QVariantHash &configuration) Q_DECL_OVERRIDE; + bool blockingMode() const override; + QQmlDebugService *service(const QString &name) const override; + void addEngine(QJSEngine *engine) override; + void removeEngine(QJSEngine *engine) override; + bool hasEngine(QJSEngine *engine) const override; + bool addService(const QString &name, QQmlDebugService *service) override; + bool removeService(const QString &name) override; + bool open(const QVariantHash &configuration) override; static void setDataStreamVersion(int version); private: diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 1eaa2819af..cb5d2d4c1b 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -187,16 +187,16 @@ public: QV4::ExecutionEngine *engine() const { return m_engine; } - bool pauseAtNextOpportunity() const Q_DECL_OVERRIDE { + bool pauseAtNextOpportunity() const override { return m_pauseRequested || m_service->m_breakHandler->m_haveBreakPoints || m_stepping >= StepOver; } - void maybeBreakAtInstruction() Q_DECL_OVERRIDE; - void enteringFunction() Q_DECL_OVERRIDE; - void leavingFunction(const QV4::ReturnedValue &retVal) Q_DECL_OVERRIDE; - void aboutToThrow() Q_DECL_OVERRIDE; + void maybeBreakAtInstruction() override; + void enteringFunction() override; + void leavingFunction(const QV4::ReturnedValue &retVal) override; + void aboutToThrow() override; void handleCommand(QJsonObject *response, const QString &cmd, const QJsonObject &arguments); diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.h b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.h index 58bf1bc94a..4b4661be2f 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.h +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.h @@ -73,14 +73,14 @@ class QQmlNativeDebugServiceImpl : public QQmlNativeDebugService public: QQmlNativeDebugServiceImpl(QObject *parent); - ~QQmlNativeDebugServiceImpl() Q_DECL_OVERRIDE; + ~QQmlNativeDebugServiceImpl() override; - void engineAboutToBeAdded(QJSEngine *engine) Q_DECL_OVERRIDE; - void engineAboutToBeRemoved(QJSEngine *engine) Q_DECL_OVERRIDE; + void engineAboutToBeAdded(QJSEngine *engine) override; + void engineAboutToBeRemoved(QJSEngine *engine) override; - void stateAboutToBeChanged(State state) Q_DECL_OVERRIDE; + void stateAboutToBeChanged(State state) override; - void messageReceived(const QByteArray &message) Q_DECL_OVERRIDE; + void messageReceived(const QByteArray &message) override; void emitAsynchronousMessageToClient(const QJsonObject &message); diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h index 6392944519..3c5daa0f4f 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h @@ -81,15 +81,15 @@ protected: QList<QJSEngine *> stoppingEngines; bool blockingMode; - void messageReceived(const QByteArray &) Q_DECL_OVERRIDE; - void engineAboutToBeAdded(QJSEngine *) Q_DECL_OVERRIDE; - void engineAboutToBeRemoved(QJSEngine *) Q_DECL_OVERRIDE; - void engineAdded(QJSEngine *) Q_DECL_OVERRIDE; - void engineRemoved(QJSEngine *) Q_DECL_OVERRIDE; + void messageReceived(const QByteArray &) override; + void engineAboutToBeAdded(QJSEngine *) override; + void engineAboutToBeRemoved(QJSEngine *) override; + void engineAdded(QJSEngine *) override; + void engineRemoved(QJSEngine *) override; void sendMessage(MessageType type, QJSEngine *engine); - void stateChanged(State) Q_DECL_OVERRIDE; + void stateChanged(State) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp index 510c745d4e..d676731ba7 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp @@ -44,24 +44,36 @@ QT_BEGIN_NAMESPACE -QQmlProfilerAdapter::QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine) : - next(0) +QQmlProfilerAdapter::QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine) { - setService(service); engine->profiler = new QQmlProfiler; + init(service, engine->profiler); +} + +QQmlProfilerAdapter::QQmlProfilerAdapter(QQmlProfilerService *service, QQmlTypeLoader *loader) +{ + QQmlProfiler *profiler = new QQmlProfiler; + loader->setProfiler(profiler); + init(service, profiler); +} + +void QQmlProfilerAdapter::init(QQmlProfilerService *service, QQmlProfiler *profiler) +{ + next = 0; + setService(service); connect(this, &QQmlProfilerAdapter::profilingEnabled, - engine->profiler, &QQmlProfiler::startProfiling); + profiler, &QQmlProfiler::startProfiling); connect(this, &QQmlAbstractProfilerAdapter::profilingEnabledWhileWaiting, - engine->profiler, &QQmlProfiler::startProfiling, Qt::DirectConnection); + profiler, &QQmlProfiler::startProfiling, Qt::DirectConnection); connect(this, &QQmlAbstractProfilerAdapter::profilingDisabled, - engine->profiler, &QQmlProfiler::stopProfiling); + profiler, &QQmlProfiler::stopProfiling); connect(this, &QQmlAbstractProfilerAdapter::profilingDisabledWhileWaiting, - engine->profiler, &QQmlProfiler::stopProfiling, Qt::DirectConnection); + profiler, &QQmlProfiler::stopProfiling, Qt::DirectConnection); connect(this, &QQmlAbstractProfilerAdapter::dataRequested, - engine->profiler, &QQmlProfiler::reportData); + profiler, &QQmlProfiler::reportData); connect(this, &QQmlAbstractProfilerAdapter::referenceTimeKnown, - engine->profiler, &QQmlProfiler::setTimer); - connect(engine->profiler, &QQmlProfiler::dataReady, + profiler, &QQmlProfiler::setTimer); + connect(profiler, &QQmlProfiler::dataReady, this, &QQmlProfilerAdapter::receiveData); } diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h index 1fee5c389f..b14b72d254 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h @@ -60,13 +60,15 @@ class QQmlProfilerAdapter : public QQmlAbstractProfilerAdapter { Q_OBJECT public: QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine); + QQmlProfilerAdapter(QQmlProfilerService *service, QQmlTypeLoader *loader); qint64 sendMessages(qint64 until, QList<QByteArray> &messages, - bool trackLocations) Q_DECL_OVERRIDE; + bool trackLocations) override; void receiveData(const QVector<QQmlProfilerData> &new_data, const QQmlProfiler::LocationHash &locations); private: + void init(QQmlProfilerService *service, QQmlProfiler *profiler); QVector<QQmlProfilerData> data; QQmlProfiler::LocationHash locations; int next; diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp index edeb364f60..4176ede40e 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp @@ -119,9 +119,12 @@ void QQmlProfilerServiceImpl::engineAboutToBeAdded(QJSEngine *engine) QMutexLocker lock(&m_configMutex); if (QQmlEngine *qmlEngine = qobject_cast<QQmlEngine *>(engine)) { - QQmlProfilerAdapter *qmlAdapter = - new QQmlProfilerAdapter(this, QQmlEnginePrivate::get(qmlEngine)); + QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(qmlEngine); + QQmlProfilerAdapter *qmlAdapter = new QQmlProfilerAdapter(this, enginePrivate); addEngineProfiler(qmlAdapter, engine); + QQmlProfilerAdapter *compileAdapter + = new QQmlProfilerAdapter(this, &(enginePrivate->typeLoader)); + addEngineProfiler(compileAdapter, engine); } QV4ProfilerAdapter *v4Adapter = new QV4ProfilerAdapter(this, QV8Engine::getV4(engine->handle())); addEngineProfiler(v4Adapter, engine); diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h index bbfc32b681..e6f89e850a 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h @@ -78,30 +78,30 @@ class QQmlProfilerServiceImpl : Q_OBJECT public: - void engineAboutToBeAdded(QJSEngine *engine) Q_DECL_OVERRIDE; - void engineAboutToBeRemoved(QJSEngine *engine) Q_DECL_OVERRIDE; - void engineAdded(QJSEngine *engine) Q_DECL_OVERRIDE; - void engineRemoved(QJSEngine *engine) Q_DECL_OVERRIDE; + void engineAboutToBeAdded(QJSEngine *engine) override; + void engineAboutToBeRemoved(QJSEngine *engine) override; + void engineAdded(QJSEngine *engine) override; + void engineRemoved(QJSEngine *engine) override; - void addGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) Q_DECL_OVERRIDE; - void removeGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) Q_DECL_OVERRIDE; + void addGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) override; + void removeGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) override; void startProfiling(QJSEngine *engine, - quint64 features = std::numeric_limits<quint64>::max()) Q_DECL_OVERRIDE; - void stopProfiling(QJSEngine *engine) Q_DECL_OVERRIDE; + quint64 features = std::numeric_limits<quint64>::max()) override; + void stopProfiling(QJSEngine *engine) override; QQmlProfilerServiceImpl(QObject *parent = 0); - ~QQmlProfilerServiceImpl() Q_DECL_OVERRIDE; + ~QQmlProfilerServiceImpl() override; - void dataReady(QQmlAbstractProfilerAdapter *profiler) Q_DECL_OVERRIDE; + void dataReady(QQmlAbstractProfilerAdapter *profiler) override; signals: void startFlushTimer(); void stopFlushTimer(); protected: - virtual void stateAboutToBeChanged(State state) Q_DECL_OVERRIDE; - virtual void messageReceived(const QByteArray &) Q_DECL_OVERRIDE; + void stateAboutToBeChanged(State state) override; + void messageReceived(const QByteArray &) override; private: friend class QQmlProfilerServiceFactory; diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp index 0a7421842a..59848ceb82 100644 --- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp +++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp @@ -131,19 +131,19 @@ class QQmlDebugServerImpl : public QQmlDebugServer public: QQmlDebugServerImpl(); - bool blockingMode() const Q_DECL_OVERRIDE; + bool blockingMode() const override; - QQmlDebugService *service(const QString &name) const Q_DECL_OVERRIDE; + QQmlDebugService *service(const QString &name) const override; - void addEngine(QJSEngine *engine) Q_DECL_OVERRIDE; - void removeEngine(QJSEngine *engine) Q_DECL_OVERRIDE; - bool hasEngine(QJSEngine *engine) const Q_DECL_OVERRIDE; + void addEngine(QJSEngine *engine) override; + void removeEngine(QJSEngine *engine) override; + bool hasEngine(QJSEngine *engine) const override; - bool addService(const QString &name, QQmlDebugService *service) Q_DECL_OVERRIDE; - bool removeService(const QString &name) Q_DECL_OVERRIDE; + bool addService(const QString &name, QQmlDebugService *service) override; + bool removeService(const QString &name) override; - bool open(const QVariantHash &configuration) Q_DECL_OVERRIDE; - void setDevice(QIODevice *socket) Q_DECL_OVERRIDE; + bool open(const QVariantHash &configuration) override; + void setDevice(QIODevice *socket) override; void parseArguments(); diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro index 27c51b53c8..5895169ca0 100644 --- a/src/plugins/qmltooling/qmltooling.pro +++ b/src/plugins/qmltooling/qmltooling.pro @@ -19,17 +19,19 @@ qtConfig(qml-network) { qmldbg_tcp } +# Services +SUBDIRS += \ + qmldbg_messages \ + qmldbg_profiler +qmldbg_messages.depends = packetprotocol +qmldbg_profiler.depends = packetprotocol + qtConfig(qml-interpreter) { - # Services SUBDIRS += \ qmldbg_debugger \ - qmldbg_profiler \ - qmldbg_messages \ qmldbg_nativedebugger qmldbg_debugger.depends = packetprotocol - qmldbg_profiler.depends = packetprotocol - qmldbg_messages.depends = packetprotocol qmldbg_nativedebugger.depends = packetprotocol } diff --git a/src/plugins/qmltooling/shared/qqmlconfigurabledebugservice.h b/src/plugins/qmltooling/shared/qqmlconfigurabledebugservice.h index 85ff9b182f..89ac734e05 100644 --- a/src/plugins/qmltooling/shared/qqmlconfigurabledebugservice.h +++ b/src/plugins/qmltooling/shared/qqmlconfigurabledebugservice.h @@ -85,7 +85,7 @@ protected: QQmlDebugConnector::instance()->blockingMode()); } - void stateChanged(QQmlDebugService::State newState) Q_DECL_OVERRIDE + void stateChanged(QQmlDebugService::State newState) override { if (newState != QQmlDebugService::Enabled) stopWaiting(); @@ -93,7 +93,7 @@ protected: init(); } - void engineAboutToBeAdded(QJSEngine *engine) Q_DECL_OVERRIDE + void engineAboutToBeAdded(QJSEngine *engine) override { QMutexLocker lock(&m_configMutex); if (m_waitingForConfiguration) diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 7eca0b7780..1c88eab2a8 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -318,7 +318,6 @@ void Document::removeScriptPragmas(QString &script) Document::Document(bool debugMode) : jsModule(debugMode) , program(0) - , indexOfRootObject(0) , jsGenerator(&jsModule) { } @@ -422,7 +421,10 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen QQmlJS::AST::UiObjectDefinition *rootObject = QQmlJS::AST::cast<QQmlJS::AST::UiObjectDefinition*>(program->members->member); Q_ASSERT(rootObject); - defineQMLObject(&output->indexOfRootObject, rootObject); + int rootObjectIndex = -1; + if (defineQMLObject(&rootObjectIndex, rootObject)) { + Q_ASSERT(rootObjectIndex == 0); + } qSwap(_imports, output->imports); qSwap(_pragmas, output->pragmas); @@ -1587,7 +1589,6 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, const QV4: qmlUnit->nImports = output.imports.count(); qmlUnit->offsetToObjects = unitSize + importSize; qmlUnit->nObjects = output.objects.count(); - qmlUnit->indexOfRootObject = output.indexOfRootObject; qmlUnit->offsetToStringTable = totalSize - output.jsGenerator.stringTable.sizeOfTableAndData(); qmlUnit->stringTableSize = output.jsGenerator.stringTable.stringCount(); @@ -2317,8 +2318,6 @@ void IRLoader::load() output->pragmas << p; } - output->indexOfRootObject = unit->indexOfRootObject; - for (uint i = 0; i < unit->nObjects; ++i) { const QV4::CompiledData::Object *serializedObject = unit->objectAt(i); QmlIR::Object *object = loadObject(serializedObject); diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index 4f000081df..406c939998 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -457,7 +457,6 @@ struct Q_QML_PRIVATE_EXPORT Document QList<const QV4::CompiledData::Import *> imports; QList<Pragma*> pragmas; QQmlJS::AST::UiProgram *program; - int indexOfRootObject; QVector<Object*> objects; QV4::Compiler::JSUnitGenerator jsGenerator; diff --git a/src/qml/compiler/qqmlpropertycachecreator_p.h b/src/qml/compiler/qqmlpropertycachecreator_p.h index b33deac045..5d6a5c177a 100644 --- a/src/qml/compiler/qqmlpropertycachecreator_p.h +++ b/src/qml/compiler/qqmlpropertycachecreator_p.h @@ -108,7 +108,7 @@ template <typename ObjectContainer> inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjects() { QQmlBindingInstantiationContext context; - return buildMetaObjectRecursively(objectContainer->rootObjectIndex(), context); + return buildMetaObjectRecursively(/*root object*/0, context); } template <typename ObjectContainer> @@ -278,7 +278,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj QByteArray newClassName; - if (objectIndex == objectContainer->rootObjectIndex()) { + if (objectIndex == /*root object*/0) { const QString path = objectContainer->url().path(); int lastSlash = path.lastIndexOf(QLatin1Char('/')); if (lastSlash > -1) { @@ -576,7 +576,9 @@ inline QQmlPropertyCacheAliasCreator<ObjectContainer>::QQmlPropertyCacheAliasCre template <typename ObjectContainer> inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasPropertiesToMetaObjects() { - for (int i = 0; i < objectContainer->objectCount(); ++i) { + // skip the root object (index 0) as that one does not have a first object index originating + // from a binding. + for (int i = 1; i < objectContainer->objectCount(); ++i) { const CompiledObject &component = *objectContainer->objectAt(i); if (!(component.flags & QV4::CompiledData::Object::IsComponent)) continue; @@ -585,7 +587,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasPropertie appendAliasPropertiesInMetaObjectsWithinComponent(component, rootBinding->value.objectIndex); } - const int rootObjectIndex = objectContainer->rootObjectIndex(); + const int rootObjectIndex = 0; appendAliasPropertiesInMetaObjectsWithinComponent(*objectContainer->objectAt(rootObjectIndex), rootObjectIndex); } @@ -648,7 +650,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::collectObjectsWithAl objectsWithAliases->append(objectIndex); // Stop at Component boundary - if (object.flags & QV4::CompiledData::Object::IsComponent && objectIndex != objectContainer->rootObjectIndex()) + if (object.flags & QV4::CompiledData::Object::IsComponent && objectIndex != /*root object*/0) return; auto binding = object.bindingsBegin(); diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp index 4ac7aad553..7ea89b378d 100644 --- a/src/qml/compiler/qqmlpropertyvalidator.cpp +++ b/src/qml/compiler/qqmlpropertyvalidator.cpp @@ -58,7 +58,7 @@ QQmlPropertyValidator::QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, c QVector<QQmlCompileError> QQmlPropertyValidator::validate() { - return validateObject(qmlUnit->indexOfRootObject, /*instantiatingBinding*/0); + return validateObject(/*root object*/0, /*instantiatingBinding*/0); } typedef QVarLengthArray<const QV4::CompiledData::Binding *, 8> GroupPropertyVector; @@ -94,16 +94,6 @@ QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex, if (!propertyCache) return QVector<QQmlCompileError>(); - QStringList deferredPropertyNames; - { - const QMetaObject *mo = propertyCache->firstCppMetaObject(); - const int namesIndex = mo->indexOfClassInfo("DeferredPropertyNames"); - if (namesIndex != -1) { - QMetaClassInfo classInfo = mo->classInfo(namesIndex); - deferredPropertyNames = QString::fromUtf8(classInfo.value()).split(QLatin1Char(',')); - } - } - QQmlCustomParser *customParser = 0; if (auto typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex)) { if (typeRef->type.isValid()) diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index fb31efaed0..1e17312fe1 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -218,15 +218,10 @@ QVector<QmlIR::Object *> *QQmlTypeCompiler::qmlObjects() const return &document->objects; } -int QQmlTypeCompiler::rootObjectIndex() const -{ - return document->indexOfRootObject; -} - void QQmlTypeCompiler::setPropertyCaches(QQmlPropertyCacheVector &&caches) { m_propertyCaches = std::move(caches); - Q_ASSERT(m_propertyCaches.count() >= document->indexOfRootObject); + Q_ASSERT(m_propertyCaches.count() > 0); } const QQmlPropertyCacheVector *QQmlTypeCompiler::propertyCaches() const @@ -693,7 +688,7 @@ QQmlCustomParserScriptIndexer::QQmlCustomParserScriptIndexer(QQmlTypeCompiler *t void QQmlCustomParserScriptIndexer::annotateBindingsWithScriptStrings() { - scanObjectRecursively(compiler->rootObjectIndex()); + scanObjectRecursively(/*root object*/0); } void QQmlCustomParserScriptIndexer::scanObjectRecursively(int objectIndex, bool annotateScriptBindings) @@ -788,7 +783,6 @@ QQmlComponentAndAliasResolver::QQmlComponentAndAliasResolver(QQmlTypeCompiler *t , enginePrivate(typeCompiler->enginePrivate()) , pool(typeCompiler->memoryPool()) , qmlObjects(typeCompiler->qmlObjects()) - , indexOfRootObject(typeCompiler->rootObjectIndex()) , resolvedTypes(&typeCompiler->resolvedTypes) , propertyCaches(std::move(typeCompiler->takePropertyCaches())) { @@ -926,9 +920,9 @@ bool QQmlComponentAndAliasResolver::resolve() if (rootBinding->next || rootBinding->type != QV4::CompiledData::Binding::Type_Object) COMPILE_EXCEPTION(obj, tr("Invalid component body specification")); - // We are going to collect ids/aliases and resolve them for the root object as a separate + // For the root object, we are going to collect ids/aliases and resolve them for as a separate // last pass. - if (i != indexOfRootObject) + if (i != 0) componentRoots.append(i); } @@ -954,12 +948,12 @@ bool QQmlComponentAndAliasResolver::resolve() _idToObjectIndex.clear(); _objectsWithAliases.clear(); - collectIdsAndAliases(indexOfRootObject); + collectIdsAndAliases(/*root object*/0); - QmlIR::Object *rootComponent = qmlObjects->at(indexOfRootObject); + QmlIR::Object *rootComponent = qmlObjects->at(/*root object*/0); rootComponent->namedObjectsInComponent.allocate(pool, _idToObjectIndex); - if (!resolveAliases(indexOfRootObject)) + if (!resolveAliases(/*root object*/0)) return false; // Implicit component insertion may have added objects and thus we also need @@ -987,7 +981,7 @@ bool QQmlComponentAndAliasResolver::collectIdsAndAliases(int objectIndex) _objectsWithAliases.append(objectIndex); // Stop at Component boundary - if (obj->flags & QV4::CompiledData::Object::IsComponent && objectIndex != compiler->rootObjectIndex()) + if (obj->flags & QV4::CompiledData::Object::IsComponent && objectIndex != /*root object*/0) return true; for (const QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) { @@ -1178,7 +1172,7 @@ QQmlDeferredAndCustomParserBindingScanner::QQmlDeferredAndCustomParserBindingSca bool QQmlDeferredAndCustomParserBindingScanner::scanObject() { - return scanObject(compiler->rootObjectIndex()); + return scanObject(/*root object*/0); } bool QQmlDeferredAndCustomParserBindingScanner::scanObject(int objectIndex) @@ -1264,7 +1258,7 @@ bool QQmlDeferredAndCustomParserBindingScanner::scanObject(int objectIndex) _seenObjectWithId |= seenSubObjectWithId; } - if (!seenSubObjectWithId + if (!seenSubObjectWithId && binding->type != QV4::CompiledData::Binding::Type_GroupProperty && !deferredPropertyNames.isEmpty() && deferredPropertyNames.contains(name)) { binding->flags |= QV4::CompiledData::Binding::IsDeferredBinding; @@ -1304,7 +1298,7 @@ bool QQmlJSCodeGenerator::generateCodeForComponents() return false; } - return compileComponent(compiler->rootObjectIndex()); + return compileComponent(/*root object*/0); } bool QQmlJSCodeGenerator::compileComponent(int contextObject) diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h index a70ad77bfb..d905b956c7 100644 --- a/src/qml/compiler/qqmltypecompiler_p.h +++ b/src/qml/compiler/qqmltypecompiler_p.h @@ -117,7 +117,6 @@ public: QQmlEnginePrivate *enginePrivate() const { return engine; } const QQmlImports *imports() const; QVector<QmlIR::Object *> *qmlObjects() const; - int rootObjectIndex() const; void setPropertyCaches(QQmlPropertyCacheVector &&caches); const QQmlPropertyCacheVector *propertyCaches() const; QQmlPropertyCacheVector &&takePropertyCaches(); @@ -280,7 +279,6 @@ protected: QQmlJS::MemoryPool *pool; QVector<QmlIR::Object*> *qmlObjects; - const int indexOfRootObject; // indices of the objects that are actually Component {} QVector<quint32> componentRoots; diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 890f4c47de..ab47bf66f2 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -45,6 +45,7 @@ #include <private/qv4objectproto_p.h> #include <private/qv4lookup_p.h> #include <private/qv4regexpobject_p.h> +#include <private/qv4regexp_p.h> #include <private/qqmlpropertycache_p.h> #include <private/qqmltypeloader_p.h> #include <private/qqmlengine_p.h> @@ -136,8 +137,16 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) memset(runtimeRegularExpressions, 0, data->regexpTableSize * sizeof(QV4::Value)); for (uint i = 0; i < data->regexpTableSize; ++i) { const CompiledData::RegExp *re = data->regexpAt(i); - QV4::Heap::RegExpObject *ro = engine->newRegExpObject(data->stringAt(re->stringIndex), re->flags); - runtimeRegularExpressions[i] = ro; + bool global = false; + bool multiline = false; + bool ignoreCase = false; + if (re->flags & CompiledData::RegExp::RegExp_Global) + global = true; + if (re->flags & CompiledData::RegExp::RegExp_IgnoreCase) + ignoreCase = true; + if (re->flags & CompiledData::RegExp::RegExp_Multiline) + multiline = true; + runtimeRegularExpressions[i] = QV4::RegExp::create(engine, data->stringAt(re->stringIndex), ignoreCase, multiline, global); } if (data->lookupTableSize) { @@ -213,7 +222,7 @@ void CompilationUnit::unlink() engine->compilationUnits.erase(engine->compilationUnits.find(this)); if (isRegisteredWithEngine) { - Q_ASSERT(data && quint32(propertyCaches.count()) > data->indexOfRootObject && propertyCaches.at(data->indexOfRootObject)); + Q_ASSERT(data && propertyCaches.count() > 0 && propertyCaches.at(/*root object*/0)); if (qmlEngine) qmlEngine->unregisterInternalCompositeType(this); QQmlMetaType::unregisterInternalCompositeType(this); @@ -289,11 +298,11 @@ void CompilationUnit::finalizeCompositeType(QQmlEnginePrivate *qmlEngine) this->qmlEngine = qmlEngine; // Add to type registry of composites - if (propertyCaches.needsVMEMetaObject(data->indexOfRootObject)) { + if (propertyCaches.needsVMEMetaObject(/*root object*/0)) { QQmlMetaType::registerInternalCompositeType(this); qmlEngine->registerInternalCompositeType(this); } else { - const QV4::CompiledData::Object *obj = objectAt(data->indexOfRootObject); + const QV4::CompiledData::Object *obj = objectAt(/*root object*/0); auto *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex); Q_ASSERT(typeRef); if (typeRef->compilationUnit) { @@ -714,8 +723,6 @@ void ResolvedTypeReference::doDynamicTypeCheck() isFullyDynamicType = qtTypeInherits<QQmlPropertyMap>(mo); } -#if defined(QT_BUILD_INTERNAL) - static QByteArray ownLibraryChecksum() { static QByteArray libraryChecksum; @@ -723,7 +730,10 @@ static QByteArray ownLibraryChecksum() if (checksumInitialized) return libraryChecksum; checksumInitialized = true; -#if !defined(QT_NO_DYNAMIC_CAST) && QT_CONFIG(dlopen) +#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_DYNAMIC_CAST) && QT_CONFIG(dlopen) + // This is a bit of a hack to make development easier. When hacking on the code generator + // the cache files may end up being re-used. To avoid that we also add the checksum of + // the QtQml library. Dl_info libInfo; if (dladdr(reinterpret_cast<const void *>(&ownLibraryChecksum), &libInfo) != 0) { QFile library(QFile::decodeName(libInfo.dli_fname)); @@ -733,14 +743,14 @@ static QByteArray ownLibraryChecksum() libraryChecksum = hash.result(); } } +#elif defined(QML_COMPILE_HASH) + libraryChecksum = QByteArray(QT_STRINGIFY(QML_COMPILE_HASH)); #else // Not implemented. #endif return libraryChecksum; } -#endif - bool ResolvedTypeReferenceMap::addToHash(QCryptographicHash *hash, QQmlEngine *engine) const { for (auto it = constBegin(), end = constEnd(); it != end; ++it) { @@ -748,12 +758,7 @@ bool ResolvedTypeReferenceMap::addToHash(QCryptographicHash *hash, QQmlEngine *e return false; } - // This is a bit of a hack to make development easier. When hacking on the code generator - // the cache files may end up being re-used. To avoid that we also add the checksum of - // the QtQml library. -#if defined(QT_BUILD_INTERNAL) hash->addData(ownLibraryChecksum()); -#endif return true; } diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 1fa13e7d37..8825ce7b98 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -112,10 +112,6 @@ struct TableIterator bool operator!=(const TableIterator &rhs) const { return index != rhs.index; } }; -#if defined(Q_CC_MSVC) || defined(Q_CC_GNU) -#pragma pack(push, 1) -#endif - struct Location { union { @@ -131,6 +127,7 @@ struct Location (line == other.line && column < other.column); } }; +static_assert(sizeof(Location) == 4, "Location structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct RegExp { @@ -147,6 +144,7 @@ struct RegExp RegExp() : _dummy(0) { } }; +static_assert(sizeof(RegExp) == 4, "RegExp structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Lookup { @@ -164,6 +162,7 @@ struct Lookup Lookup() : _dummy(0) { } }; +static_assert(sizeof(Lookup) == 4, "Lookup structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct JSClassMember { @@ -175,6 +174,7 @@ struct JSClassMember JSClassMember() : _dummy(0) { } }; +static_assert(sizeof(JSClassMember) == 4, "JSClassMember structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct JSClass { @@ -183,6 +183,7 @@ struct JSClass static int calculateSize(int nMembers) { return (sizeof(JSClass) + nMembers * sizeof(JSClassMember) + 7) & ~7; } }; +static_assert(sizeof(JSClass) == 4, "JSClass structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct String { @@ -193,6 +194,7 @@ struct String return (sizeof(String) + str.length() * sizeof(quint16) + 7) & ~0x7; } }; +static_assert(sizeof(String) == 4, "String structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct CodeOffsetToLine { quint32_le codeOffset; @@ -243,6 +245,8 @@ struct Function // Keep all unaligned data at the end quint8 flags; + quint8 padding1; + quint16_le padding2; const quint32_le *formalsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + formalsOffset); } const quint32_le *localsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); } @@ -272,6 +276,7 @@ struct Function return (a + 7) & ~size_t(7); } }; +static_assert(sizeof(Function) == 76, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); // Qml data structures @@ -279,6 +284,7 @@ struct Q_QML_EXPORT TranslationData { quint32_le commentIndex; qint32_le number; }; +static_assert(sizeof(TranslationData) == 8, "TranslationData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Q_QML_PRIVATE_EXPORT Binding { @@ -325,6 +331,8 @@ struct Q_QML_PRIVATE_EXPORT Binding Location location; Location valueLocation; + quint32_le padding; + bool isValueBinding() const { if (type == Type_AttachedProperty @@ -404,6 +412,8 @@ struct Q_QML_PRIVATE_EXPORT Binding }; +static_assert(sizeof(Binding) == 32, "Binding structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + struct EnumValue { quint32_le nameIndex; @@ -441,6 +451,7 @@ struct Parameter quint32_le customTypeNameIndex; Location location; }; +static_assert(sizeof(Parameter) == 16, "Parameter structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Signal { @@ -465,6 +476,7 @@ struct Signal int parameterCount() const { return nParameters; } // --- }; +static_assert(sizeof(Signal) == 12, "Signal structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Property { @@ -485,6 +497,7 @@ struct Property quint32_le customTypeNameIndex; // If type >= Custom Location location; }; +static_assert(sizeof(Property) == 16, "Property structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Alias { enum Flags : unsigned int { @@ -514,6 +527,7 @@ struct Alias { return encodedMetaPropertyIndex == -1; } }; +static_assert(sizeof(Alias) == 20, "Alias structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Object { @@ -636,6 +650,7 @@ struct Object int namedObjectsInComponentCount() const { return nNamedObjectsInComponent; } // --- }; +static_assert(sizeof(Object) == 80, "Object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Import { @@ -656,6 +671,7 @@ struct Import Import() { type = 0; uriIndex = 0; qualifierIndex = 0; majorVersion = 0; minorVersion = 0; } }; +static_assert(sizeof(Import) == 24, "Import structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); static const char magic_str[] = "qv4cdata"; @@ -706,7 +722,6 @@ struct Unit quint32_le offsetToImports; quint32_le nObjects; quint32_le offsetToObjects; - quint32_le indexOfRootObject; const Import *importAt(int idx) const { return reinterpret_cast<const Import*>((reinterpret_cast<const char *>(this)) + offsetToImports + idx * sizeof(Import)); @@ -772,9 +787,7 @@ struct Unit } }; -#if defined(Q_CC_MSVC) || defined(Q_CC_GNU) -#pragma pack(pop) -#endif +static_assert(sizeof(Unit) == 144, "Unit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct TypeReference { @@ -894,7 +907,7 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public CompilationUnitBase, public // QML specific fields QQmlPropertyCacheVector propertyCaches; - QQmlPropertyCache *rootPropertyCache() const { return propertyCaches.at(data->indexOfRootObject); } + QQmlPropertyCache *rootPropertyCache() const { return propertyCaches.at(/*root object*/0); } QQmlRefPointer<QQmlTypeNameCache> typeNameCache; @@ -931,7 +944,6 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public CompilationUnitBase, public // --- interface for QQmlPropertyCacheCreator typedef Object CompiledObject; int objectCount() const { return data->nObjects; } - int rootObjectIndex() const { return data->indexOfRootObject; } const Object *objectAt(int index) const { return data->objectAt(index); } QString stringAt(int index) const { return data->stringAt(index); } @@ -956,7 +968,7 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public CompilationUnitBase, public void markObjects(MarkStack *markStack); - void destroy() Q_DECL_OVERRIDE; + void destroy() override; bool loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString); diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index a3c203b136..545ce70e42 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -455,7 +455,6 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp unit.offsetToImports = 0; unit.nObjects = 0; unit.offsetToObjects = 0; - unit.indexOfRootObject = 0; unit.unitSize = nextOffset; diff --git a/src/qml/jsapi/qjsengine.h b/src/qml/jsapi/qjsengine.h index 41c4b81270..f92a26445f 100644 --- a/src/qml/jsapi/qjsengine.h +++ b/src/qml/jsapi/qjsengine.h @@ -119,7 +119,7 @@ private: friend inline bool qjsvalue_cast_helper(const QJSValue &, int, void *); protected: - QJSEngine(QJSEnginePrivate &dd, QObject *parent = Q_NULLPTR); + QJSEngine(QJSEnginePrivate &dd, QObject *parent = nullptr); private: QV8Engine *d; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index d10fd78973..d63320b595 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -134,10 +134,6 @@ ExecutionEngine::ExecutionEngine() , m_engineId(engineSerial.fetchAndAddOrdered(1)) , regExpCache(0) , m_multiplyWrappedQObjects(0) -#ifndef QT_NO_QML_DEBUGGER - , m_debugger(0) - , m_profiler(0) -#endif { memoryManager = new QV4::MemoryManager(this); @@ -469,12 +465,6 @@ ExecutionEngine::ExecutionEngine() ExecutionEngine::~ExecutionEngine() { -#ifndef QT_NO_QML_DEBUGGER - delete m_debugger; - m_debugger = 0; - delete m_profiler; - m_profiler = 0; -#endif delete m_multiplyWrappedQObjects; m_multiplyWrappedQObjects = 0; delete identifierTable; @@ -502,13 +492,13 @@ ExecutionEngine::~ExecutionEngine() void ExecutionEngine::setDebugger(Debugging::Debugger *debugger) { Q_ASSERT(!m_debugger); - m_debugger = debugger; + m_debugger.reset(debugger); } void ExecutionEngine::setProfiler(Profiling::Profiler *profiler) { Q_ASSERT(!m_profiler); - m_profiler = profiler; + m_profiler.reset(profiler); } #endif // QT_NO_QML_DEBUGGER @@ -650,21 +640,17 @@ Heap::DateObject *ExecutionEngine::newDateObjectFromTime(const QTime &t) Heap::RegExpObject *ExecutionEngine::newRegExpObject(const QString &pattern, int flags) { bool global = (flags & QV4::CompiledData::RegExp::RegExp_Global); - bool ignoreCase = false; - bool multiline = false; - if (flags & QV4::CompiledData::RegExp::RegExp_IgnoreCase) - ignoreCase = true; - if (flags & QV4::CompiledData::RegExp::RegExp_Multiline) - multiline = true; + bool ignoreCase = (flags & QV4::CompiledData::RegExp::RegExp_IgnoreCase); + bool multiline = (flags & QV4::CompiledData::RegExp::RegExp_Multiline); Scope scope(this); - Scoped<RegExp> re(scope, RegExp::create(this, pattern, ignoreCase, multiline)); - return newRegExpObject(re, global); + Scoped<RegExp> re(scope, RegExp::create(this, pattern, ignoreCase, multiline, global)); + return newRegExpObject(re); } -Heap::RegExpObject *ExecutionEngine::newRegExpObject(RegExp *re, bool global) +Heap::RegExpObject *ExecutionEngine::newRegExpObject(RegExp *re) { - return memoryManager->allocObject<RegExpObject>(re, global); + return memoryManager->allocObject<RegExpObject>(re); } Heap::RegExpObject *ExecutionEngine::newRegExpObject(const QRegExp &re) diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index fcadf57508..0f9027ea5f 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -371,8 +371,8 @@ public: void setDebugger(Debugging::Debugger *) {} void setProfiler(Profiling::Profiler *) {} #else - QV4::Debugging::Debugger *debugger() const { return m_debugger; } - QV4::Profiling::Profiler *profiler() const { return m_profiler; } + QV4::Debugging::Debugger *debugger() const { return m_debugger.data(); } + QV4::Profiling::Profiler *profiler() const { return m_profiler.data(); } void setDebugger(Debugging::Debugger *debugger); void setProfiler(Profiling::Profiler *profiler); @@ -408,7 +408,7 @@ public: Heap::DateObject *newDateObjectFromTime(const QTime &t); Heap::RegExpObject *newRegExpObject(const QString &pattern, int flags); - Heap::RegExpObject *newRegExpObject(RegExp *re, bool global); + Heap::RegExpObject *newRegExpObject(RegExp *re); Heap::RegExpObject *newRegExpObject(const QRegExp &re); Heap::Object *newErrorObject(const Value &value); @@ -476,8 +476,8 @@ public: private: #ifndef QT_NO_QML_DEBUGGER - QV4::Debugging::Debugger *m_debugger; - QV4::Profiling::Profiler *m_profiler; + QScopedPointer<QV4::Debugging::Debugger> m_debugger; + QScopedPointer<QV4::Profiling::Profiler> m_profiler; #endif }; diff --git a/src/qml/jsruntime/qv4identifier.cpp b/src/qml/jsruntime/qv4identifier.cpp index 6260fd0cc8..e35f72b820 100644 --- a/src/qml/jsruntime/qv4identifier.cpp +++ b/src/qml/jsruntime/qv4identifier.cpp @@ -152,7 +152,7 @@ const IdentifierHashEntry *IdentifierHashBase::lookup(const QString &str) const return 0; Q_ASSERT(d->entries); - uint hash = String::createHashValue(str.constData(), str.length(), Q_NULLPTR); + uint hash = String::createHashValue(str.constData(), str.length(), nullptr); uint idx = hash % d->alloc; while (1) { if (!d->entries[idx].identifier) diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 5419e45038..0c94c1ac43 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -46,6 +46,7 @@ #include <QtCore/private/qnumeric_p.h> #include <QtCore/qthreadstorage.h> +#include <math.h> #include <cmath> using namespace QV4; diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index b182e3ab83..ce0c89be57 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -62,20 +62,17 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(QQmlContextWrapper); DEFINE_MANAGED_VTABLE(QmlContext); -void Heap::QQmlContextWrapper::init(QQmlContextData *context, QObject *scopeObject, bool ownsContext) +void Heap::QQmlContextWrapper::init(QQmlContextData *context, QObject *scopeObject) { Object::init(); readOnly = true; - this->ownsContext = ownsContext; isNullWrapper = false; - this->context = new QQmlGuardedContextData(context); + this->context = new QQmlContextDataRef(context); this->scopeObject.init(scopeObject); } void Heap::QQmlContextWrapper::destroy() { - if (*context && ownsContext) - (*context)->destroy(); delete context; scopeObject.destroy(); Object::destroy(); @@ -314,7 +311,7 @@ Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, cons context->isInternal = true; context->isJSContext = true; - Scoped<QQmlContextWrapper> qml(scope, scope.engine->memoryManager->allocObject<QQmlContextWrapper>(context, (QObject*)0, true)); + Scoped<QQmlContextWrapper> qml(scope, scope.engine->memoryManager->allocObject<QQmlContextWrapper>(context, (QObject*)0)); qml->d()->isNullWrapper = true; qml->setReadOnly(false); diff --git a/src/qml/jsruntime/qv4qmlcontext_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h index 9faf58d496..f0782c7ee1 100644 --- a/src/qml/jsruntime/qv4qmlcontext_p.h +++ b/src/qml/jsruntime/qv4qmlcontext_p.h @@ -67,13 +67,12 @@ struct QQmlContextWrapper; namespace Heap { struct QQmlContextWrapper : Object { - void init(QQmlContextData *context, QObject *scopeObject, bool ownsContext = false); + void init(QQmlContextData *context, QObject *scopeObject); void destroy(); bool readOnly; - bool ownsContext; bool isNullWrapper; - QQmlGuardedContextData *context; + QQmlContextDataRef *context; QQmlQPointer<QObject> scopeObject; }; @@ -93,10 +92,6 @@ struct Q_QML_EXPORT QQmlContextWrapper : Object V4_OBJECT2(QQmlContextWrapper, Object) V4_NEEDS_DESTROY - void takeContextOwnership() { - d()->ownsContext = true; - } - inline QObject *getScopeObject() const { return d()->scopeObject; } inline QQmlContextData *getContext() const { return *d()->context; } @@ -119,10 +114,6 @@ struct Q_QML_EXPORT QmlContext : public ExecutionContext QQmlContextData *qmlContext() const { return *d()->qml()->context; } - - void takeContextOwnership() { - d()->qml()->ownsContext = true; - } }; } diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 400d0f8cb2..5bd3bcb439 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1045,8 +1045,12 @@ void QObjectWrapper::destroyObject(bool lastCall) QQmlData *ddata = QQmlData::get(h->object(), false); if (ddata) { if (!h->object()->parent() && !ddata->indestructible) { - if (ddata && ddata->ownContext && ddata->context) - ddata->context->emitDestruction(); + if (ddata && ddata->ownContext) { + Q_ASSERT(ddata->ownContext == ddata->context); + ddata->ownContext->emitDestruction(); + ddata->ownContext = 0; + ddata->context = 0; + } // This object is notionally destroyed now ddata->isQueuedForDeletion = true; if (lastCall) diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index 3032363cb4..fb49def317 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -69,9 +69,9 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets) return JSC::Yarr::interpret(byteCode(), s.characters16(), string.length(), start, matchOffsets); } -Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline) +Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline, bool global) { - RegExpCacheKey key(pattern, ignoreCase, multiline); + RegExpCacheKey key(pattern, ignoreCase, multiline, global); RegExpCache *cache = engine->regExpCache; if (!cache) @@ -82,7 +82,7 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo return result->d(); Scope scope(engine); - Scoped<RegExp> result(scope, engine->memoryManager->alloc<RegExp>(pattern, ignoreCase, multiline)); + Scoped<RegExp> result(scope, engine->memoryManager->alloc<RegExp>(pattern, ignoreCase, multiline, global)); result->d()->cache = cache; cachedValue.set(engine, result); @@ -90,12 +90,14 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo return result->d(); } -void Heap::RegExp::init(const QString &pattern, bool ignoreCase, bool multiline) +void Heap::RegExp::init(const QString &pattern, bool ignoreCase, bool multiline, bool global) { Base::init(); this->pattern = new QString(pattern); this->ignoreCase = ignoreCase; this->multiLine = multiline; + this->global = global; + valid = false; const char* error = 0; diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h index 59277ca3cd..498468e165 100644 --- a/src/qml/jsruntime/qv4regexp_p.h +++ b/src/qml/jsruntime/qv4regexp_p.h @@ -76,7 +76,7 @@ struct RegExpCacheKey; namespace Heap { struct RegExp : Base { - void init(const QString& pattern, bool ignoreCase, bool multiline); + void init(const QString& pattern, bool ignoreCase, bool multiline, bool global); void destroy(); QString *pattern; @@ -95,6 +95,7 @@ struct RegExp : Base { int subPatternCount; bool ignoreCase; bool multiLine; + bool global; bool valid; int captureCount() const { return subPatternCount + 1; } @@ -119,8 +120,9 @@ struct RegExp : public Managed int subPatternCount() const { return d()->subPatternCount; } bool ignoreCase() const { return d()->ignoreCase; } bool multiLine() const { return d()->multiLine; } + bool global() const { return d()->global; } - static Heap::RegExp *create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase = false, bool multiline = false); + static Heap::RegExp *create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase = false, bool multiline = false, bool global = false); bool isValid() const { return d()->valid; } @@ -133,27 +135,30 @@ struct RegExp : public Managed struct RegExpCacheKey { - RegExpCacheKey(const QString &pattern, bool ignoreCase, bool multiLine) + RegExpCacheKey(const QString &pattern, bool ignoreCase, bool multiLine, bool global) : pattern(pattern) , ignoreCase(ignoreCase) , multiLine(multiLine) + , global(global) { } explicit inline RegExpCacheKey(const RegExp::Data *re); bool operator==(const RegExpCacheKey &other) const - { return pattern == other.pattern && ignoreCase == other.ignoreCase && multiLine == other.multiLine; } + { return pattern == other.pattern && ignoreCase == other.ignoreCase && multiLine == other.multiLine && global == other.global; } bool operator!=(const RegExpCacheKey &other) const { return !operator==(other); } QString pattern; uint ignoreCase : 1; uint multiLine : 1; + uint global : 1; }; inline RegExpCacheKey::RegExpCacheKey(const RegExp::Data *re) : pattern(*re->pattern) , ignoreCase(re->ignoreCase) , multiLine(re->multiLine) + , global(re->global) {} inline uint qHash(const RegExpCacheKey& key, uint seed = 0) Q_DECL_NOTHROW diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index d4d646be3f..c42c018f9d 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -72,15 +72,13 @@ void Heap::RegExpObject::init() Scope scope(internalClass->engine); Scoped<QV4::RegExpObject> o(scope, this); value.set(scope.engine, QV4::RegExp::create(scope.engine, QString(), false, false)); - global = false; o->initProperties(); } -void Heap::RegExpObject::init(QV4::RegExp *value, bool global) +void Heap::RegExpObject::init(QV4::RegExp *value) { Object::init(); Scope scope(internalClass->engine); - this->global = global; this->value.set(scope.engine, value->d()); Scoped<QV4::RegExpObject> o(scope, this); o->initProperties(); @@ -92,7 +90,6 @@ void Heap::RegExpObject::init(QV4::RegExp *value, bool global) void Heap::RegExpObject::init(const QRegExp &re) { Object::init(); - global = false; // Convert the pattern to a ECMAScript pattern. QString pattern = QT_PREPEND_NAMESPACE(qt_regexp_toCanonical)(re.pattern(), re.patternSyntax()); @@ -228,7 +225,7 @@ ReturnedValue RegExpCtor::construct(const Managed *m, CallData *callData) return scope.engine->throwTypeError(); Scoped<RegExp> regexp(scope, re->value()); - return Encode(scope.engine->newRegExpObject(regexp, re->global())); + return Encode(scope.engine->newRegExpObject(regexp)); } QString pattern; @@ -258,12 +255,12 @@ ReturnedValue RegExpCtor::construct(const Managed *m, CallData *callData) } } - Scoped<RegExp> regexp(scope, RegExp::create(scope.engine, pattern, ignoreCase, multiLine)); + Scoped<RegExp> regexp(scope, RegExp::create(scope.engine, pattern, ignoreCase, multiLine, global)); if (!regexp->isValid()) { return scope.engine->throwSyntaxError(QStringLiteral("Invalid regular expression")); } - return Encode(scope.engine->newRegExpObject(regexp, global)); + return Encode(scope.engine->newRegExpObject(regexp)); } ReturnedValue RegExpCtor::call(const Managed *that, CallData *callData) @@ -445,8 +442,7 @@ ReturnedValue RegExpPrototype::method_compile(const BuiltinFunction *b, CallData Scoped<RegExpObject> re(scope, jsCall.callAsConstructor()); r->d()->value.set(scope.engine, re->value()); - r->d()->global = re->global(); - RETURN_UNDEFINED(); + return Encode::undefined(); } template <int index> diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index b808ec38cf..7432840fcd 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -58,6 +58,7 @@ #include "qv4managed_p.h" #include "qv4property_p.h" #include "qv4objectiterator_p.h" +#include "qv4regexp_p.h" #include <QtCore/QString> #include <QtCore/QHash> @@ -72,14 +73,13 @@ namespace QV4 { namespace Heap { #define RegExpObjectMembers(class, Member) \ - Member(class, Pointer, RegExp *, value) \ - Member(class, NoMark, bool, global) + Member(class, Pointer, RegExp *, value) DECLARE_HEAP_OBJECT(RegExpObject, Object) { DECLARE_MARK_TABLE(RegExpObject); void init(); - void init(QV4::RegExp *value, bool global); + void init(QV4::RegExp *value); void init(const QRegExp &re); }; @@ -122,7 +122,7 @@ struct RegExpObject: Object { }; Heap::RegExp *value() const { return d()->value; } - bool global() const { return d()->global; } + bool global() const { return d()->value->global; } void initProperties(); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 5d0c91d9ef..2e97d8074a 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -51,6 +51,8 @@ #include "qv4lookup_p.h" #include "qv4function_p.h" #include "qv4numberobject_p.h" +#include "qv4regexp_p.h" +#include "qv4regexpobject_p.h" #include "private/qlocale_tools_p.h" #include "qv4scopedvalue_p.h" #include "qv4jscall_p.h" @@ -1239,6 +1241,12 @@ ReturnedValue Runtime::method_loadQmlContext(NoThrowEngine *engine) return engine->qmlContext()->asReturnedValue(); } +ReturnedValue Runtime::method_regexpLiteral(ExecutionEngine *engine, int id) +{ + Heap::RegExpObject *ro = engine->newRegExpObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeRegularExpressions[id].as<RegExp>()); + return ro->asReturnedValue(); +} + ReturnedValue Runtime::method_loadQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, bool captureRequired) { const QmlContext &c = static_cast<const QmlContext &>(context); diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index d5814abf36..7d32a81bc2 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -179,6 +179,8 @@ struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> { F(Bool, compareInstanceof, (ExecutionEngine *engine, const Value &left, const Value &right)) \ F(Bool, compareIn, (ExecutionEngine *engine, const Value &left, const Value &right)) \ \ + F(ReturnedValue, regexpLiteral, (ExecutionEngine *engine, int id)) \ + \ /* qml */ \ F(ReturnedValue, loadQmlContext, (NoThrowEngine *engine)) \ F(ReturnedValue, loadQmlImportedScripts, (NoThrowEngine *engine)) \ diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index d6dbeacb2d..9e03913730 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -554,7 +554,7 @@ ReturnedValue StringPrototype::method_replace(const BuiltinFunction *b, CallData break; } nMatchOffsets += re->captureCount() * 2; - if (!regExp->d()->global) + if (!regExp->global()) break; offset = qMax(offset + 1, matchOffsets[oldSize + 1]); } diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 17aea4e022..63433b7955 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -608,7 +608,7 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value inline Primitive Primitive::undefinedValue() { Primitive v; - v.setM(Q_NULLPTR); + v.setM(nullptr); return v; } diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index b3b8d7363f..f27a7d452c 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -50,6 +50,8 @@ #include <private/qv4math_p.h> #include <private/qv4scopedvalue_p.h> #include <private/qv4lookup_p.h> +#include <private/qv4regexp_p.h> +#include <private/qv4regexpobject_p.h> #include <private/qv4string_p.h> #include <private/qv4profiling_p.h> #include <private/qqmljavascriptexpression_p.h> @@ -605,7 +607,7 @@ QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function) MOTH_END_INSTR(LoadRuntimeString) MOTH_BEGIN_INSTR(LoadRegExp) - acc = function->compilationUnit->runtimeRegularExpressions[regExpId].asReturnedValue(); + acc = Runtime::method_regexpLiteral(engine, regExpId); MOTH_END_INSTR(LoadRegExp) MOTH_BEGIN_INSTR(LoadClosure) diff --git a/src/qml/qml.pro b/src/qml/qml.pro index 66f0b59226..fb50588177 100644 --- a/src/qml/qml.pro +++ b/src/qml/qml.pro @@ -16,6 +16,19 @@ gcc:isEqual(QT_ARCH, "mips"): QMAKE_CXXFLAGS += -fno-reorder-blocks DEFINES += QT_NO_FOREACH +tagFile=$$PWD/../../.tag +tag= +exists($$tagFile) { + tag=$$cat($$tagFile, singleline) + QMAKE_INTERNAL_INCLUDED_FILES += $$tagFile +} +!equals(tag, "$${LITERAL_DOLLAR}Format:%H$${LITERAL_DOLLAR}") { + DEFINES += QML_COMPILE_HASH="$$tag" +} else:exists($$PWD/../../.git) { + commit=$$system(git describe --tags --always --long --dirty) + DEFINES += QML_COMPILE_HASH="$$commit" +} + exists("qqml_enable_gcov") { QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors LIBS_PRIVATE += -lgcov diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h index 9ee50ec931..956805d696 100644 --- a/src/qml/qml/ftw/qhashedstring_p.h +++ b/src/qml/qml/ftw/qhashedstring_p.h @@ -1311,12 +1311,12 @@ bool QHashedString::compare(const char *lhs, const char *rhs, int length) quint32 QHashedString::stringHash(const QChar *data, int length) { - return QV4::String::createHashValue(data, length, Q_NULLPTR); + return QV4::String::createHashValue(data, length, nullptr); } quint32 QHashedString::stringHash(const char *data, int length) { - return QV4::String::createHashValue(data, length, Q_NULLPTR); + return QV4::String::createHashValue(data, length, nullptr); } void QHashedString::computeHash() const diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index ddb4af0b81..219df264be 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -112,10 +112,10 @@ int qmlRegisterType() qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), 0, - Q_NULLPTR, + nullptr, QString(), - Q_NULLPTR, 0, 0, Q_NULLPTR, &T::staticMetaObject, + nullptr, 0, 0, nullptr, &T::staticMetaObject, QQmlPrivate::attachedPropertiesFunc<T>(), QQmlPrivate::attachedPropertiesMetaObject<T>(), @@ -124,9 +124,9 @@ int qmlRegisterType() QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - Q_NULLPTR, Q_NULLPTR, + nullptr, nullptr, - Q_NULLPTR, + nullptr, 0 }; @@ -146,7 +146,7 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), 0, - Q_NULLPTR, + nullptr, reason, uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, @@ -158,9 +158,9 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - Q_NULLPTR, Q_NULLPTR, + nullptr, nullptr, - Q_NULLPTR, + nullptr, 0 }; @@ -178,7 +178,7 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), 0, - Q_NULLPTR, + nullptr, reason, uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, @@ -190,9 +190,9 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - Q_NULLPTR, Q_NULLPTR, + nullptr, nullptr, - Q_NULLPTR, + nullptr, metaObjectRevision }; @@ -217,7 +217,7 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), 0, - Q_NULLPTR, + nullptr, reason, uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, @@ -231,7 +231,7 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve QQmlPrivate::createParent<E>, &E::staticMetaObject, - Q_NULLPTR, + nullptr, 0 }; @@ -256,7 +256,7 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), 0, - Q_NULLPTR, + nullptr, reason, uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, @@ -270,7 +270,7 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve QQmlPrivate::createParent<E>, &E::staticMetaObject, - Q_NULLPTR, + nullptr, metaObjectRevision }; @@ -301,9 +301,9 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - Q_NULLPTR, Q_NULLPTR, + nullptr, nullptr, - Q_NULLPTR, + nullptr, 0 }; @@ -332,9 +332,9 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - Q_NULLPTR, Q_NULLPTR, + nullptr, nullptr, - Q_NULLPTR, + nullptr, metaObjectRevision }; @@ -363,9 +363,9 @@ int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor) QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - Q_NULLPTR, Q_NULLPTR, + nullptr, nullptr, - Q_NULLPTR, + nullptr, metaObjectRevision }; @@ -384,10 +384,10 @@ int qmlRegisterExtendedType() qRegisterNormalizedMetaType<T *>(pointerName.constData()), qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()), 0, - Q_NULLPTR, + nullptr, QString(), - Q_NULLPTR, 0, 0, Q_NULLPTR, &T::staticMetaObject, + nullptr, 0, 0, nullptr, &T::staticMetaObject, QQmlPrivate::attachedPropertiesFunc<T>(), QQmlPrivate::attachedPropertiesMetaObject<T>(), @@ -398,7 +398,7 @@ int qmlRegisterExtendedType() QQmlPrivate::createParent<E>, &E::staticMetaObject, - Q_NULLPTR, + nullptr, 0 }; @@ -437,7 +437,7 @@ int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor, QQmlPrivate::createParent<E>, &E::staticMetaObject, - Q_NULLPTR, + nullptr, 0 }; @@ -487,7 +487,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor, QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(), QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(), - Q_NULLPTR, Q_NULLPTR, + nullptr, nullptr, parser, 0 @@ -583,7 +583,7 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi uri, versionMajor, versionMinor, typeName, - callback, Q_NULLPTR, Q_NULLPTR, 0, 0 + callback, nullptr, nullptr, 0, 0 }; return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api); @@ -601,7 +601,7 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi uri, versionMajor, versionMinor, typeName, - Q_NULLPTR, callback, &T::staticMetaObject, qRegisterNormalizedMetaType<T *>(pointerName.constData()), 0 + nullptr, callback, &T::staticMetaObject, qRegisterNormalizedMetaType<T *>(pointerName.constData()), 0 }; return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api); diff --git a/src/qml/qml/qqmlapplicationengine.h b/src/qml/qml/qqmlapplicationengine.h index 6c57f46c72..d0f9e6d319 100644 --- a/src/qml/qml/qqmlapplicationengine.h +++ b/src/qml/qml/qqmlapplicationengine.h @@ -53,9 +53,9 @@ class Q_QML_EXPORT QQmlApplicationEngine : public QQmlEngine { Q_OBJECT public: - QQmlApplicationEngine(QObject *parent = Q_NULLPTR); - QQmlApplicationEngine(const QUrl &url, QObject *parent = Q_NULLPTR); - QQmlApplicationEngine(const QString &filePath, QObject *parent = Q_NULLPTR); + QQmlApplicationEngine(QObject *parent = nullptr); + QQmlApplicationEngine(const QUrl &url, QObject *parent = nullptr); + QQmlApplicationEngine(const QString &filePath, QObject *parent = nullptr); ~QQmlApplicationEngine(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index fa60ba3216..56ab259229 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -180,7 +180,7 @@ class QQmlBindingBinding: public QQmlBinding { protected: void doUpdate(const DeleteWatcher &, - QQmlPropertyData::WriteFlags flags, QV4::Scope &) Q_DECL_OVERRIDE Q_DECL_FINAL + QQmlPropertyData::WriteFlags flags, QV4::Scope &) override final { Q_ASSERT(!m_targetIndex.hasValueTypeIndex()); QQmlPropertyData *pd = nullptr; @@ -196,7 +196,7 @@ class QQmlNonbindingBinding: public QQmlBinding { protected: void doUpdate(const DeleteWatcher &watcher, - QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) Q_DECL_OVERRIDE + QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) override { auto ep = QQmlEnginePrivate::get(scope.engine); ep->referenceScarceResources(); @@ -237,7 +237,7 @@ class GenericBinding: public QQmlNonbindingBinding protected: // Returns true if successful, false if an error description was set on expression Q_ALWAYS_INLINE bool write(const QV4::Value &result, bool isUndefined, - QQmlPropertyData::WriteFlags flags) Q_DECL_OVERRIDE Q_DECL_FINAL + QQmlPropertyData::WriteFlags flags) override final { Q_ASSERT(targetObject()); @@ -306,7 +306,7 @@ public: } void doUpdate(const DeleteWatcher &watcher, - QQmlPropertyData::WriteFlags flags, QV4::Scope &) Q_DECL_OVERRIDE Q_DECL_FINAL + QQmlPropertyData::WriteFlags flags, QV4::Scope &) override final { if (watcher.wasDeleted()) return; @@ -620,7 +620,7 @@ public: protected: Q_ALWAYS_INLINE bool write(const QV4::Value &result, bool isUndefined, - QQmlPropertyData::WriteFlags flags) Q_DECL_OVERRIDE Q_DECL_FINAL + QQmlPropertyData::WriteFlags flags) override final { QQmlPropertyData *pd; QQmlPropertyData vtpd; diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 38d59a8919..8bc9554a42 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -86,10 +86,10 @@ public: void setNotifyOnValueChanged(bool); - void refresh() Q_DECL_OVERRIDE; + void refresh() override; - void setEnabled(bool, QQmlPropertyData::WriteFlags flags = QQmlPropertyData::DontRemoveBinding) Q_DECL_OVERRIDE; - QString expression() const Q_DECL_OVERRIDE; + void setEnabled(bool, QQmlPropertyData::WriteFlags flags = QQmlPropertyData::DontRemoveBinding) override; + QString expression() const override; void update(QQmlPropertyData::WriteFlags flags = QQmlPropertyData::DontRemoveBinding); typedef int Identifier; diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h index ca60f01eb5..b8cc556e4a 100644 --- a/src/qml/qml/qqmlcomponent.h +++ b/src/qml/qml/qqmlcomponent.h @@ -77,12 +77,12 @@ public: enum CompilationMode { PreferSynchronous, Asynchronous }; Q_ENUM(CompilationMode) - QQmlComponent(QObject *parent = Q_NULLPTR); - QQmlComponent(QQmlEngine *, QObject *parent = Q_NULLPTR); - QQmlComponent(QQmlEngine *, const QString &fileName, QObject *parent = Q_NULLPTR); - QQmlComponent(QQmlEngine *, const QString &fileName, CompilationMode mode, QObject *parent = Q_NULLPTR); - QQmlComponent(QQmlEngine *, const QUrl &url, QObject *parent = Q_NULLPTR); - QQmlComponent(QQmlEngine *, const QUrl &url, CompilationMode mode, QObject *parent = Q_NULLPTR); + QQmlComponent(QObject *parent = nullptr); + QQmlComponent(QQmlEngine *, QObject *parent = nullptr); + QQmlComponent(QQmlEngine *, const QString &fileName, QObject *parent = nullptr); + QQmlComponent(QQmlEngine *, const QString &fileName, CompilationMode mode, QObject *parent = nullptr); + QQmlComponent(QQmlEngine *, const QUrl &url, QObject *parent = nullptr); + QQmlComponent(QQmlEngine *, const QUrl &url, CompilationMode mode, QObject *parent = nullptr); virtual ~QQmlComponent(); enum Status { Null, Ready, Loading, Error }; @@ -101,12 +101,12 @@ public: QUrl url() const; - virtual QObject *create(QQmlContext *context = Q_NULLPTR); + virtual QObject *create(QQmlContext *context = nullptr); virtual QObject *beginCreate(QQmlContext *); virtual void completeCreate(); - void create(QQmlIncubator &, QQmlContext *context = Q_NULLPTR, - QQmlContext *forContext = Q_NULLPTR); + void create(QQmlIncubator &, QQmlContext *context = nullptr, + QQmlContext *forContext = nullptr); QQmlContext *creationContext() const; diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 531d9ae457..37cb328b36 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -161,6 +161,7 @@ QQmlContext::QQmlContext(QQmlEngine *e, bool) { Q_D(QQmlContext); d->data = new QQmlContextData(this); + ++d->data->refCount; d->data->engine = e; } @@ -174,6 +175,7 @@ QQmlContext::QQmlContext(QQmlEngine *engine, QObject *parent) { Q_D(QQmlContext); d->data = new QQmlContextData(this); + ++d->data->refCount; d->data->setParent(engine?QQmlContextData::get(engine->rootContext()):0); } @@ -187,6 +189,7 @@ QQmlContext::QQmlContext(QQmlContext *parentContext, QObject *parent) { Q_D(QQmlContext); d->data = new QQmlContextData(this); + ++d->data->refCount; d->data->setParent(parentContext?QQmlContextData::get(parentContext):0); } @@ -199,6 +202,7 @@ QQmlContext::QQmlContext(QQmlContextData *data) { Q_D(QQmlContext); d->data = data; + // don't add a refcount here, as the data owns this context } /*! @@ -212,7 +216,8 @@ QQmlContext::~QQmlContext() { Q_D(QQmlContext); - if (!d->data->isInternal) + d->data->publicContext = 0; + if (!--d->data->refCount) d->data->destroy(); } @@ -521,12 +526,12 @@ QQmlContextData::QQmlContextData() } QQmlContextData::QQmlContextData(QQmlContext *ctxt) -: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), - isPragmaLibraryContext(false), unresolvedNames(false), hasEmittedDestruction(false), isRootObjectInCreation(false), - publicContext(ctxt), incubator(0), componentObjectIndex(-1), - contextObject(0), childContexts(0), nextChild(0), prevChild(0), - expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0), - componentAttached(0) + : engine(0), isInternal(false), isJSContext(false), + isPragmaLibraryContext(false), unresolvedNames(false), hasEmittedDestruction(false), isRootObjectInCreation(false), + publicContext(ctxt), incubator(0), componentObjectIndex(-1), + contextObject(0), nextChild(0), prevChild(0), + expressions(0), contextObjects(0), idValues(0), idValueCount(0), + componentAttached(0) { } @@ -563,11 +568,8 @@ void QQmlContextData::invalidate() emitDestruction(); while (childContexts) { - if (childContexts->ownedByParent) { - childContexts->destroy(); - } else { - childContexts->invalidate(); - } + Q_ASSERT(childContexts != this); + childContexts->invalidate(); } if (prevChild) { @@ -601,12 +603,17 @@ void QQmlContextData::clearContext() void QQmlContextData::destroy() { - if (linkedContext) - linkedContext->destroy(); + Q_ASSERT(refCount == 0); + linkedContext = 0; - if (engine) invalidate(); + // avoid recursion + ++refCount; + if (engine) + invalidate(); + Q_ASSERT(refCount == 1); clearContext(); + Q_ASSERT(refCount == 1); while (contextObjects) { QQmlData *co = contextObjects; @@ -617,6 +624,7 @@ void QQmlContextData::destroy() co->nextContextObject = 0; co->prevContextObject = 0; } + Q_ASSERT(refCount == 1); QQmlGuardedContextData *contextGuard = contextGuards; while (contextGuard) { @@ -627,17 +635,29 @@ void QQmlContextData::destroy() contextGuard = next; } contextGuards = 0; + Q_ASSERT(refCount == 1); delete [] idValues; + idValues = 0; - if (isInternal) + Q_ASSERT(refCount == 1); + if (publicContext) { + // the QQmlContext destructor will remove one ref again + ++refCount; delete publicContext; + } + + Q_ASSERT(refCount == 1); + --refCount; + Q_ASSERT(refCount == 0); delete this; } -void QQmlContextData::setParent(QQmlContextData *p, bool parentTakesOwnership) +void QQmlContextData::setParent(QQmlContextData *p) { + if (p == parent) + return; if (p) { parent = p; engine = p->engine; @@ -645,7 +665,6 @@ void QQmlContextData::setParent(QQmlContextData *p, bool parentTakesOwnership) if (nextChild) nextChild->prevChild = &nextChild; prevChild = &p->childContexts; p->childContexts = this; - ownedByParent = parentTakesOwnership; } } @@ -660,6 +679,10 @@ void QQmlContextData::refreshExpressionsRecursive(QQmlJavaScriptExpression *expr expression->refresh(); } +QQmlContextData::~QQmlContextData() +{ +} + static inline bool expressions_to_run(QQmlContextData *ctxt, bool isGlobalRefresh) { return ctxt->expressions && (!isGlobalRefresh || ctxt->unresolvedNames); @@ -795,7 +818,7 @@ QQmlContextPrivate *QQmlContextData::asQQmlContextPrivate() void QQmlContextData::initFromTypeCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, int subComponentIndex) { typeCompilationUnit = unit; - componentObjectIndex = subComponentIndex == -1 ? typeCompilationUnit->data->indexOfRootObject : subComponentIndex; + componentObjectIndex = subComponentIndex == -1 ? /*root object*/0 : subComponentIndex; Q_ASSERT(!idValues); idValueCount = typeCompilationUnit->data->objectAt(componentObjectIndex)->nNamedObjectsInComponent; idValues = new ContextGuard[idValueCount]; diff --git a/src/qml/qml/qqmlcontext.h b/src/qml/qml/qqmlcontext.h index 781eac44fc..b2b95b7573 100644 --- a/src/qml/qml/qqmlcontext.h +++ b/src/qml/qml/qqmlcontext.h @@ -62,8 +62,8 @@ class Q_QML_EXPORT QQmlContext : public QObject Q_DECLARE_PRIVATE(QQmlContext) public: - QQmlContext(QQmlEngine *parent, QObject *objParent = Q_NULLPTR); - QQmlContext(QQmlContext *parent, QObject *objParent = Q_NULLPTR); + QQmlContext(QQmlEngine *parent, QObject *objParent = nullptr); + QQmlContext(QQmlContext *parent, QObject *objParent = nullptr); virtual ~QQmlContext(); bool isValid() const; diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index a259fd62d8..d01820a430 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -78,6 +78,7 @@ class QQmlExpression; class QQmlExpressionPrivate; class QQmlJavaScriptExpression; class QQmlContextData; +class QQmlGuardedContextData; class QQmlIncubatorPrivate; class QQmlContextPrivate : public QObjectPrivate @@ -106,7 +107,7 @@ public: }; class QQmlComponentAttached; -class QQmlGuardedContextData; + class Q_QML_PRIVATE_EXPORT QQmlContextData { public: @@ -114,7 +115,6 @@ public: QQmlContextData(QQmlContext *); void emitDestruction(); void clearContext(); - void destroy(); void invalidate(); inline bool isValid() const { @@ -122,10 +122,10 @@ public: } // My parent context and engine - QQmlContextData *parent; + QQmlContextData *parent = nullptr; QQmlEngine *engine; - void setParent(QQmlContextData *, bool parentTakesOwnership = false); + void setParent(QQmlContextData *); void refreshExpressions(); void addObject(QObject *); @@ -136,14 +136,14 @@ public: // If internal is false publicContext owns this. QQmlContext *asQQmlContext(); QQmlContextPrivate *asQQmlContextPrivate(); + quint32 refCount = 0; quint32 isInternal:1; - quint32 ownedByParent:1; // unrelated to isInternal; parent context deletes children if true. quint32 isJSContext:1; quint32 isPragmaLibraryContext:1; quint32 unresolvedNames:1; // True if expressions in this context failed to resolve a toplevel name quint32 hasEmittedDestruction:1; quint32 isRootObjectInCreation:1; - quint32 dummy:25; + quint32 dummy:26; QQmlContext *publicContext; // The incubator that is constructing this context if any @@ -178,7 +178,7 @@ public: QQmlRefPointer<QQmlTypeNameCache> imports; // My children - QQmlContextData *childContexts; + QQmlContextData *childContexts = 0; // My peers in parent's childContexts list QQmlContextData *nextChild; @@ -191,7 +191,7 @@ public: QQmlData *contextObjects; // Doubly-linked list of context guards (XXX merge with contextObjects) - QQmlGuardedContextData *contextGuards; + QQmlGuardedContextData *contextGuards = 0; // id guards struct ContextGuard : public QQmlGuard<QObject> @@ -210,7 +210,7 @@ public: void setIdProperty(int, QObject *); // Linked contexts. this owns linkedContext. - QQmlContextData *linkedContext; + QQmlContextDataRef linkedContext; // Linked list of uses of the Component attached property in this // context @@ -224,91 +224,137 @@ public: } private: + friend class QQmlContextDataRef; + friend class QQmlContext; // needs to do manual refcounting :/ void refreshExpressionsRecursive(bool isGlobal); void refreshExpressionsRecursive(QQmlJavaScriptExpression *); - ~QQmlContextData() {} + ~QQmlContextData(); + void destroy(); }; + class QQmlGuardedContextData { public: - inline QQmlGuardedContextData(); - inline QQmlGuardedContextData(QQmlContextData *); - inline ~QQmlGuardedContextData(); - - inline QQmlContextData *contextData() const; + inline QQmlGuardedContextData() = default; + inline QQmlGuardedContextData(QQmlContextData *data) + { setContextData(data); } + inline ~QQmlGuardedContextData() + { clear(); } + + inline QQmlContextData *contextData() const + { return m_contextData; } inline void setContextData(QQmlContextData *); inline bool isNull() const { return !m_contextData; } inline operator QQmlContextData*() const { return m_contextData; } inline QQmlContextData* operator->() const { return m_contextData; } - inline QQmlGuardedContextData &operator=(QQmlContextData *d); + inline QQmlGuardedContextData &operator=(QQmlContextData *d) { + setContextData(d); return *this; + } private: - QQmlGuardedContextData &operator=(const QQmlGuardedContextData &); - QQmlGuardedContextData(const QQmlGuardedContextData &); + QQmlGuardedContextData &operator=(const QQmlGuardedContextData &) = delete; + QQmlGuardedContextData(const QQmlGuardedContextData &) = delete; friend class QQmlContextData; inline void clear(); - QQmlContextData *m_contextData; - QQmlGuardedContextData *m_next; - QQmlGuardedContextData **m_prev; + QQmlContextData *m_contextData = 0; + QQmlGuardedContextData *m_next = 0; + QQmlGuardedContextData **m_prev = 0; }; -QQmlGuardedContextData::QQmlGuardedContextData() -: m_contextData(0), m_next(0), m_prev(0) + +void QQmlGuardedContextData::setContextData(QQmlContextData *contextData) + { + if (m_contextData == contextData) + return; + clear(); + + if (contextData) { + m_contextData = contextData; + m_next = contextData->contextGuards; + if (m_next) m_next->m_prev = &m_next; + m_prev = &contextData->contextGuards; + contextData->contextGuards = this; + } +} + +void QQmlGuardedContextData::clear() +{ + if (m_prev) { + *m_prev = m_next; + if (m_next) m_next->m_prev = m_prev; + m_contextData = 0; + m_next = 0; + m_prev = 0; + } +} + +QQmlContextDataRef::QQmlContextDataRef() + : m_contextData(0) { } -QQmlGuardedContextData::QQmlGuardedContextData(QQmlContextData *data) -: m_contextData(0), m_next(0), m_prev(0) +QQmlContextDataRef::QQmlContextDataRef(const QQmlContextDataRef &other) + : m_contextData(other.m_contextData) { - setContextData(data); + if (m_contextData) + ++m_contextData->refCount; } -QQmlGuardedContextData::~QQmlGuardedContextData() +QQmlContextDataRef::QQmlContextDataRef(QQmlContextData *data) + : m_contextData(data) +{ + if (m_contextData) + ++m_contextData->refCount; +} + +QQmlContextDataRef::~QQmlContextDataRef() { clear(); } -void QQmlGuardedContextData::setContextData(QQmlContextData *contextData) +void QQmlContextDataRef::setContextData(QQmlContextData *contextData) { + if (m_contextData == contextData) + return; clear(); if (contextData) { m_contextData = contextData; - m_next = contextData->contextGuards; - if (m_next) m_next->m_prev = &m_next; - m_prev = &contextData->contextGuards; - contextData->contextGuards = this; + ++m_contextData->refCount; } } -QQmlContextData *QQmlGuardedContextData::contextData() const +QQmlContextData *QQmlContextDataRef::contextData() const { return m_contextData; } -void QQmlGuardedContextData::clear() +void QQmlContextDataRef::clear() { - if (m_prev) { - *m_prev = m_next; - if (m_next) m_next->m_prev = m_prev; - m_contextData = 0; - m_next = 0; - m_prev = 0; - } + if (m_contextData && !--m_contextData->refCount) + m_contextData->destroy(); + m_contextData = 0; } -QQmlGuardedContextData & -QQmlGuardedContextData::operator=(QQmlContextData *d) +QQmlContextDataRef & +QQmlContextDataRef::operator=(QQmlContextData *d) { setContextData(d); return *this; } +QQmlContextDataRef & +QQmlContextDataRef::operator=(const QQmlContextDataRef &other) +{ + setContextData(other.m_contextData); + return *this; +} + QQmlContextData::ContextGuard::ContextGuard() : context(0) { diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 2083326cd5..75ea720358 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -78,6 +78,34 @@ struct CompilationUnit; } } +// This is declared here because QQmlData below needs it and this file +// in turn is included from qqmlcontext_p.h. +class QQmlContextData; +class Q_QML_PRIVATE_EXPORT QQmlContextDataRef +{ +public: + inline QQmlContextDataRef(); + inline QQmlContextDataRef(QQmlContextData *); + inline QQmlContextDataRef(const QQmlContextDataRef &); + inline ~QQmlContextDataRef(); + + inline QQmlContextData *contextData() const; + inline void setContextData(QQmlContextData *); + + inline bool isNull() const { return !m_contextData; } + + inline operator QQmlContextData*() const { return m_contextData; } + inline QQmlContextData* operator->() const { return m_contextData; } + inline QQmlContextDataRef &operator=(QQmlContextData *d); + inline QQmlContextDataRef &operator=(const QQmlContextDataRef &other); + +private: + + inline void clear(); + + QQmlContextData *m_contextData; +}; + // This class is structured in such a way, that simply zero'ing it is the // default state for elemental object allocations. This is crucial in the // workings of the QQmlInstruction::CreateSimpleObject instruction. @@ -114,7 +142,6 @@ public: quint32 ownedByQml1:1; // This bit is shared with QML1's QDeclarativeData. quint32 ownMemory:1; - quint32 ownContext:1; quint32 indestructible:1; quint32 explicitIndestructibleSet:1; quint32 hasTaintedV4Object:1; @@ -127,7 +154,7 @@ public: quint32 hasInterceptorMetaObject:1; quint32 hasVMEMetaObject:1; quint32 parentFrozen:1; - quint32 dummy:21; + quint32 dummy:22; // When bindingBitsSize < sizeof(ptr), we store the binding bit flags inside // bindingBitsValue. When we need more than sizeof(ptr) bits, we allocated @@ -161,9 +188,10 @@ public: void disconnectNotifiers(); // The context that created the C++ object - QQmlContextData *context; + QQmlContextData *context = 0; // The outermost context in which this object lives - QQmlContextData *outerContext; + QQmlContextData *outerContext = 0; + QQmlContextDataRef ownContext; QQmlAbstractBinding *bindings; QQmlBoundSignal *signalHandlers; diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 194c58b805..ea148cb29e 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -131,21 +131,21 @@ int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject, 0, 0, 0, - Q_NULLPTR, + nullptr, reason, uri, versionMajor, versionMinor, qmlName, &staticMetaObject, QQmlAttachedPropertiesFunc(), - Q_NULLPTR, + nullptr, 0, 0, 0, - Q_NULLPTR, Q_NULLPTR, + nullptr, nullptr, - Q_NULLPTR, + nullptr, 0 }; @@ -718,8 +718,13 @@ QQmlEnginePrivate::~QQmlEnginePrivate() void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) { if (QQmlData *d = QQmlData::get(o)) { - if (d->ownContext && d->context) { - d->context->destroy(); + if (d->ownContext) { + for (QQmlContextData *lc = d->ownContext->linkedContext; lc; lc = lc->linkedContext) + lc->invalidate(); + d->ownContext->invalidate(); + if (d->ownContext->contextObject == o) + d->ownContext->contextObject = nullptr; + d->ownContext = 0; d->context = 0; } @@ -735,10 +740,10 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) } QQmlData::QQmlData() - : ownedByQml1(false), ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false), + : ownedByQml1(false), ownMemory(true), indestructible(true), explicitIndestructibleSet(false), hasTaintedV4Object(false), isQueuedForDeletion(false), rootObjectInCreation(false), hasInterceptorMetaObject(false), hasVMEMetaObject(false), parentFrozen(false), - bindingBitsSize(MaxInlineBits), bindingBitsValue(0), notifyList(0), context(0), outerContext(0), + bindingBitsSize(MaxInlineBits), bindingBitsValue(0), notifyList(0), bindings(0), signalHandlers(0), nextContextObject(0), prevContextObject(0), lineNumber(0), columnNumber(0), jsEngineId(0), compilationUnit(0), deferredData(0), propertyCache(0), guards(0), extendedData(0) @@ -888,8 +893,12 @@ void QQmlData::setQueuedForDeletion(QObject *object) { if (object) { if (QQmlData *ddata = QQmlData::get(object)) { - if (ddata->ownContext && ddata->context) + if (ddata->ownContext) { + Q_ASSERT(ddata->ownContext == ddata->context); ddata->context->emitDestruction(); + ddata->ownContext = 0; + ddata->context = 0; + } ddata->isQueuedForDeletion = true; } } @@ -1786,8 +1795,7 @@ void QQmlData::destroyed(QObject *object) if (propertyCache) propertyCache->release(); - if (ownContext && context) - context->destroy(); + ownContext = 0; while (guards) { QQmlGuard<QObject> *guard = static_cast<QQmlGuard<QObject> *>(guards); diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h index 2bf4c0497b..b775054253 100644 --- a/src/qml/qml/qqmlengine.h +++ b/src/qml/qml/qqmlengine.h @@ -97,7 +97,7 @@ class Q_QML_EXPORT QQmlEngine : public QJSEngine Q_PROPERTY(QString offlineStoragePath READ offlineStoragePath WRITE setOfflineStoragePath) Q_OBJECT public: - explicit QQmlEngine(QObject *p = Q_NULLPTR); + explicit QQmlEngine(QObject *p = nullptr); virtual ~QQmlEngine(); QQmlContext *rootContext() const; diff --git a/src/qml/qml/qqmlexpression.h b/src/qml/qml/qqmlexpression.h index 5239d59c8a..e9c8770e92 100644 --- a/src/qml/qml/qqmlexpression.h +++ b/src/qml/qml/qqmlexpression.h @@ -60,8 +60,8 @@ class Q_QML_EXPORT QQmlExpression : public QObject Q_OBJECT public: QQmlExpression(); - QQmlExpression(QQmlContext *, QObject *, const QString &, QObject * = Q_NULLPTR); - explicit QQmlExpression(const QQmlScriptString &, QQmlContext * = Q_NULLPTR, QObject * = Q_NULLPTR, QObject * = Q_NULLPTR); + QQmlExpression(QQmlContext *, QObject *, const QString &, QObject * = nullptr); + explicit QQmlExpression(const QQmlScriptString &, QQmlContext * = nullptr, QObject * = nullptr, QObject * = nullptr); virtual ~QQmlExpression(); QQmlEngine *engine() const; @@ -84,7 +84,7 @@ public: void clearError(); QQmlError error() const; - QVariant evaluate(bool *valueIsUndefined = Q_NULLPTR); + QVariant evaluate(bool *valueIsUndefined = nullptr); Q_SIGNALS: void valueChanged(); diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h index c0915c0abe..84a46fb93e 100644 --- a/src/qml/qml/qqmlextensionplugin.h +++ b/src/qml/qml/qqmlextensionplugin.h @@ -58,7 +58,7 @@ class Q_QML_EXPORT QQmlExtensionPlugin Q_INTERFACES(QQmlExtensionInterface) Q_INTERFACES(QQmlTypesExtensionInterface) public: - explicit QQmlExtensionPlugin(QObject *parent = Q_NULLPTR); + explicit QQmlExtensionPlugin(QObject *parent = nullptr); ~QQmlExtensionPlugin(); QUrl baseUrl() const; diff --git a/src/qml/qml/qqmlfileselector.h b/src/qml/qml/qqmlfileselector.h index 03b951420e..4eaf92c918 100644 --- a/src/qml/qml/qqmlfileselector.h +++ b/src/qml/qml/qqmlfileselector.h @@ -54,7 +54,7 @@ class Q_QML_EXPORT QQmlFileSelector : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QQmlFileSelector) public: - explicit QQmlFileSelector(QQmlEngine *engine, QObject *parent = Q_NULLPTR); + explicit QQmlFileSelector(QQmlEngine *engine, QObject *parent = nullptr); ~QQmlFileSelector(); QFileSelector *selector() const Q_DECL_NOTHROW; void setSelector(QFileSelector *selector); diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 7c9dcb1826..bc8be04f24 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -472,6 +472,17 @@ void findCompositeSingletons(const QQmlImportNamespace &set, QList<QQmlImports:: resultList.append(ref); } } + + if (QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->majversion)) { + module->walkCompositeSingletons([&resultList, &set](const QQmlType &singleton) { + QQmlImports::CompositeSingletonReference ref; + ref.typeName = singleton.elementName(); + ref.prefix = set.prefix; + ref.majorVersion = singleton.majorVersion(); + ref.minorVersion = singleton.minorVersion(); + resultList.append(ref); + }); + } } } @@ -1699,13 +1710,13 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e) // env import paths if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QML2_IMPORT_PATH"))) { - const QByteArray envImportPath = qgetenv("QML2_IMPORT_PATH"); + const QString envImportPath = qEnvironmentVariable("QML2_IMPORT_PATH"); #if defined(Q_OS_WIN) QLatin1Char pathSep(';'); #else QLatin1Char pathSep(':'); #endif - QStringList paths = QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts); + QStringList paths = envImportPath.split(pathSep, QString::SkipEmptyParts); for (int ii = paths.count() - 1; ii >= 0; --ii) addImportPath(paths.at(ii)); } diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h index e3955deee5..4c6ae0cb8f 100644 --- a/src/qml/qml/qqmllist.h +++ b/src/qml/qml/qqmllist.h @@ -61,20 +61,20 @@ public: typedef void (*ClearFunction)(QQmlListProperty<T> *); QQmlListProperty() - : object(Q_NULLPTR), - data(Q_NULLPTR), - append(Q_NULLPTR), - count(Q_NULLPTR), - at(Q_NULLPTR), - clear(Q_NULLPTR), - dummy1(Q_NULLPTR), - dummy2(Q_NULLPTR) + : object(nullptr), + data(nullptr), + append(nullptr), + count(nullptr), + at(nullptr), + clear(nullptr), + dummy1(nullptr), + dummy2(nullptr) {} QQmlListProperty(QObject *o, QList<T *> &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), clear(qlist_clear), - dummy1(Q_NULLPTR), - dummy2(Q_NULLPTR) + dummy1(nullptr), + dummy2(nullptr) {} QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r ) @@ -84,17 +84,17 @@ public: count(c), at(t), clear(r), - dummy1(Q_NULLPTR), - dummy2(Q_NULLPTR) + dummy1(nullptr), + dummy2(nullptr) {} QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction t) : object(o), data(d), - append(Q_NULLPTR), + append(nullptr), count(c), at(t), - clear(Q_NULLPTR), - dummy1(Q_NULLPTR), - dummy2(Q_NULLPTR) + clear(nullptr), + dummy1(nullptr), + dummy2(nullptr) {} bool operator==(const QQmlListProperty &o) const { return object == o.object && @@ -140,7 +140,7 @@ class Q_QML_EXPORT QQmlListReference { public: QQmlListReference(); - QQmlListReference(QObject *, const char *property, QQmlEngine * = Q_NULLPTR); + QQmlListReference(QObject *, const char *property, QQmlEngine * = nullptr); QQmlListReference(const QQmlListReference &); QQmlListReference &operator=(const QQmlListReference &); ~QQmlListReference(); diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index a9464c9759..5836c85666 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -235,7 +235,7 @@ public: struct PropertyCacheByMinorVersion { - PropertyCacheByMinorVersion() : cache(Q_NULLPTR), minorVersion(-1) {} + PropertyCacheByMinorVersion() : cache(nullptr), minorVersion(-1) {} explicit PropertyCacheByMinorVersion(QQmlPropertyCache *pc, int ver) : cache(pc), minorVersion(ver) {} QQmlPropertyCachePtr cache; int minorVersion; @@ -837,7 +837,7 @@ QQmlPropertyCache *QQmlTypePrivate::propertyCacheForMinorVersion(int minorVersio for (int i = 0; i < propertyCaches.count(); ++i) if (propertyCaches.at(i).minorVersion == minorVersion) return propertyCaches.at(i).cache; - return Q_NULLPTR; + return nullptr; } void QQmlTypePrivate::setPropertyCacheForMinorVersion(int minorVersion, QQmlPropertyCache *cache) @@ -1303,6 +1303,13 @@ void QQmlType::derefHandle(QQmlTypePrivate *priv) delete priv; } +int QQmlType::refCount(QQmlTypePrivate *priv) +{ + if (priv) + return priv->refCount; + return -1; +} + namespace { template <typename QQmlTypeContainer> void removeQQmlTypePrivate(QQmlTypeContainer &container, const QQmlTypePrivate *reference) @@ -1374,7 +1381,7 @@ void QQmlTypeModulePrivate::add(QQmlTypePrivate *type) void QQmlTypeModulePrivate::remove(const QQmlTypePrivate *type) { for (TypeHash::ConstIterator elementIt = typeHash.begin(); elementIt != typeHash.end();) { - QList<QQmlTypePrivate *> &list = typeHash[elementIt.key()]; + QList<QQmlTypePrivate *> &list = const_cast<QList<QQmlTypePrivate *> &>(elementIt.value()); removeQQmlTypePrivate(list, type); @@ -1417,6 +1424,18 @@ QQmlType QQmlTypeModule::type(const QV4::String *name, int minor) const return QQmlType(); } +void QQmlTypeModule::walkCompositeSingletons(const std::function<void(const QQmlType &)> &callback) const +{ + QMutexLocker lock(metaTypeDataLock()); + for (auto typeCandidates = d->typeHash.begin(), end = d->typeHash.end(); + typeCandidates != end; ++typeCandidates) { + for (auto type: typeCandidates.value()) { + if (type->regType == QQmlType::CompositeSingletonType) + callback(QQmlType(type)); + } + } +} + QQmlTypeModuleVersion::QQmlTypeModuleVersion() : m_module(0), m_minor(0) { @@ -1481,6 +1500,7 @@ void qmlClearTypeRegistrations() // Declared in qqml.h data->urlToNonFileImportType.clear(); data->metaObjectToType.clear(); data->uriToModule.clear(); + data->undeletableTypes.clear(); QQmlEnginePrivate::baseModulesUninitialized = true; //So the engine re-registers its types #if QT_CONFIG(library) @@ -2419,7 +2439,7 @@ void QQmlMetaType::freeUnusedTypesAndCaches() while (it != data->propertyCaches.end()) { if ((*it)->count() == 1) { - QQmlPropertyCache *pc = Q_NULLPTR; + QQmlPropertyCache *pc = nullptr; qSwap(pc, *it); it = data->propertyCaches.erase(it); pc->release(); diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h index 8eb91f321a..720c6d904a 100644 --- a/src/qml/qml/qqmlmetatype_p.h +++ b/src/qml/qml/qqmlmetatype_p.h @@ -253,6 +253,7 @@ public: QQmlTypePrivate *priv() const { return d; } static void refHandle(QQmlTypePrivate *priv); static void derefHandle(QQmlTypePrivate *priv); + static int refCount(QQmlTypePrivate *priv); enum RegistrationType { CppType = 0, @@ -307,6 +308,8 @@ public: QQmlType type(const QHashedStringRef &, int) const; QQmlType type(const QV4::String *, int) const; + void walkCompositeSingletons(const std::function<void(const QQmlType &)> &callback) const; + QQmlTypeModulePrivate *priv() { return d; } private: //Used by register functions and creates the QQmlTypeModule for them diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp index 938e2b77e2..e068ad174a 100644 --- a/src/qml/qml/qqmlnotifier.cpp +++ b/src/qml/qml/qqmlnotifier.cpp @@ -74,7 +74,7 @@ namespace { void QQmlNotifier::notify(QQmlData *ddata, int notifierIndex) { if (QQmlNotifierEndpoint *ep = ddata->notify(notifierIndex)) - emitNotify(ep, Q_NULLPTR); + emitNotify(ep, nullptr); } void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 11d090a415..4042e32120 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -163,7 +163,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI int objectToCreate; if (subComponentIndex == -1) { - objectToCreate = qmlUnit->indexOfRootObject; + objectToCreate = /*root object*/0; } else { const QV4::CompiledData::Object *compObj = qmlUnit->objectAt(subComponentIndex); objectToCreate = compObj->bindingTable()->value.objectIndex; @@ -1113,8 +1113,16 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo return 0; } } - if (parent) + if (instance->isWidgetType()) { + if (parent && parent->isWidgetType()) { + QAbstractDeclarativeData::setWidgetParent(instance, parent); + } else { + // No parent! Layouts need to handle this through a default property that + // reparents accordingly. Otherwise the garbage collector will collect. + } + } else if (parent) { QQml_setParent_noEvent(instance, parent); + } ddata = QQmlData::get(instance, /*create*/true); ddata->lineNumber = obj->location.line; @@ -1122,7 +1130,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo } ddata->setImplicitDestructible(); - if (static_cast<quint32>(index) == qmlUnit->indexOfRootObject || ddata->rootObjectInCreation) { + if (static_cast<quint32>(index) == /*root object*/0 || ddata->rootObjectInCreation) { if (ddata->context) { Q_ASSERT(ddata->context != context); Q_ASSERT(ddata->outerContext); @@ -1132,7 +1140,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo c->linkedContext = context; } else context->addObject(instance); - ddata->ownContext = true; + ddata->ownContext = ddata->context; } else if (!ddata->context) context->addObject(instance); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 38c14c2979..650503f911 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -701,8 +701,7 @@ void QQmlDataBlob::notifyComplete(QQmlDataBlob *blob) { Q_ASSERT(m_waitingFor.contains(blob)); Q_ASSERT(blob->status() == Error || blob->status() == Complete); - QQmlCompilingProfiler prof(QQmlEnginePrivate::get(typeLoader()->engine())->profiler, - blob); + QQmlCompilingProfiler prof(typeLoader()->profiler(), blob); m_inCallback = true; @@ -964,6 +963,14 @@ void QQmlTypeLoader::invalidate() #endif // qml_network } +#ifndef QT_NO_QML_DEBUGGER +void QQmlTypeLoader::setProfiler(QQmlProfiler *profiler) +{ + Q_ASSERT(!m_profiler); + m_profiler.reset(profiler); +} +#endif + void QQmlTypeLoader::lock() { m_thread->lock(); @@ -1263,7 +1270,7 @@ void QQmlTypeLoader::setData(QQmlDataBlob *blob, const QString &fileName) void QQmlTypeLoader::setData(QQmlDataBlob *blob, const QQmlDataBlob::SourceCodeData &d) { QML_MEMORY_SCOPE_URL(blob->url()); - QQmlCompilingProfiler prof(QQmlEnginePrivate::get(engine())->profiler, blob); + QQmlCompilingProfiler prof(profiler(), blob); blob->m_inCallback = true; @@ -1283,7 +1290,7 @@ void QQmlTypeLoader::setData(QQmlDataBlob *blob, const QQmlDataBlob::SourceCodeD void QQmlTypeLoader::setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit) { QML_MEMORY_SCOPE_URL(blob->url()); - QQmlCompilingProfiler prof(QQmlEnginePrivate::get(engine())->profiler, blob); + QQmlCompilingProfiler prof(profiler(), blob); blob->m_inCallback = true; @@ -2815,7 +2822,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent effectiveCtxt = 0; // Create the script context if required - QQmlContextData *ctxt = new QQmlContextData; + QQmlContextDataRef ctxt(new QQmlContextData); ctxt->isInternal = true; ctxt->isJSContext = true; if (shared) @@ -2835,7 +2842,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent } if (effectiveCtxt) { - ctxt->setParent(effectiveCtxt, true); + ctxt->setParent(effectiveCtxt); } else { ctxt->engine = parentCtxt->engine; // Fix for QTBUG-21620 } @@ -2857,12 +2864,10 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent if (!m_program) { if (shared) m_loaded = true; - ctxt->destroy(); return QV4::Encode::undefined(); } QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, 0)); - qmlContext->takeContextOwnership(); m_program->qmlContext.set(scope.engine, qmlContext); m_program->run(); diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 05923f77e8..c214f0cd43 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -84,6 +84,7 @@ class QQmlComponentPrivate; class QQmlTypeData; class QQmlTypeLoader; class QQmlExtensionInterface; +class QQmlProfiler; struct QQmlCompileError; namespace QmlIR { @@ -248,7 +249,7 @@ private: QString m_location; }; -class Q_AUTOTEST_EXPORT QQmlTypeLoader +class Q_QML_PRIVATE_EXPORT QQmlTypeLoader { Q_DECLARE_TR_FUNCTIONS(QQmlTypeLoader) public: @@ -320,6 +321,15 @@ public: void initializeEngine(QQmlExtensionInterface *, const char *); void invalidate(); +#ifdef QT_NO_QML_DEBUGGER + QQmlProfiler *profiler() const { return nullptr; } + void setProfiler(QQmlProfiler *) {} +#else + QQmlProfiler *profiler() const { return m_profiler.data(); } + void setProfiler(QQmlProfiler *profiler); +#endif // QT_NO_QML_DEBUGGER + + private: friend class QQmlDataBlob; friend class QQmlTypeLoaderThread; @@ -368,6 +378,11 @@ private: QQmlEngine *m_engine; QQmlTypeLoaderThread *m_thread; + +#ifndef QT_NO_QML_DEBUGGER + QScopedPointer<QQmlProfiler> m_profiler; +#endif + #if QT_CONFIG(qml_network) NetworkReplies m_networkReplies; #endif diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h index 6e5cd0fb54..8ac25c4fbe 100644 --- a/src/qml/qml/qqmltypenamecache_p.h +++ b/src/qml/qml/qqmltypenamecache_p.h @@ -81,7 +81,7 @@ struct QQmlImportRef { class QQmlType; class QQmlEngine; -class QQmlTypeNameCache : public QQmlRefCount +class Q_QML_PRIVATE_EXPORT QQmlTypeNameCache : public QQmlRefCount { public: QQmlTypeNameCache(const QQmlImports &imports); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index ebca199ee1..90ca08537c 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -400,11 +400,11 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha VALUE_TYPE_LOAD(QMetaType::Bool, bool, bool); QVariant v; - void *args[] = { Q_NULLPTR, Q_NULLPTR }; + void *args[] = { nullptr, nullptr }; if (result->propType() == QMetaType::QVariant) { args[0] = &v; } else { - v = QVariant(result->propType(), static_cast<void *>(Q_NULLPTR)); + v = QVariant(result->propType(), static_cast<void *>(nullptr)); args[0] = v.data(); } metaObject->d.static_metacall(reinterpret_cast<QObject*>(gadget), QMetaObject::ReadProperty, index, args); diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index ea5e9c0904..be1936cfb0 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -101,7 +101,7 @@ public: static QQmlInterceptorMetaObject *get(QObject *obj); - QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *o) Q_DECL_OVERRIDE; + QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *o) override; // Used by auto-tests for inspection QQmlPropertyCache *propertyCache() const { return cache; } @@ -116,7 +116,7 @@ public: } protected: - int metaCall(QObject *o, QMetaObject::Call c, int id, void **a) Q_DECL_OVERRIDE; + int metaCall(QObject *o, QMetaObject::Call c, int id, void **a) override; bool intercept(QMetaObject::Call c, int id, void **a); public: @@ -161,7 +161,7 @@ public: static QQmlVMEMetaObject *getForSignal(QObject *o, int coreIndex); protected: - int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) Q_DECL_OVERRIDE; + int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override; public: QV4::ExecutionEngine *engine; diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 554c4c5bc4..98a37ca5ee 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1077,7 +1077,7 @@ private: void readEncoding(); PersistentValue m_thisObject; - QQmlGuardedContextData m_qmlContext; + QQmlContextDataRef m_qmlContext; static void dispatchCallback(Object *thisObj, QQmlContextData *context); void dispatchCallback(); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index bfa155161d..3627f29cb2 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -532,7 +532,7 @@ ReturnedValue QtObject::method_matrix4x4(const BuiltinFunction *b, CallData *cal QV4::Scope scope(b); if (callData->argc() == 0) { - return scope.engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 0, Q_NULLPTR)); + return scope.engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 0, nullptr)); } if (callData->argc() == 1 && callData->args[0].isObject()) { @@ -1164,6 +1164,10 @@ ReturnedValue QtObject::method_createQmlObject(const BuiltinFunction *b, CallDat if (!component.isReady()) THROW_GENERIC_ERROR("Qt.createQmlObject(): Component is not ready"); + if (!effectiveContext->isValid()) { + THROW_GENERIC_ERROR("Qt.createQmlObject(): Cannot create a component in an invalid context"); + } + QObject *obj = component.beginCreate(effectiveContext); if (obj) { QQmlData::get(obj, true)->explicitIndestructibleSet = false; diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index b8e0f25482..3f801ec2b5 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -268,7 +268,8 @@ QQmlDelegateModel::~QQmlDelegateModel() delete cacheItem->object; cacheItem->object = 0; - cacheItem->contextData->destroy(); + cacheItem->contextData->invalidate(); + Q_ASSERT(cacheItem->contextData->refCount == 1); cacheItem->contextData = 0; cacheItem->scriptRef -= 1; } @@ -839,7 +840,8 @@ void QQDMIncubationTask::statusChanged(Status status) delete incubating->object; incubating->object = 0; if (incubating->contextData) { - incubating->contextData->destroy(); + incubating->contextData->invalidate(); + Q_ASSERT(incubating->contextData->refCount == 1); incubating->contextData = 0; } incubating->scriptRef = 0; @@ -899,8 +901,10 @@ void QQmlDelegateModelPrivate::incubatorStatusChanged(QQDMIncubationTask *incuba delete cacheItem->object; cacheItem->object = 0; cacheItem->scriptRef -= 1; - if (cacheItem->contextData) - cacheItem->contextData->destroy(); + if (cacheItem->contextData) { + cacheItem->contextData->invalidate(); + Q_ASSERT(cacheItem->contextData->refCount == 1); + } cacheItem->contextData = 0; if (!cacheItem->isReferenced()) { @@ -982,7 +986,7 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bo if (QQmlAdaptorModelProxyInterface *proxy = qobject_cast<QQmlAdaptorModelProxyInterface *>(cacheItem)) { ctxt = new QQmlContextData; - ctxt->setParent(cacheItem->contextData, true); + ctxt->setParent(cacheItem->contextData); ctxt->contextObject = proxy->proxiedObject(); } } @@ -1263,6 +1267,13 @@ void QQmlDelegateModel::_q_itemsInserted(int index, int count) d->emitChanges(); } +//### This method should be split in two. It will remove delegates, and it will re-render the list. +// When e.g. QQmlListModel::remove is called, the removal of the delegates should be done on +// QAbstractItemModel::rowsAboutToBeRemoved, and the re-rendering on +// QAbstractItemModel::rowsRemoved. Currently both are done on the latter signal. The problem is +// that the destruction of an item will emit a changed signal that ends up at the delegate, which +// in turn will try to load the data from the model (which should have already freed it), resulting +// in a use-after-free. See QTBUG-59256. void QQmlDelegateModelPrivate::itemsRemoved( const QVector<Compositor::Remove> &removes, QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> *translatedRemoves, @@ -1940,8 +1951,11 @@ void QQmlDelegateModelItem::destroyObject() QQmlData *data = QQmlData::get(object); Q_ASSERT(data); - if (data->ownContext && data->context) - data->context->clearContext(); + if (data->ownContext) { + data->ownContext->clearContext(); + data->ownContext = 0; + data->context = 0; + } object->deleteLater(); if (attached) { @@ -1949,7 +1963,7 @@ void QQmlDelegateModelItem::destroyObject() attached = 0; } - contextData->destroy(); + contextData->invalidate(); contextData = 0; object = 0; } diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 4de6fd0745..e0416e93ee 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -135,7 +135,7 @@ public: QV4::ExecutionEngine *v4; QQmlDelegateModelItemMetaType * const metaType; - QQmlContextData *contextData; + QQmlContextDataRef contextData; QPointer<QObject> object; QPointer<QQmlDelegateModelAttached> attached; QQDMIncubationTask *incubationTask; diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 20000557ee..d088a5da42 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -572,14 +572,20 @@ void ListModel::clear() elements.clear(); } -void ListModel::remove(int index, int count) +QVector<std::function<void()>> ListModel::remove(int index, int count) { + QVector<std::function<void()>> toDestroy; + auto layout = m_layout; for (int i=0 ; i < count ; ++i) { - elements[index+i]->destroy(m_layout); - delete elements[index+i]; + auto element = elements[index+i]; + toDestroy.append([element, layout](){ + element->destroy(layout); + delete element; + }); } elements.remove(index, count); updateCacheIndices(index); + return toDestroy; } void ListModel::insert(int elementIndex, QV4::Object *object) @@ -1394,7 +1400,10 @@ void ModelObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, u p->value = v4->fromVariant(value); return; } - QV4::QObjectWrapper::advanceIterator(m, it, name, index, p, attributes); + // Fall back to QV4::Object as opposed to QV4::QObjectWrapper otherwise it will add + // unnecessary entries that relate to the roles used. These just create extra work + // later on as they will just be ignored. + QV4::Object::advanceIterator(m, it, name, index, p, attributes); } DEFINE_OBJECT_VTABLE(ModelObject); @@ -2059,15 +2068,22 @@ void QQmlListModel::remove(QQmlV4Function *args) emitItemsAboutToBeRemoved(index, removeCount); + QVector<std::function<void()>> toDestroy; if (m_dynamicRoles) { - for (int i=0 ; i < removeCount ; ++i) - delete m_modelObjects[index+i]; + for (int i=0 ; i < removeCount ; ++i) { + auto modelObject = m_modelObjects[index+i]; + toDestroy.append([modelObject](){ + delete modelObject; + }); + } m_modelObjects.remove(index, removeCount); } else { - m_listModel->remove(index, removeCount); + toDestroy = m_listModel->remove(index, removeCount); } emitItemsRemoved(index, removeCount); + for (const auto &destroyer : toDestroy) + destroyer(); } else { qmlWarning(this) << tr("remove: incorrect number of arguments"); } diff --git a/src/qml/types/qqmllistmodel_p.h b/src/qml/types/qqmllistmodel_p.h index b750d30676..372b7c70c7 100644 --- a/src/qml/types/qqmllistmodel_p.h +++ b/src/qml/types/qqmllistmodel_p.h @@ -187,8 +187,8 @@ public: QQmlListModelParser() : QQmlCustomParser(QQmlCustomParser::AcceptsSignalHandlers) {} - void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) Q_DECL_OVERRIDE; - void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) Q_DECL_OVERRIDE; + void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; + void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; private: bool verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding); diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index e2653c220d..77d2002afa 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -367,7 +367,7 @@ public: void insert(int elementIndex, QV4::Object *object); void clear(); - void remove(int index, int count); + Q_REQUIRED_RESULT QVector<std::function<void()>> remove(int index, int count); int appendElement(); void insertElement(int index); diff --git a/src/qml/util/qqmlpropertymap.h b/src/qml/util/qqmlpropertymap.h index 8c5ecce48e..3930ac00a8 100644 --- a/src/qml/util/qqmlpropertymap.h +++ b/src/qml/util/qqmlpropertymap.h @@ -55,7 +55,7 @@ class Q_QML_EXPORT QQmlPropertyMap : public QObject { Q_OBJECT public: - explicit QQmlPropertyMap(QObject *parent = Q_NULLPTR); + explicit QQmlPropertyMap(QObject *parent = nullptr); virtual ~QQmlPropertyMap(); QVariant value(const QString &key) const; diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 993a411013..3cd1694dd0 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -63,6 +63,8 @@ #include <QtCore/QTranslator> #include <QtTest/QSignalSpy> +#include <private/qqmlcomponent_p.h> + #ifdef QT_QMLTEST_WITH_WIDGETS #include <QtWidgets/QApplication> #endif @@ -195,6 +197,133 @@ bool qWaitForSignal(QObject *obj, const char* signal, int timeout = 5000) return spy.size(); } +using namespace QV4::CompiledData; + +class TestCaseCollector +{ +public: + typedef QList<QString> TestCaseList; + + TestCaseCollector(const QFileInfo &fileInfo, QQmlEngine *engine) + { + QQmlComponent component(engine, fileInfo.absoluteFilePath()); + m_errors += component.errors(); + + if (component.isReady()) { + CompilationUnit *rootCompilationUnit = QQmlComponentPrivate::get(&component)->compilationUnit; + TestCaseEnumerationResult result = enumerateTestCases(rootCompilationUnit); + m_testCases = result.testCases + result.finalizedPartialTestCases(); + m_errors += result.errors; + } + } + + TestCaseList testCases() const { return m_testCases; } + QList<QQmlError> errors() const { return m_errors; } + +private: + TestCaseList m_testCases; + QList<QQmlError> m_errors; + + struct TestCaseEnumerationResult + { + TestCaseList testCases; + QList<QQmlError> errors; + + // Partially constructed test cases + bool isTestCase = false; + TestCaseList testFunctions; + QString testCaseName; + + TestCaseList finalizedPartialTestCases() const + { + TestCaseList result; + for (const QString &function : testFunctions) + result << QString(QStringLiteral("%1::%2")).arg(testCaseName).arg(function); + return result; + } + + TestCaseEnumerationResult &operator<<(const TestCaseEnumerationResult &other) + { + testCases += other.testCases + other.finalizedPartialTestCases(); + errors += other.errors; + return *this; + } + }; + + TestCaseEnumerationResult enumerateTestCases(CompilationUnit *compilationUnit, const Object *object = nullptr) + { + QQmlType testCaseType; + for (quint32 i = 0; i < compilationUnit->data->nImports; ++i) { + const Import *import = compilationUnit->data->importAt(i); + if (compilationUnit->stringAt(import->uriIndex) != QLatin1Literal("QtTest")) + continue; + + QString testCaseTypeName(QStringLiteral("TestCase")); + QString typeQualifier = compilationUnit->stringAt(import->qualifierIndex); + if (!typeQualifier.isEmpty()) + testCaseTypeName = typeQualifier % QLatin1Char('.') % testCaseTypeName; + + testCaseType = compilationUnit->typeNameCache->query(testCaseTypeName).type; + if (testCaseType.isValid()) + break; + } + + TestCaseEnumerationResult result; + + if (!object) // Start at root of compilation unit if not enumerating a specific child + object = compilationUnit->objectAt(0); + + if (CompilationUnit *superTypeUnit = compilationUnit->resolvedTypes.value(object->inheritedTypeNameIndex)->compilationUnit) { + // We have a non-C++ super type, which could indicate we're a subtype of a TestCase + if (testCaseType.isValid() && superTypeUnit->url() == testCaseType.sourceUrl()) + result.isTestCase = true; + else + result = enumerateTestCases(superTypeUnit); + + if (result.isTestCase) { + // Look for override of name in this type + for (auto binding = object->bindingsBegin(); binding != object->bindingsEnd(); ++binding) { + if (compilationUnit->stringAt(binding->propertyNameIndex) == QLatin1Literal("name")) { + if (binding->type == QV4::CompiledData::Binding::Type_String) { + result.testCaseName = compilationUnit->stringAt(binding->stringIndex); + } else { + QQmlError error; + error.setUrl(compilationUnit->url()); + error.setLine(binding->location.line); + error.setColumn(binding->location.column); + error.setDescription(QStringLiteral("the 'name' property of a TestCase must be a literal string")); + result.errors << error; + } + break; + } + } + + // Look for additional functions in this type + auto functionsEnd = compilationUnit->objectFunctionsEnd(object); + for (auto function = compilationUnit->objectFunctionsBegin(object); function != functionsEnd; ++function) { + QString functionName = compilationUnit->stringAt(function->nameIndex); + if (!(functionName.startsWith(QLatin1Literal("test_")) || functionName.startsWith(QLatin1Literal("benchmark_")))) + continue; + + if (functionName.endsWith(QLatin1Literal("_data"))) + continue; + + result.testFunctions << functionName; + } + } + } + + for (auto binding = object->bindingsBegin(); binding != object->bindingsEnd(); ++binding) { + if (binding->type == QV4::CompiledData::Binding::Type_Object) { + const Object *child = compilationUnit->objectAt(binding->value.objectIndex); + result << enumerateTestCases(compilationUnit, child); + } + } + + return result; + } +}; + int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir) { // Peek at arguments to check for '-widgets' argument @@ -339,7 +468,32 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD if (!fi.exists()) continue; - QQuickView view ; + QQmlEngine engine; + for (const QString &path : qAsConst(imports)) + engine.addImportPath(path); + for (const QString &path : qAsConst(pluginPaths)) + engine.addPluginPath(path); + + TestCaseCollector testCaseCollector(fi, &engine); + if (!testCaseCollector.errors().isEmpty()) { + for (const QQmlError &error : testCaseCollector.errors()) + qWarning() << error; + exit(1); + } + + TestCaseCollector::TestCaseList availableTestFunctions = testCaseCollector.testCases(); + if (QTest::printAvailableFunctions) { + for (const QString &function : availableTestFunctions) + qDebug("%s()", qPrintable(function)); + continue; + } + + static const QSet<QString> commandLineTestFunctions = QTest::testFunctions.toSet(); + if (!commandLineTestFunctions.isEmpty() && + !availableTestFunctions.toSet().intersects(commandLineTestFunctions)) + continue; + + QQuickView view(&engine, nullptr); view.setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); @@ -350,10 +504,6 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD &eventLoop, SLOT(quit())); view.rootContext()->setContextProperty (QLatin1String("qtest"), QTestRootObject::instance()); // Deprecated. Use QTestRootObject from Qt.test.qtestroot instead - for (const QString &path : qAsConst(imports)) - view.engine()->addImportPath(path); - for (const QString &path : qAsConst(pluginPaths)) - view.engine()->addPluginPath(path); view.setObjectName(fi.baseName()); view.setTitle(view.objectName()); @@ -364,8 +514,6 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD else view.setSource(QUrl::fromLocalFile(path)); - if (QTest::printAvailableFunctions) - continue; while (view.status() == QQuickView::Loading) QTest::qWait(10); if (view.status() == QQuickView::Error) { diff --git a/src/quick/accessible/qaccessiblequickitem_p.h b/src/quick/accessible/qaccessiblequickitem_p.h index 577a105627..5375d37bf0 100644 --- a/src/quick/accessible/qaccessiblequickitem_p.h +++ b/src/quick/accessible/qaccessiblequickitem_p.h @@ -66,73 +66,73 @@ class QAccessibleQuickItem : public QAccessibleObject, public QAccessibleActionI public: QAccessibleQuickItem(QQuickItem *item); - QWindow *window() const Q_DECL_OVERRIDE; + QWindow *window() const override; - QRect rect() const Q_DECL_OVERRIDE; + QRect rect() const override; QRect viewRect() const; bool clipsChildren() const; - QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE; + QAccessibleInterface *childAt(int x, int y) const override; - QAccessibleInterface *parent() const Q_DECL_OVERRIDE; - QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE; - int childCount() const Q_DECL_OVERRIDE; - int indexOfChild(const QAccessibleInterface *iface) const Q_DECL_OVERRIDE; + QAccessibleInterface *parent() const override; + QAccessibleInterface *child(int index) const override; + int childCount() const override; + int indexOfChild(const QAccessibleInterface *iface) const override; QList<QQuickItem *> childItems() const; - QAccessible::State state() const Q_DECL_OVERRIDE; - QAccessible::Role role() const Q_DECL_OVERRIDE; - QString text(QAccessible::Text) const Q_DECL_OVERRIDE; + QAccessible::State state() const override; + QAccessible::Role role() const override; + QString text(QAccessible::Text) const override; bool isAccessible() const; // Action Interface - QStringList actionNames() const Q_DECL_OVERRIDE; - void doAction(const QString &actionName) Q_DECL_OVERRIDE; - QStringList keyBindingsForAction(const QString &actionName) const Q_DECL_OVERRIDE; + QStringList actionNames() const override; + void doAction(const QString &actionName) override; + QStringList keyBindingsForAction(const QString &actionName) const override; // Value Interface - QVariant currentValue() const Q_DECL_OVERRIDE; - void setCurrentValue(const QVariant &value) Q_DECL_OVERRIDE; - QVariant maximumValue() const Q_DECL_OVERRIDE; - QVariant minimumValue() const Q_DECL_OVERRIDE; - QVariant minimumStepSize() const Q_DECL_OVERRIDE; + QVariant currentValue() const override; + void setCurrentValue(const QVariant &value) override; + QVariant maximumValue() const override; + QVariant minimumValue() const override; + QVariant minimumStepSize() const override; // Text Interface - void selection(int selectionIndex, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; - int selectionCount() const Q_DECL_OVERRIDE; - void addSelection(int startOffset, int endOffset) Q_DECL_OVERRIDE; - void removeSelection(int selectionIndex) Q_DECL_OVERRIDE; - void setSelection(int selectionIndex, int startOffset, int endOffset) Q_DECL_OVERRIDE; + void selection(int selectionIndex, int *startOffset, int *endOffset) const override; + int selectionCount() const override; + void addSelection(int startOffset, int endOffset) override; + void removeSelection(int selectionIndex) override; + void setSelection(int selectionIndex, int startOffset, int endOffset) override; // cursor - int cursorPosition() const Q_DECL_OVERRIDE; - void setCursorPosition(int position) Q_DECL_OVERRIDE; + int cursorPosition() const override; + void setCursorPosition(int position) override; // text - QString text(int startOffset, int endOffset) const Q_DECL_OVERRIDE; + QString text(int startOffset, int endOffset) const override; QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; + int *startOffset, int *endOffset) const override; QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; + int *startOffset, int *endOffset) const override; QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; - int characterCount() const Q_DECL_OVERRIDE; + int *startOffset, int *endOffset) const override; + int characterCount() const override; // character <-> geometry - QRect characterRect(int /* offset */) const Q_DECL_OVERRIDE { return QRect(); } - int offsetAtPoint(const QPoint & /* point */) const Q_DECL_OVERRIDE { return -1; } + QRect characterRect(int /* offset */) const override { return QRect(); } + int offsetAtPoint(const QPoint & /* point */) const override { return -1; } - void scrollToSubstring(int /* startIndex */, int /* endIndex */) Q_DECL_OVERRIDE {} - QString attributes(int /* offset */, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE + void scrollToSubstring(int /* startIndex */, int /* endIndex */) override {} + QString attributes(int /* offset */, int *startOffset, int *endOffset) const override { *startOffset = 0; *endOffset = 0; return QString(); } QTextDocument *textDocument() const; protected: QQuickItem *item() const { return static_cast<QQuickItem*>(object()); } - void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE; + void *interface_cast(QAccessible::InterfaceType t) override; private: QTextDocument *m_doc; diff --git a/src/quick/doc/images/touchpoints-pinchhandler.png b/src/quick/doc/images/touchpoints-pinchhandler.png Binary files differnew file mode 100644 index 0000000000..1cf1393364 --- /dev/null +++ b/src/quick/doc/images/touchpoints-pinchhandler.png diff --git a/src/quick/doc/snippets/pointerHandlers/pinchHandler.qml b/src/quick/doc/snippets/pointerHandlers/pinchHandler.qml new file mode 100644 index 0000000000..841e401da1 --- /dev/null +++ b/src/quick/doc/snippets/pointerHandlers/pinchHandler.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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$ +** +****************************************************************************/ +//![0] +import QtQuick 2.8 +import Qt.labs.handlers 1.0 + +Rectangle { + width: 400 + height: 300 + color: "lightsteelblue" + PinchHandler { } +} +//![0] diff --git a/src/quick/doc/snippets/pointerHandlers/pinchHandlerDifferentTarget.qml b/src/quick/doc/snippets/pointerHandlers/pinchHandlerDifferentTarget.qml new file mode 100644 index 0000000000..211c370da6 --- /dev/null +++ b/src/quick/doc/snippets/pointerHandlers/pinchHandlerDifferentTarget.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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$ +** +****************************************************************************/ +//![0] +import QtQuick 2.8 +import Qt.labs.handlers 1.0 + +Item { + width: 640 + height: 480 + + Rectangle { + id: map + color: "aqua" + width: 400 + height: 300 + } + + PinchHandler { + target: map + } +} +//![0] diff --git a/src/quick/doc/snippets/pointerHandlers/pinchHandlerNullTarget.qml b/src/quick/doc/snippets/pointerHandlers/pinchHandlerNullTarget.qml new file mode 100644 index 0000000000..b0139d7194 --- /dev/null +++ b/src/quick/doc/snippets/pointerHandlers/pinchHandlerNullTarget.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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$ +** +****************************************************************************/ +//![0] +import QtQuick 2.8 +import Qt.labs.handlers 1.0 + +Item { + width: 640 + height: 480 + + PinchHandler { + id: handler + target: null + } + + Text { + color: handler.active ? "darkgreen" : "black" + text: handler.rotation.toFixed(1) + " degrees\n" + + handler.translation.x.toFixed(1) + ", " + handler.translation.y.toFixed(1) + "\n" + + (handler.scale * 100).toFixed(1) + "%" + } +} +//![0] diff --git a/src/quick/handlers/qquickhandlersmodule.cpp b/src/quick/handlers/qquickhandlersmodule.cpp index 4a3a1f6aa2..8472c6a062 100644 --- a/src/quick/handlers/qquickhandlersmodule.cpp +++ b/src/quick/handlers/qquickhandlersmodule.cpp @@ -70,13 +70,18 @@ static void qt_quickhandlers_defineModule(const char *uri, int major, int minor) QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent); qmlRegisterUncreatableType<QQuickPointerEvent>(uri, major, minor, "PointerEvent", QQuickPointerHandler::tr("PointerEvent is only available as a parameter of several signals in PointerHandler")); + qmlRegisterUncreatableType<QQuickEventPoint>(uri, major, minor, "EventPoint", + QQuickPointerHandler::tr("EventPoint is only available as a member of PointerEvent")); + qmlRegisterUncreatableType<QQuickEventTouchPoint>(uri, major, minor, "EventTouchPoint", + QQuickPointerHandler::tr("EventTouchPoint is only available as a member of PointerEvent")); qmlRegisterUncreatableType<QQuickPointerDevice>(uri, major, minor, "PointerDevice", QQuickPointerHandler::tr("PointerDevice is only available as a property of PointerEvent")); qRegisterMetaType<QPointingDeviceUniqueId>("QPointingDeviceUniqueId"); qmlRegisterUncreatableType<QPointingDeviceUniqueId>(uri, major, minor, "PointingDeviceUniqueId", QQuickPointerHandler::tr("PointingDeviceUniqueId is only available as a property of PointerEvent")); - qmlRegisterType<QQuickPointerHandler>(uri,major,minor,"PointerHandler"); + qmlRegisterUncreatableType<QQuickPointerHandler>(uri,major,minor,"PointerHandler", + QQuickPointerHandler::tr("PointerHandler is an abstract base class")); qmlRegisterType<QQuickDragHandler>(uri,major,minor,"DragHandler"); qmlRegisterUncreatableType<QQuickDragAxis>(uri, major, minor, "DragAxis", QQuickDragHandler::tr("DragAxis is only available as a grouped property of DragHandler")); diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp index 6cc7747e3a..41d8b228a1 100644 --- a/src/quick/handlers/qquickmultipointhandler.cpp +++ b/src/quick/handlers/qquickmultipointhandler.cpp @@ -80,7 +80,7 @@ QVector<QQuickEventPoint *> QQuickMultiPointHandler::eligiblePoints(QQuickPointe { QVector<QQuickEventPoint *> ret; int c = event->pointCount(); - QRectF targetBounds = target()->mapRectToScene(target()->boundingRect()) + QRectF parentBounds = parentItem()->mapRectToScene(parentItem()->boundingRect()) .marginsAdded(QMarginsF(m_pointDistanceThreshold, m_pointDistanceThreshold, m_pointDistanceThreshold, m_pointDistanceThreshold)); // If one or more points are newly pressed or released, all non-released points are candidates for this handler. // In other cases however, do not steal the grab: that is, if a point has a grabber, @@ -93,7 +93,7 @@ QVector<QQuickEventPoint *> QQuickMultiPointHandler::eligiblePoints(QQuickPointe if (exclusiveGrabber && exclusiveGrabber != this) continue; } - if (p->state() != QQuickEventPoint::Released && targetBounds.contains(p->scenePosition())) + if (p->state() != QQuickEventPoint::Released && parentBounds.contains(p->scenePosition())) ret << p; } return ret; diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp index 92bcc643f3..3cd99fe1a2 100644 --- a/src/quick/handlers/qquickpinchhandler.cpp +++ b/src/quick/handlers/qquickpinchhandler.cpp @@ -55,11 +55,33 @@ Q_LOGGING_CATEGORY(lcPinchHandler, "qt.quick.handler.pinch") /*! \qmltype PinchHandler \instantiates QQuickPinchHandler - \inqmlmodule QtQuick + \inqmlmodule Qt.labs.handlers \ingroup qtquick-handlers \brief Handler for pinch gestures - PinchHandler is a handler that is used to interactively rotate and zoom an Item. + PinchHandler is a handler that interprets a multi-finger gesture to + interactively rotate, zoom, and drag an Item. Like other Pointer Handlers, + by default it is fully functional, and manipulates its \l target, + which is the Item within which it is declared. + + \snippet pointerHandlers/pinchHandler.qml 0 + + It has properties to restrict the range of dragging, rotation, and zoom. + + If it is declared within one Item but is assigned a different \l target, it + handles events within the bounds of the outer Item but manipulates the + \c target Item instead: + + \snippet pointerHandlers/pinchHandlerDifferentTarget.qml 0 + + A third way to use it is to set \l target to \c null and react to property + changes in some other way: + + \snippet pointerHandlers/pinchHandlerNullTarget.qml 0 + + \image touchpoints-pinchhandler.png + + \sa PinchArea */ QQuickPinchHandler::QQuickPinchHandler(QObject *parent) @@ -85,6 +107,12 @@ QQuickPinchHandler::~QQuickPinchHandler() { } +/*! + \qmlproperty real QtQuick::PinchHandler::minimumScale + + The minimum acceptable \l {Item::scale}{scale} to be applied + to the \l target. +*/ void QQuickPinchHandler::setMinimumScale(qreal minimumScale) { if (m_minimumScale == minimumScale) @@ -94,6 +122,12 @@ void QQuickPinchHandler::setMinimumScale(qreal minimumScale) emit minimumScaleChanged(); } +/*! + \qmlproperty real QtQuick::PinchHandler::maximumScale + + The maximum acceptable \l {Item::scale}{scale} to be applied + to the \l target. +*/ void QQuickPinchHandler::setMaximumScale(qreal maximumScale) { if (m_maximumScale == maximumScale) @@ -103,6 +137,12 @@ void QQuickPinchHandler::setMaximumScale(qreal maximumScale) emit maximumScaleChanged(); } +/*! + \qmlproperty real QtQuick::PinchHandler::minimumRotation + + The minimum acceptable \l {Item::rotation}{rotation} to be applied + to the \l target. +*/ void QQuickPinchHandler::setMinimumRotation(qreal minimumRotation) { if (m_minimumRotation == minimumRotation) @@ -112,6 +152,12 @@ void QQuickPinchHandler::setMinimumRotation(qreal minimumRotation) emit minimumRotationChanged(); } +/*! + \qmlproperty real QtQuick::PinchHandler::maximumRotation + + The maximum acceptable \l {Item::rotation}{rotation} to be applied + to the \l target. +*/ void QQuickPinchHandler::setMaximumRotation(qreal maximumRotation) { if (m_maximumRotation == maximumRotation) @@ -121,6 +167,20 @@ void QQuickPinchHandler::setMaximumRotation(qreal maximumRotation) emit maximumRotationChanged(); } +/*! + \qmlproperty real QtQuick::PinchHandler::pinchOrigin + + The point to be held in place, around which the \l target is scaled and + rotated. + + \value FirstPoint + the first touch point, wherever the first finger is pressed + \value PinchCenter + the centroid between all the touch points at the time when the + PinchHandler becomes \l active + \value TargetCenter + the center of the \l target +*/ void QQuickPinchHandler::setPinchOrigin(QQuickPinchHandler::PinchOrigin pinchOrigin) { if (m_pinchOrigin == pinchOrigin) @@ -131,10 +191,10 @@ void QQuickPinchHandler::setPinchOrigin(QQuickPinchHandler::PinchOrigin pinchOri } /*! - \qmlproperty real QQuickPinchHandler::minimumX + \qmlproperty real QtQuick::PinchHandler::minimumX The minimum acceptable x coordinate of the centroid - */ +*/ void QQuickPinchHandler::setMinimumX(qreal minX) { if (m_minimumX == minX) @@ -144,10 +204,10 @@ void QQuickPinchHandler::setMinimumX(qreal minX) } /*! - \qmlproperty real QQuickPinchHandler::maximumX + \qmlproperty real QtQuick::PinchHandler::maximumX The maximum acceptable x coordinate of the centroid - */ +*/ void QQuickPinchHandler::setMaximumX(qreal maxX) { if (m_maximumX == maxX) @@ -157,10 +217,10 @@ void QQuickPinchHandler::setMaximumX(qreal maxX) } /*! - \qmlproperty real QQuickPinchHandler::minimumY + \qmlproperty real QtQuick::PinchHandler::minimumY The minimum acceptable y coordinate of the centroid - */ +*/ void QQuickPinchHandler::setMinimumY(qreal minY) { if (m_minimumY == minY) @@ -170,10 +230,10 @@ void QQuickPinchHandler::setMinimumY(qreal minY) } /*! - \qmlproperty real QQuickPinchHandler::maximumY + \qmlproperty real QtQuick::PinchHandler::maximumY The maximum acceptable y coordinate of the centroid - */ +*/ void QQuickPinchHandler::setMaximumY(qreal maxY) { if (m_maximumY == maxY) @@ -183,7 +243,7 @@ void QQuickPinchHandler::setMaximumY(qreal maxY) } /*! - \qmlproperty QQuickPinchHandler::minimumTouchPoints + \qmlproperty int QtQuick::PinchHandler::minimumTouchPoints The pinch begins when this number of fingers are pressed. Until then, PinchHandler tracks the positions of any pressed fingers, @@ -192,29 +252,35 @@ void QQuickPinchHandler::setMaximumY(qreal maxY) */ /*! - \qmlproperty QQuickPinchHandler::active + \qmlproperty bool QtQuick::PinchHandler::active + + This property is true when all the constraints (epecially \l minimumTouchPoints) + are satisfied and the \l target, if any, is being manipulated. */ void QQuickPinchHandler::onActiveChanged() { if (active()) { + m_startMatrix = QMatrix4x4(); + m_startCentroid = touchPointCentroid(); + m_startAngles = angles(m_startCentroid); + m_startDistance = averageTouchPointDistance(m_startCentroid); + m_activeRotation = 0; + m_activeTranslation = QVector2D(); if (const QQuickItem *t = target()) { m_startScale = t->scale(); // TODO incompatible with independent x/y scaling m_startRotation = t->rotation(); - m_startCentroid = touchPointCentroid(); - m_startAngles = angles(m_startCentroid); - m_startDistance = averageTouchPointDistance(m_startCentroid); QVector3D xformOrigin(t->transformOriginPoint()); - m_startMatrix = QMatrix4x4(); m_startMatrix.translate(t->x(), t->y()); m_startMatrix.translate(xformOrigin); m_startMatrix.scale(m_startScale); m_startMatrix.rotate(m_startRotation, 0, 0, -1); m_startMatrix.translate(-xformOrigin); - m_activeRotation = 0; - m_activeTranslation = QPointF(0,0); - qCInfo(lcPinchHandler) << "activated with starting scale" << m_startScale << "rotation" << m_startRotation; + } else { + m_startScale = 1; + m_startRotation = 0; } + qCInfo(lcPinchHandler) << "activated with starting scale" << m_startScale << "rotation" << m_startRotation; } else { qCInfo(lcPinchHandler) << "deactivated with scale" << m_activeScale << "rotation" << m_activeRotation; } @@ -244,7 +310,7 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event) // TODO check m_pinchOrigin: right now it acts like it's set to PinchCenter m_centroid = touchPointCentroid(); m_centroidVelocity = touchPointCentroidVelocity(); - QRectF bounds(m_minimumX, m_minimumY, m_maximumX, m_maximumY); + QRectF bounds(m_minimumX, m_minimumY, m_maximumX - m_minimumX, m_maximumY - m_minimumY); // avoid mapping the minima and maxima, as they might have unmappable values // such as -inf/+inf. Because of this we perform the bounding to min/max in local coords. QPointF centroidParentPos; @@ -271,7 +337,7 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event) if (target() && target()->parentItem()) { // 3. Drag/translate const QPointF centroidStartParentPos = target()->parentItem()->mapFromScene(m_startCentroid); - m_activeTranslation = centroidParentPos - centroidStartParentPos; + m_activeTranslation = QVector2D(centroidParentPos - centroidStartParentPos); // apply rotation + scaling around the centroid - then apply translation. QMatrix4x4 mat; @@ -293,15 +359,15 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event) target()->setRotation(rotation); target()->setScale(scale); - // TODO some translation inadvertently happens; try to hold the chosen pinch origin in place - - qCDebug(lcPinchHandler) << "centroid" << m_startCentroid << "->" << m_centroid - << ", distance" << m_startDistance << "->" << dist - << ", startScale" << m_startScale << "->" << scale - << ", activeRotation" << m_activeRotation - << ", rotation" << rotation; + } else { + m_activeTranslation = QVector2D(m_centroid - m_startCentroid); } + qCDebug(lcPinchHandler) << "centroid" << m_startCentroid << "->" << m_centroid + << ", distance" << m_startDistance << "->" << dist + << ", startScale" << m_startScale << "->" << scale + << ", activeRotation" << m_activeRotation + << ", rotation" << rotation; if (!containsReleasedPoints) acceptPoints(m_currentPoints); diff --git a/src/quick/handlers/qquickpinchhandler_p.h b/src/quick/handlers/qquickpinchhandler_p.h index 356cc0eed3..b1ece494a5 100644 --- a/src/quick/handlers/qquickpinchhandler_p.h +++ b/src/quick/handlers/qquickpinchhandler_p.h @@ -70,7 +70,7 @@ class Q_AUTOTEST_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler Q_PROPERTY(QVector2D centroidVelocity READ centroidVelocity NOTIFY updated) Q_PROPERTY(qreal scale READ scale NOTIFY updated) Q_PROPERTY(qreal rotation READ rotation NOTIFY updated) - Q_PROPERTY(QPointF translation READ translation NOTIFY updated) + Q_PROPERTY(QVector2D translation READ translation NOTIFY updated) Q_PROPERTY(qreal minimumX READ minimumX WRITE setMinimumX NOTIFY minimumXChanged) Q_PROPERTY(qreal maximumX READ maximumX WRITE setMaximumX NOTIFY maximumXChanged) Q_PROPERTY(qreal minimumY READ minimumY WRITE setMinimumY NOTIFY minimumYChanged) @@ -100,7 +100,7 @@ public: PinchOrigin pinchOrigin() const { return m_pinchOrigin; } void setPinchOrigin(PinchOrigin pinchOrigin); - QPointF translation() const { return m_activeTranslation; } + QVector2D translation() const { return m_activeTranslation; } qreal scale() const { return m_activeScale; } qreal rotation() const { return m_activeRotation; } QPointF centroid() const { return m_centroid; } @@ -136,7 +136,7 @@ private: // properties qreal m_activeScale; qreal m_activeRotation; - QPointF m_activeTranslation; + QVector2D m_activeTranslation; QPointF m_centroid; QVector2D m_centroidVelocity; diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h index aea95ae827..6504ec87f0 100644 --- a/src/quick/handlers/qquicktaphandler_p.h +++ b/src/quick/handlers/qquicktaphandler_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE class Q_AUTOTEST_EXPORT QQuickTapHandler : public QQuickSinglePointHandler { Q_OBJECT - Q_PROPERTY(bool isPressed READ isPressed NOTIFY pressedChanged) + Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged) Q_PROPERTY(int tapCount READ tapCount NOTIFY tapCountChanged) Q_PROPERTY(qreal timeHeld READ timeHeld NOTIFY timeHeldChanged) Q_PROPERTY(qreal longPressThreshold READ longPressThreshold WRITE setLongPressThreshold NOTIFY longPressThresholdChanged) diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index ff90a74c43..7349f45444 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -66,7 +66,7 @@ class QQuickCanvasTextureProvider : public QSGTextureProvider { public: QSGTexture *tex; - QSGTexture *texture() const Q_DECL_OVERRIDE { return tex; } + QSGTexture *texture() const override { return tex; } void fireTextureChanged() { emit textureChanged(); } }; diff --git a/src/quick/items/context2d/qquickcanvasitem_p.h b/src/quick/items/context2d/qquickcanvasitem_p.h index 217ae9bb69..59de847680 100644 --- a/src/quick/items/context2d/qquickcanvasitem_p.h +++ b/src/quick/items/context2d/qquickcanvasitem_p.h @@ -155,8 +155,8 @@ public: Q_INVOKABLE QString toDataURL(const QString& type = QLatin1String("image/png")) const; QQmlRefPointer<QQuickCanvasPixmap> loadedPixmap(const QUrl& url); - bool isTextureProvider() const Q_DECL_OVERRIDE; - QSGTextureProvider *textureProvider() const Q_DECL_OVERRIDE; + bool isTextureProvider() const override; + QSGTextureProvider *textureProvider() const override; Q_SIGNALS: void paint(const QRect ®ion); @@ -185,13 +185,13 @@ private Q_SLOTS: void schedulePolish(); protected: - void componentComplete() Q_DECL_OVERRIDE; - void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &) Q_DECL_OVERRIDE; - void updatePolish() Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void releaseResources() Q_DECL_OVERRIDE; - bool event(QEvent *event) Q_DECL_OVERRIDE; + void componentComplete() override; + void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &) override; + void updatePolish() override; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void releaseResources() override; + bool event(QEvent *event) override; private: Q_DECLARE_PRIVATE(QQuickCanvasItem) Q_INVOKABLE void delayedCreate(); diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index a4e701f59c..3a5d8f7a13 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -4040,7 +4040,7 @@ class QQuickContext2DTextureCleanup : public QRunnable { public: QQuickContext2DTexture *texture; - void run() Q_DECL_OVERRIDE { delete texture; } + void run() override { delete texture; } }; QMutex QQuickContext2D::mutex; diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp index b985cb0ccc..30895d9b0e 100644 --- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp +++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp @@ -100,8 +100,8 @@ namespace { { } - void paint(QPainter *p) const Q_DECL_OVERRIDE { p->fillRect(m_rect, m_brush); } - QRectF boundingRect() const Q_DECL_OVERRIDE { return m_rect; } + void paint(QPainter *p) const override { p->fillRect(m_rect, m_brush); } + QRectF boundingRect() const override { return m_rect; } private: QRectF m_rect; @@ -117,8 +117,8 @@ namespace { { } - void paint(QPainter *p) const Q_DECL_OVERRIDE { p->fillPath(m_path, m_brush); } - QRectF boundingRect() const Q_DECL_OVERRIDE { return m_path.boundingRect(); } + void paint(QPainter *p) const override { p->fillPath(m_path, m_brush); } + QRectF boundingRect() const override { return m_path.boundingRect(); } private: QPainterPath m_path; @@ -134,9 +134,9 @@ namespace { { } - void paint(QPainter *p) const Q_DECL_OVERRIDE { p->strokePath(m_path, m_pen); } + void paint(QPainter *p) const override { p->strokePath(m_path, m_pen); } - QRectF boundingRect() const Q_DECL_OVERRIDE + QRectF boundingRect() const override { qreal d = qMax(qreal(1), m_pen.widthF()); return m_path.boundingRect().adjusted(-d, -d, d, d); @@ -156,9 +156,9 @@ namespace { { } - void paint(QPainter *p) const Q_DECL_OVERRIDE { p->drawImage(m_offset, m_image); } + void paint(QPainter *p) const override { p->drawImage(m_offset, m_image); } - QRectF boundingRect() const Q_DECL_OVERRIDE { return QRectF(m_image.rect()).translated(m_offset); } + QRectF boundingRect() const override { return QRectF(m_image.rect()).translated(m_offset); } private: QImage m_image; diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp index df6dd9dba2..a8bf14ba9f 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture.cpp +++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp @@ -54,6 +54,9 @@ #include <QtGui/QGuiApplication> QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(lcCanvas, "qt.quick.canvas") + #if QT_CONFIG(opengl) #define QT_MINIMUM_FBO_SIZE 64 @@ -96,6 +99,7 @@ QQuickContext2DTexture::QQuickContext2DTexture() #endif , m_surface(0) , m_item(0) + , m_canvasDevicePixelRatio(1) , m_canvasWindowChanged(false) , m_dirtyTexture(false) , m_smooth(true) @@ -161,12 +165,22 @@ void QQuickContext2DTexture::setItem(QQuickCanvasItem* item) bool QQuickContext2DTexture::setCanvasWindow(const QRect& r) { + qreal canvasDevicePixelRatio = (m_item && m_item->window()) ? + m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio(); + if (!qFuzzyCompare(m_canvasDevicePixelRatio, canvasDevicePixelRatio)) { + qCDebug(lcCanvas, "%s device pixel ratio %.1lf -> %.1lf", + (m_item->objectName().isEmpty() ? "Canvas" : qPrintable(m_item->objectName())), + m_canvasDevicePixelRatio, canvasDevicePixelRatio); + m_canvasDevicePixelRatio = canvasDevicePixelRatio; + m_canvasWindowChanged = true; + } + if (m_canvasWindow != r) { m_canvasWindow = r; m_canvasWindowChanged = true; - return true; } - return false; + + return m_canvasWindowChanged; } bool QQuickContext2DTexture::setDirtyRect(const QRect &r) @@ -549,9 +563,6 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() { QQuickContext2DTexture::beginPainting(); - const qreal devicePixelRatio = (m_item && m_item->window()) ? - m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio(); - if (m_canvasWindow.size().isEmpty()) { delete m_fbo; delete m_multisampledFbo; @@ -566,7 +577,7 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() delete m_paint_device; m_paint_device = 0; - m_fboSize = npotAdjustedSize(m_canvasWindow.size() * devicePixelRatio); + m_fboSize = npotAdjustedSize(m_canvasWindow.size() * m_canvasDevicePixelRatio); m_canvasWindowChanged = false; if (doMultisampling()) { @@ -604,7 +615,10 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() QOpenGLPaintDevice *gl_device = new QOpenGLPaintDevice(m_fbo->size()); gl_device->setPaintFlipped(true); gl_device->setSize(m_fbo->size()); - gl_device->setDevicePixelRatio(devicePixelRatio); + gl_device->setDevicePixelRatio(m_canvasDevicePixelRatio); + qCDebug(lcCanvas, "%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", + (m_item->objectName().isEmpty() ? "Canvas" : qPrintable(m_item->objectName())), + m_item->width(), m_item->height(), m_fbo->size().width(), m_fbo->size().height(), m_canvasDevicePixelRatio); m_paint_device = gl_device; } @@ -710,14 +724,15 @@ QPaintDevice* QQuickContext2DImageTexture::beginPainting() if (m_canvasWindow.size().isEmpty()) return 0; - const qreal devicePixelRatio = (m_item && m_item->window()) ? - m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio(); if (m_canvasWindowChanged) { - m_image = QImage(m_canvasWindow.size() * devicePixelRatio, QImage::Format_ARGB32_Premultiplied); - m_image.setDevicePixelRatio(devicePixelRatio); + m_image = QImage(m_canvasWindow.size() * m_canvasDevicePixelRatio, QImage::Format_ARGB32_Premultiplied); + m_image.setDevicePixelRatio(m_canvasDevicePixelRatio); m_image.fill(0x00000000); m_canvasWindowChanged = false; + qCDebug(lcCanvas, "%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", + (m_item->objectName().isEmpty() ? "Canvas" : qPrintable(m_item->objectName())), + m_item->width(), m_item->height(), m_image.size().width(), m_image.size().height(), m_canvasDevicePixelRatio); } return &m_image; diff --git a/src/quick/items/context2d/qquickcontext2dtexture_p.h b/src/quick/items/context2d/qquickcontext2dtexture_p.h index 97135816a2..0e1fbd5d34 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture_p.h +++ b/src/quick/items/context2d/qquickcontext2dtexture_p.h @@ -168,6 +168,7 @@ protected: QSize m_canvasSize; QSize m_tileSize; QRect m_canvasWindow; + qreal m_canvasDevicePixelRatio; QMutex m_mutex; QWaitCondition m_condition; @@ -188,21 +189,21 @@ class QQuickContext2DFBOTexture : public QQuickContext2DTexture public: QQuickContext2DFBOTexture(); ~QQuickContext2DFBOTexture(); - QQuickContext2DTile* createTile() const Q_DECL_OVERRIDE; - QPaintDevice* beginPainting() Q_DECL_OVERRIDE; - void endPainting() Q_DECL_OVERRIDE; + QQuickContext2DTile* createTile() const override; + QPaintDevice* beginPainting() override; + void endPainting() override; QRectF normalizedTextureSubRect() const; - QQuickCanvasItem::RenderTarget renderTarget() const Q_DECL_OVERRIDE; - void compositeTile(QQuickContext2DTile* tile) Q_DECL_OVERRIDE; - QSize adjustedTileSize(const QSize &ts) Q_DECL_OVERRIDE; + QQuickCanvasItem::RenderTarget renderTarget() const override; + void compositeTile(QQuickContext2DTile* tile) override; + QSize adjustedTileSize(const QSize &ts) override; - QSGTexture *textureForNextFrame(QSGTexture *, QQuickWindow *window) Q_DECL_OVERRIDE; + QSGTexture *textureForNextFrame(QSGTexture *, QQuickWindow *window) override; protected: - QVector2D scaleFactor() const Q_DECL_OVERRIDE; + QVector2D scaleFactor() const override; public Q_SLOTS: - void grabImage(const QRectF& region = QRectF()) Q_DECL_OVERRIDE; + void grabImage(const QRectF& region = QRectF()) override; private: bool doMultisampling() const; diff --git a/src/quick/items/context2d/qquickcontext2dtile_p.h b/src/quick/items/context2d/qquickcontext2dtile_p.h index d5255edcfc..c3d4dfef64 100644 --- a/src/quick/items/context2d/qquickcontext2dtile_p.h +++ b/src/quick/items/context2d/qquickcontext2dtile_p.h @@ -93,7 +93,7 @@ class QQuickContext2DFBOTile : public QQuickContext2DTile public: QQuickContext2DFBOTile(); ~QQuickContext2DFBOTile(); - virtual void setRect(const QRect& r) override; + void setRect(const QRect& r) override; QOpenGLFramebufferObject* fbo() const {return m_fbo;} void drawFinished() override; diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp index c0bec7d716..45b405bd82 100644 --- a/src/quick/items/qquickanchors.cpp +++ b/src/quick/items/qquickanchors.cpp @@ -832,7 +832,7 @@ void QQuickAnchors::resetTop() Q_D(QQuickAnchors); d->usedAnchors &= ~TopAnchor; d->remDepend(d->topAnchorItem); - d->topAnchorItem = Q_NULLPTR; + d->topAnchorItem = nullptr; d->topAnchorLine = QQuickAnchors::InvalidAnchor; emit topChanged(); d->updateVerticalAnchors(); @@ -872,7 +872,7 @@ void QQuickAnchors::resetBottom() Q_D(QQuickAnchors); d->usedAnchors &= ~BottomAnchor; d->remDepend(d->bottomAnchorItem); - d->bottomAnchorItem = Q_NULLPTR; + d->bottomAnchorItem = nullptr; d->bottomAnchorLine = QQuickAnchors::InvalidAnchor; emit bottomChanged(); d->updateVerticalAnchors(); @@ -912,7 +912,7 @@ void QQuickAnchors::resetVerticalCenter() Q_D(QQuickAnchors); d->usedAnchors &= ~VCenterAnchor; d->remDepend(d->vCenterAnchorItem); - d->vCenterAnchorItem = Q_NULLPTR; + d->vCenterAnchorItem = nullptr; d->vCenterAnchorLine = QQuickAnchors::InvalidAnchor; emit verticalCenterChanged(); d->updateVerticalAnchors(); @@ -952,7 +952,7 @@ void QQuickAnchors::resetBaseline() Q_D(QQuickAnchors); d->usedAnchors &= ~BaselineAnchor; d->remDepend(d->baselineAnchorItem); - d->baselineAnchorItem = Q_NULLPTR; + d->baselineAnchorItem = nullptr; d->baselineAnchorLine = QQuickAnchors::InvalidAnchor; emit baselineChanged(); d->updateVerticalAnchors(); @@ -992,7 +992,7 @@ void QQuickAnchors::resetLeft() Q_D(QQuickAnchors); d->usedAnchors &= ~LeftAnchor; d->remDepend(d->leftAnchorItem); - d->leftAnchorItem = Q_NULLPTR; + d->leftAnchorItem = nullptr; d->leftAnchorLine = QQuickAnchors::InvalidAnchor; emit leftChanged(); d->updateHorizontalAnchors(); @@ -1032,7 +1032,7 @@ void QQuickAnchors::resetRight() Q_D(QQuickAnchors); d->usedAnchors &= ~RightAnchor; d->remDepend(d->rightAnchorItem); - d->rightAnchorItem = Q_NULLPTR; + d->rightAnchorItem = nullptr; d->rightAnchorLine = QQuickAnchors::InvalidAnchor; emit rightChanged(); d->updateHorizontalAnchors(); @@ -1072,7 +1072,7 @@ void QQuickAnchors::resetHorizontalCenter() Q_D(QQuickAnchors); d->usedAnchors &= ~HCenterAnchor; d->remDepend(d->hCenterAnchorItem); - d->hCenterAnchorItem = Q_NULLPTR; + d->hCenterAnchorItem = nullptr; d->hCenterAnchorLine = QQuickAnchors::InvalidAnchor; emit horizontalCenterChanged(); d->updateHorizontalAnchors(); diff --git a/src/quick/items/qquickanchors_p_p.h b/src/quick/items/qquickanchors_p_p.h index 906f607302..ae6ca02786 100644 --- a/src/quick/items/qquickanchors_p_p.h +++ b/src/quick/items/qquickanchors_p_p.h @@ -90,15 +90,15 @@ public: , hCenterOffset(0) , baselineOffset(0) , item(i) - , fill(Q_NULLPTR) - , centerIn(Q_NULLPTR) - , leftAnchorItem(Q_NULLPTR) - , rightAnchorItem(Q_NULLPTR) - , topAnchorItem(Q_NULLPTR) - , bottomAnchorItem(Q_NULLPTR) - , vCenterAnchorItem(Q_NULLPTR) - , hCenterAnchorItem(Q_NULLPTR) - , baselineAnchorItem(Q_NULLPTR) + , fill(nullptr) + , centerIn(nullptr) + , leftAnchorItem(nullptr) + , rightAnchorItem(nullptr) + , topAnchorItem(nullptr) + , bottomAnchorItem(nullptr) + , vCenterAnchorItem(nullptr) + , hCenterAnchorItem(nullptr) + , baselineAnchorItem(nullptr) , leftAnchorLine(QQuickAnchors::InvalidAnchor) , leftMarginExplicit(false) , rightAnchorLine(QQuickAnchors::InvalidAnchor) @@ -141,8 +141,8 @@ public: void updateMe(); // QQuickItemGeometryListener interface - void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) Q_DECL_OVERRIDE; - QQuickAnchorsPrivate *anchorPrivate() Q_DECL_OVERRIDE { return this; } + void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override; + QQuickAnchorsPrivate *anchorPrivate() override { return this; } bool checkHValid() const; bool checkVValid() const; diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp index a30d71dd1e..5bc5b0faff 100644 --- a/src/quick/items/qquickanimatedimage.cpp +++ b/src/quick/items/qquickanimatedimage.cpp @@ -279,8 +279,7 @@ void QQuickAnimatedImage::setSource(const QUrl &url) d->oldPlaying = isPlaying(); if (d->_movie) { - delete d->_movie; - d->_movie = 0; + d->setMovie(nullptr); } d->url = url; @@ -320,7 +319,7 @@ void QQuickAnimatedImage::load() QString lf = QQmlFile::urlToLocalFileOrQrc(loadUrl); if (!lf.isEmpty()) { - d->_movie = new QMovie(lf); + d->setMovie(new QMovie(lf)); movieRequestFinished(); } else { #if QT_CONFIG(qml_network) @@ -366,14 +365,13 @@ void QQuickAnimatedImage::movieRequestFinished() } d->redirectCount=0; - d->_movie = new QMovie(d->reply); + d->setMovie(new QMovie(d->reply)); } #endif if (!d->_movie || !d->_movie->isValid()) { qmlWarning(this) << "Error Reading Animated Image File " << d->url.toString(); - delete d->_movie; - d->_movie = 0; + d->setMovie(nullptr); d->setImage(QImage()); if (d->progress != 0) { d->progress = 0; @@ -490,6 +488,18 @@ void QQuickAnimatedImage::componentComplete() load(); } +void QQuickAnimatedImagePrivate::setMovie(QMovie *movie) +{ + Q_Q(QQuickAnimatedImage); + const int oldFrameCount = q->frameCount(); + + delete _movie; + _movie = movie; + + if (oldFrameCount != q->frameCount()) + emit q->frameCountChanged(); +} + QT_END_NAMESPACE #include "moc_qquickanimatedimage_p.cpp" diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h index 54da093259..f7a6bd808b 100644 --- a/src/quick/items/qquickanimatedimage_p.h +++ b/src/quick/items/qquickanimatedimage_p.h @@ -69,7 +69,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimatedImage : public QQuickImage Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged) - Q_PROPERTY(int frameCount READ frameCount) + Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged) // read-only for AnimatedImage Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) @@ -90,13 +90,14 @@ public: int frameCount() const; // Extends QQuickImage's src property - void setSource(const QUrl&) Q_DECL_OVERRIDE; + void setSource(const QUrl&) override; virtual QSize sourceSize(); Q_SIGNALS: void playingChanged(); void pausedChanged(); void frameChanged(); + void frameCountChanged(); private Q_SLOTS: void movieUpdate(); @@ -105,8 +106,8 @@ private Q_SLOTS: void onCacheChanged(); protected: - void load() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; + void load() override; + void componentComplete() override; private: Q_DISABLE_COPY(QQuickAnimatedImage) diff --git a/src/quick/items/qquickanimatedimage_p_p.h b/src/quick/items/qquickanimatedimage_p_p.h index 9eff6a44e3..68c4f2d359 100644 --- a/src/quick/items/qquickanimatedimage_p_p.h +++ b/src/quick/items/qquickanimatedimage_p_p.h @@ -91,6 +91,7 @@ public: #endif QMap<int, QQuickPixmap *> frameMap; QSize currentSourceSize; + void setMovie(QMovie *movie); }; QT_END_NAMESPACE diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h index 850461a011..276e6fbb92 100644 --- a/src/quick/items/qquickanimatedsprite_p.h +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -169,8 +169,8 @@ protected Q_SLOTS: void reset(); protected: - void componentComplete() Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + void componentComplete() override; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; private: void maybeUpdate(); bool isCurrentFrameChangedConnected(); diff --git a/src/quick/items/qquickborderimage_p.h b/src/quick/items/qquickborderimage_p.h index 844f71e2c9..f43e6c8e1e 100644 --- a/src/quick/items/qquickborderimage_p.h +++ b/src/quick/items/qquickborderimage_p.h @@ -83,7 +83,7 @@ public: TileMode verticalTileMode() const; void setVerticalTileMode(TileMode); - void setSource(const QUrl &url) Q_DECL_OVERRIDE; + void setSource(const QUrl &url) override; Q_SIGNALS: void horizontalTileModeChanged(); @@ -91,16 +91,16 @@ Q_SIGNALS: void sourceSizeChanged(); protected: - void load() Q_DECL_OVERRIDE; - void pixmapChange() Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + void load() override; + void pixmapChange() override; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; private: void setGridScaledImage(const QQuickGridScaledImage& sci); private Q_SLOTS: void doUpdate(); - void requestFinished() Q_DECL_OVERRIDE; + void requestFinished() override; #if QT_CONFIG(qml_network) void sciRequestFinished(); #endif diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index 41847e5f01..6dc005a03c 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -82,8 +82,8 @@ public: { } - void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) Q_DECL_OVERRIDE; - void itemParentChanged(QQuickItem *, QQuickItem *parent) Q_DECL_OVERRIDE; + void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override; + void itemParentChanged(QQuickItem *, QQuickItem *parent) override; void updatePosition(); void restartDrag(); void deliverEnterEvent(); @@ -772,6 +772,7 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct drag->setPixmap(QPixmap::fromImage(pixmapLoader.image())); } + drag->setHotSpot(hotSpot.toPoint()); emit q->dragStarted(); Qt::DropAction dropAction = drag->exec(supportedActions); diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h index 0c4c072db7..d25cd4decc 100644 --- a/src/quick/items/qquickdroparea_p.h +++ b/src/quick/items/qquickdroparea_p.h @@ -175,10 +175,10 @@ Q_SIGNALS: void dropped(QQuickDropEvent *drop); protected: - void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE; - void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE; - void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE; - void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent *event) override; + void dragEnterEvent(QDragEnterEvent *event) override; + void dragLeaveEvent(QDragLeaveEvent *event) override; + void dropEvent(QDropEvent *event) override; private: Q_DISABLE_COPY(QQuickDropArea) diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index ce584cd283..cd918cef5f 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -56,6 +56,7 @@ #include <QtCore/qmath.h> #include "qplatformdefs.h" +#include <math.h> #include <cmath> QT_BEGIN_NAMESPACE @@ -212,7 +213,7 @@ public: } protected: - void finished() Q_DECL_OVERRIDE { + void finished() override { if (!flickable) return; axisData->move.setValue(axisData->transitionTo); @@ -1771,6 +1772,7 @@ void QQuickFlickable::flick(qreal xVelocity, qreal yVelocity) d->vData.reset(); d->hData.velocity = xVelocity; d->vData.velocity = yVelocity; + d->hData.vTime = d->vData.vTime = d->timeline.time(); bool flickedX = d->flickX(xVelocity); bool flickedY = d->flickY(yVelocity); diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h index 7558ee7df8..4ad01323a4 100644 --- a/src/quick/items/qquickflickable_p.h +++ b/src/quick/items/qquickflickable_p.h @@ -263,14 +263,14 @@ Q_SIGNALS: Q_REVISION(9) void verticalOvershootChanged(); protected: - bool childMouseEventFilter(QQuickItem *, QEvent *) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + bool childMouseEventFilter(QQuickItem *, QEvent *) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; #if QT_CONFIG(wheelevent) - void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; + void wheelEvent(QWheelEvent *event) override; #endif - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) override; QQuickFlickableVisibleArea *visibleArea(); @@ -288,11 +288,11 @@ protected: virtual qreal maxYExtent() const; qreal vWidth() const; qreal vHeight() const; - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; virtual void viewportMoved(Qt::Orientations orient); void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void mouseUngrabEvent() Q_DECL_OVERRIDE; + const QRectF &oldGeometry) override; + void mouseUngrabEvent() override; bool filterMouseEvent(QQuickItem *receiver, QMouseEvent *event); bool xflick() const; diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h index 8609a15fcd..54cc67875a 100644 --- a/src/quick/items/qquickflickable_p_p.h +++ b/src/quick/items/qquickflickable_p_p.h @@ -87,7 +87,7 @@ public: { Velocity(QQuickFlickablePrivate *p) : parent(p) {} - void setValue(qreal v) Q_DECL_OVERRIDE { + void setValue(qreal v) override { if (v != value()) { QQuickTimeLineValue::setValue(v); parent->updateVelocity(); @@ -195,7 +195,7 @@ public: qreal overShootDistance(qreal size) const; - void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) Q_DECL_OVERRIDE; + void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override; void draggingStarting(); void draggingEnding(); diff --git a/src/quick/items/qquickflipable.cpp b/src/quick/items/qquickflipable.cpp index a960cd8b80..4273ed4881 100644 --- a/src/quick/items/qquickflipable.cpp +++ b/src/quick/items/qquickflipable.cpp @@ -57,7 +57,7 @@ public: transform = t; update(); } - void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE { + void applyTo(QMatrix4x4 *matrix) const override { *matrix *= transform; } private: @@ -70,7 +70,7 @@ class QQuickFlipablePrivate : public QQuickItemPrivate public: QQuickFlipablePrivate() : current(QQuickFlipable::Front), front(0), back(0), sideDirty(false) {} - void transformChanged() Q_DECL_OVERRIDE; + void transformChanged() override; void updateSide(); void setBackTransform(); diff --git a/src/quick/items/qquickflipable_p.h b/src/quick/items/qquickflipable_p.h index a76977d4ac..ec922725ef 100644 --- a/src/quick/items/qquickflipable_p.h +++ b/src/quick/items/qquickflipable_p.h @@ -93,7 +93,7 @@ Q_SIGNALS: void sideChanged(); protected: - void updatePolish() Q_DECL_OVERRIDE; + void updatePolish() override; private Q_SLOTS: void retransformBack(); diff --git a/src/quick/items/qquickframebufferobject.cpp b/src/quick/items/qquickframebufferobject.cpp index 042ee21aec..5a40d6b705 100644 --- a/src/quick/items/qquickframebufferobject.cpp +++ b/src/quick/items/qquickframebufferobject.cpp @@ -219,7 +219,7 @@ public: window->update(); } - QSGTexture *texture() const Q_DECL_OVERRIDE + QSGTexture *texture() const override { return QSGSimpleTextureNode::texture(); } diff --git a/src/quick/items/qquickframebufferobject.h b/src/quick/items/qquickframebufferobject.h index 13eeb931ad..d66ca40b3a 100644 --- a/src/quick/items/qquickframebufferobject.h +++ b/src/quick/items/qquickframebufferobject.h @@ -75,7 +75,7 @@ public: void *data; }; - QQuickFramebufferObject(QQuickItem *parent = Q_NULLPTR); + QQuickFramebufferObject(QQuickItem *parent = nullptr); bool textureFollowsItemSize() const; void setTextureFollowsItemSize(bool follows); @@ -85,15 +85,15 @@ public: virtual Renderer *createRenderer() const = 0; - bool isTextureProvider() const Q_DECL_OVERRIDE; - QSGTextureProvider *textureProvider() const Q_DECL_OVERRIDE; - void releaseResources() Q_DECL_OVERRIDE; + bool isTextureProvider() const override; + QSGTextureProvider *textureProvider() const override; + void releaseResources() override; protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; protected: - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; Q_SIGNALS: void textureFollowsItemSizeChanged(bool); diff --git a/src/quick/items/qquickimage_p.h b/src/quick/items/qquickimage_p.h index a5331266c9..09b2c1eeb7 100644 --- a/src/quick/items/qquickimage_p.h +++ b/src/quick/items/qquickimage_p.h @@ -91,7 +91,7 @@ public: qreal paintedWidth() const; qreal paintedHeight() const; - QRectF boundingRect() const Q_DECL_OVERRIDE; + QRectF boundingRect() const override; HAlignment horizontalAlignment() const; void setHorizontalAlignment(HAlignment align); @@ -99,13 +99,13 @@ public: VAlignment verticalAlignment() const; void setVerticalAlignment(VAlignment align); - bool isTextureProvider() const Q_DECL_OVERRIDE { return true; } - QSGTextureProvider *textureProvider() const Q_DECL_OVERRIDE; + bool isTextureProvider() const override { return true; } + QSGTextureProvider *textureProvider() const override; bool mipmap() const; void setMipmap(bool use); - virtual void emitAutoTransformBaseChanged() Q_DECL_OVERRIDE { emit autoTransformChanged(); } + void emitAutoTransformBaseChanged() override { emit autoTransformChanged(); } Q_SIGNALS: void fillModeChanged(); @@ -120,12 +120,12 @@ private Q_SLOTS: protected: QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent); - void pixmapChange() Q_DECL_OVERRIDE; + void pixmapChange() override; void updatePaintedGeometry(); - void releaseResources() Q_DECL_OVERRIDE; + void releaseResources() override; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; private: Q_DISABLE_COPY(QQuickImage) diff --git a/src/quick/items/qquickimagebase_p.h b/src/quick/items/qquickimagebase_p.h index 54b1f789c9..4d4a6fceaf 100644 --- a/src/quick/items/qquickimagebase_p.h +++ b/src/quick/items/qquickimagebase_p.h @@ -115,9 +115,9 @@ Q_SIGNALS: protected: virtual void load(); - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; virtual void pixmapChange(); - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) override; QQuickImageBase(QQuickImageBasePrivate &dd, QQuickItem *parent); private Q_SLOTS: diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 0a5d7adf8b..993d622087 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2488,13 +2488,13 @@ QQuickItem *QQuickItemPrivate::nextTabChildItem(const QQuickItem *item, int star { if (!item) { qWarning() << "QQuickItemPrivate::nextTabChildItem called with null item."; - return Q_NULLPTR; + return nullptr; } const QList<QQuickItem *> &children = item->childItems(); const int count = children.count(); if (start < 0 || start >= count) { qWarning() << "QQuickItemPrivate::nextTabChildItem: Start index value out of range for item" << item; - return Q_NULLPTR; + return nullptr; } while (start < count) { QQuickItem *child = children.at(start); @@ -2502,14 +2502,14 @@ QQuickItem *QQuickItemPrivate::nextTabChildItem(const QQuickItem *item, int star return child; ++start; } - return Q_NULLPTR; + return nullptr; } QQuickItem *QQuickItemPrivate::prevTabChildItem(const QQuickItem *item, int start) { if (!item) { qWarning() << "QQuickItemPrivate::prevTabChildItem called with null item."; - return Q_NULLPTR; + return nullptr; } const QList<QQuickItem *> &children = item->childItems(); const int count = children.count(); @@ -2517,7 +2517,7 @@ QQuickItem *QQuickItemPrivate::prevTabChildItem(const QQuickItem *item, int star start = count - 1; if (start < 0 || start >= count) { qWarning() << "QQuickItemPrivate::prevTabChildItem: Start index value out of range for item" << item; - return Q_NULLPTR; + return nullptr; } while (start >= 0) { QQuickItem *child = children.at(start); @@ -2525,7 +2525,7 @@ QQuickItem *QQuickItemPrivate::prevTabChildItem(const QQuickItem *item, int star return child; --start; } - return Q_NULLPTR; + return nullptr; } QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, bool forward) @@ -2565,8 +2565,8 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo QQuickItem *last = current; bool hasChildren = !current->childItems().isEmpty() && current->isEnabled() && current->isVisible(); - QQuickItem *firstChild = Q_NULLPTR; - QQuickItem *lastChild = Q_NULLPTR; + QQuickItem *firstChild = nullptr; + QQuickItem *lastChild = nullptr; if (hasChildren) { firstChild = nextTabChildItem(current, 0); if (!firstChild) @@ -2598,11 +2598,11 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo if (!current->childItems().isEmpty()) skip = true; // back to the parent - } else if (QQuickItem *parent = !isTabFence ? current->parentItem() : Q_NULLPTR) { + } else if (QQuickItem *parent = !isTabFence ? current->parentItem() : nullptr) { // we would evaluate the parent twice, thus we skip if (forward) { skip = true; - } else if (QQuickItem *firstSibling = !forward ? nextTabChildItem(parent, 0) : Q_NULLPTR) { + } else if (QQuickItem *firstSibling = !forward ? nextTabChildItem(parent, 0) : nullptr) { if (last != firstSibling || (parent->isFocusScope() && parent->activeFocusOnTab() && parent->hasActiveFocus())) skip = true; diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h index 25641f16f9..f6ee54e94d 100644 --- a/src/quick/items/qquickitem.h +++ b/src/quick/items/qquickitem.h @@ -59,7 +59,7 @@ class Q_QUICK_EXPORT QQuickTransform : public QObject { Q_OBJECT public: - explicit QQuickTransform(QObject *parent = Q_NULLPTR); + explicit QQuickTransform(QObject *parent = nullptr); ~QQuickTransform(); void appendToItem(QQuickItem *); @@ -196,7 +196,7 @@ public: }; Q_ENUM(TransformOrigin) - explicit QQuickItem(QQuickItem *parent = Q_NULLPTR); + explicit QQuickItem(QQuickItem *parent = nullptr); virtual ~QQuickItem(); QQuickWindow *window() const; @@ -392,7 +392,7 @@ Q_SIGNALS: void implicitHeightChanged(); protected: - bool event(QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) override; bool isComponentComplete() const; virtual void itemChange(ItemChange, const ItemChangeData &); @@ -405,8 +405,8 @@ protected: bool heightValid() const; // ### better name? void setImplicitSize(qreal, qreal); - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; + void classBegin() override; + void componentComplete() override; virtual void keyPressEvent(QKeyEvent *event); virtual void keyReleaseEvent(QKeyEvent *event); @@ -445,7 +445,7 @@ protected: virtual void updatePolish(); protected: - QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent = Q_NULLPTR); + QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent = nullptr); private: Q_PRIVATE_SLOT(d_func(), void _q_resourceObjectDeleted(QObject *)) diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 446a7d0945..387ce326c2 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -101,10 +101,10 @@ public: void complete(); protected: - void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) Q_DECL_OVERRIDE; - void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; - void itemChildAdded(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE; - void itemChildRemoved(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE; + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override; + void itemDestroyed(QQuickItem *item) override; + void itemChildAdded(QQuickItem *, QQuickItem *) override; + void itemChildRemoved(QQuickItem *, QQuickItem *) override; //void itemVisibilityChanged(QQuickItem *item) private: @@ -194,11 +194,11 @@ public: QQuickShaderEffectSource *effectSource() const { return m_effectSource; } - void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) Q_DECL_OVERRIDE; - void itemOpacityChanged(QQuickItem *) Q_DECL_OVERRIDE; - void itemParentChanged(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE; - void itemSiblingOrderChanged(QQuickItem *) Q_DECL_OVERRIDE; - void itemVisibilityChanged(QQuickItem *) Q_DECL_OVERRIDE; + void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override; + void itemOpacityChanged(QQuickItem *) override; + void itemParentChanged(QQuickItem *, QQuickItem *) override; + void itemSiblingOrderChanged(QQuickItem *) override; + void itemVisibilityChanged(QQuickItem *) override; void updateMatrix(); void updateGeometry(); @@ -712,8 +712,8 @@ Q_SIGNALS: void priorityChanged(); private: - void keyPressed(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; - void keyReleased(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; + void keyPressed(QKeyEvent *event, bool post) override; + void keyReleased(QKeyEvent *event, bool post) override; void setFocusNavigation(QQuickItem *currentItem, const char *dir, Qt::FocusReason reason = Qt::OtherFocusReason); }; @@ -749,7 +749,7 @@ class QQuickEnterKeyAttached : public QObject Q_PROPERTY(Qt::EnterKeyType type READ type WRITE setType NOTIFY typeChanged) public: - explicit QQuickEnterKeyAttached(QObject *parent = Q_NULLPTR); + explicit QQuickEnterKeyAttached(QObject *parent = nullptr); Qt::EnterKeyType type() const; void setType(Qt::EnterKeyType type); @@ -817,7 +817,7 @@ public: return QQmlListProperty<QQuickItem>(this, d->targets); } - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; static QQuickKeysAttached *qmlAttachedProperties(QObject *); @@ -869,11 +869,11 @@ Q_SIGNALS: void volumeDownPressed(QQuickKeyEvent *event); private: - void keyPressed(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; - void keyReleased(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; + void keyPressed(QKeyEvent *event, bool post) override; + void keyReleased(QKeyEvent *event, bool post) override; #if QT_CONFIG(im) - void inputMethodEvent(QInputMethodEvent *, bool post) Q_DECL_OVERRIDE; - QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE; + void inputMethodEvent(QInputMethodEvent *, bool post) override; + QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; #endif void shortcutOverride(QKeyEvent *event) override; static QByteArray keyToSignal(int key); diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp index d4d346def9..4b5c81b4d4 100644 --- a/src/quick/items/qquickitemanimation.cpp +++ b/src/quick/items/qquickitemanimation.cpp @@ -211,7 +211,7 @@ struct QQuickParentAnimationData : public QAbstractAnimationAction //### reverse should probably apply on a per-action basis bool reverse; QList<QQuickParentChange *> pc; - void doAction() Q_DECL_OVERRIDE + void doAction() override { for (int ii = 0; ii < actions.count(); ++ii) { const QQuickStateAction &action = actions.at(ii); diff --git a/src/quick/items/qquickitemanimation_p.h b/src/quick/items/qquickitemanimation_p.h index a503cff223..3b3fad9cc4 100644 --- a/src/quick/items/qquickitemanimation_p.h +++ b/src/quick/items/qquickitemanimation_p.h @@ -89,7 +89,7 @@ protected: QAbstractAnimationJob* transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, - QObject *defaultTarget = 0) Q_DECL_OVERRIDE; + QObject *defaultTarget = 0) override; }; class QQuickAnchorAnimationPrivate; @@ -121,7 +121,7 @@ protected: QAbstractAnimationJob* transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, - QObject *defaultTarget = 0) Q_DECL_OVERRIDE; + QObject *defaultTarget = 0) override; }; #if QT_CONFIG(quick_path) @@ -188,7 +188,7 @@ protected: QAbstractAnimationJob* transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, - QObject *defaultTarget = 0) Q_DECL_OVERRIDE; + QObject *defaultTarget = 0) override; Q_SIGNALS: void durationChanged(int); void easingChanged(const QEasingCurve &); diff --git a/src/quick/items/qquickitemgrabresult.h b/src/quick/items/qquickitemgrabresult.h index 30f8f0c2ef..3dc10e2d75 100644 --- a/src/quick/items/qquickitemgrabresult.h +++ b/src/quick/items/qquickitemgrabresult.h @@ -82,7 +82,7 @@ private Q_SLOTS: private: friend class QQuickItem; - QQuickItemGrabResult(QObject *parent = Q_NULLPTR); + QQuickItemGrabResult(QObject *parent = nullptr); }; QT_END_NAMESPACE diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index 1406e5b547..3c87496c83 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -156,6 +156,9 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) QQmlPrivate::RegisterAutoParent autoparent = { 0, &qquickitem_autoParent }; QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent); + // Register the latest version, even if there are no new types or new revisions for existing types yet. + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); + #if !QT_CONFIG(quick_animatedimage) qmlRegisterTypeNotAvailable(uri,major,minor,"AnimatedImage", QCoreApplication::translate("QQuickAnimatedImage","Qt was built without support for QMovie")); #else diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h index 2c04022cde..374b8388ba 100644 --- a/src/quick/items/qquickitemview_p_p.h +++ b/src/quick/items/qquickitemview_p_p.h @@ -201,7 +201,7 @@ public: void regenerate(bool orientationChanged=false); void layout(); - virtual void animationFinished(QAbstractAnimationJob *) override; + void animationFinished(QAbstractAnimationJob *) override; void refill(); void refill(qreal from, qreal to); void mirrorChange() override; diff --git a/src/quick/items/qquickloader_p.h b/src/quick/items/qquickloader_p.h index db171dcd1e..27e5d1ec8b 100644 --- a/src/quick/items/qquickloader_p.h +++ b/src/quick/items/qquickloader_p.h @@ -105,8 +105,8 @@ Q_SIGNALS: void asynchronousChanged(); protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void componentComplete() override; private: void setSource(const QUrl &sourceUrl, bool needsClear); diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h index 9b6267e011..7492527401 100644 --- a/src/quick/items/qquickloader_p_p.h +++ b/src/quick/items/qquickloader_p_p.h @@ -68,8 +68,8 @@ public: QQuickLoaderIncubator(QQuickLoaderPrivate *l, IncubationMode mode) : QQmlIncubator(mode), loader(l) {} protected: - void statusChanged(Status) Q_DECL_OVERRIDE; - void setInitialState(QObject *) Q_DECL_OVERRIDE; + void statusChanged(Status) override; + void setInitialState(QObject *) override; private: QQuickLoaderPrivate *loader; @@ -84,9 +84,9 @@ public: QQuickLoaderPrivate(); ~QQuickLoaderPrivate(); - void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void itemImplicitWidthChanged(QQuickItem *) Q_DECL_OVERRIDE; - void itemImplicitHeightChanged(QQuickItem *) Q_DECL_OVERRIDE; + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) override; + void itemImplicitWidthChanged(QQuickItem *) override; + void itemImplicitHeightChanged(QQuickItem *) override; void clear(); void initResize(); void load(); @@ -97,8 +97,8 @@ public: static QUrl resolveSourceUrl(QQmlV4Function *args); QV4::ReturnedValue extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error); - qreal getImplicitWidth() const Q_DECL_OVERRIDE; - qreal getImplicitHeight() const Q_DECL_OVERRIDE; + qreal getImplicitWidth() const override; + qreal getImplicitHeight() const override; QUrl source; QQuickItem *item; diff --git a/src/quick/items/qquickmousearea_p.h b/src/quick/items/qquickmousearea_p.h index ee166a2082..ae6c56726e 100644 --- a/src/quick/items/qquickmousearea_p.h +++ b/src/quick/items/qquickmousearea_p.h @@ -164,25 +164,25 @@ protected: bool setPressed(Qt::MouseButton button, bool p, Qt::MouseEventSource source); bool sendMouseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseUngrabEvent() Q_DECL_OVERRIDE; - void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseUngrabEvent() override; + void hoverEnterEvent(QHoverEvent *event) override; + void hoverMoveEvent(QHoverEvent *event) override; + void hoverLeaveEvent(QHoverEvent *event) override; #if QT_CONFIG(wheelevent) - void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; + void wheelEvent(QWheelEvent *event) override; #endif - bool childMouseEventFilter(QQuickItem *i, QEvent *e) Q_DECL_OVERRIDE; - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; - void windowDeactivateEvent() Q_DECL_OVERRIDE; + bool childMouseEventFilter(QQuickItem *i, QEvent *e) override; + void timerEvent(QTimerEvent *event) override; + void windowDeactivateEvent() override; void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void itemChange(ItemChange change, const ItemChangeData& value) Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + const QRectF &oldGeometry) override; + void itemChange(ItemChange change, const ItemChangeData& value) override; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; private: void handlePress(); diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp index 54136b1bbf..bdf30469ce 100644 --- a/src/quick/items/qquickmultipointtoucharea.cpp +++ b/src/quick/items/qquickmultipointtoucharea.cpp @@ -491,7 +491,7 @@ void QQuickMultiPointTouchArea::setMouseEnabled(bool arg) if (_mouseEnabled != arg) { _mouseEnabled = arg; if (_mouseTouchPoint && !arg) - _mouseTouchPoint = Q_NULLPTR; + _mouseTouchPoint = nullptr; emit mouseEnabledChanged(); } } @@ -835,7 +835,7 @@ void QQuickMultiPointTouchArea::mouseReleaseEvent(QMouseEvent *event) updateTouchData(event); _mouseTouchPoint->setInUse(false); _releasedTouchPoints.removeAll(_mouseTouchPoint); - _mouseTouchPoint = Q_NULLPTR; + _mouseTouchPoint = nullptr; } QQuickWindow *c = window(); diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h index 25e1056712..64fe81563d 100644 --- a/src/quick/items/qquickmultipointtoucharea_p.h +++ b/src/quick/items/qquickmultipointtoucharea_p.h @@ -265,13 +265,13 @@ Q_SIGNALS: void mouseEnabledChanged(); protected: - void touchEvent(QTouchEvent *) Q_DECL_OVERRIDE; - bool childMouseEventFilter(QQuickItem *receiver, QEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseUngrabEvent() Q_DECL_OVERRIDE; - void touchUngrabEvent() Q_DECL_OVERRIDE; + void touchEvent(QTouchEvent *) override; + bool childMouseEventFilter(QQuickItem *receiver, QEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseUngrabEvent() override; + void touchUngrabEvent() override; void addTouchPrototype(QQuickTouchPoint* prototype); void addTouchPoint(const QTouchEvent::TouchPoint *p); @@ -285,10 +285,10 @@ protected: bool sendMouseEvent(QMouseEvent *event); bool shouldFilter(QEvent *event); void grabGesture(); - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; #ifdef Q_OS_OSX - void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverEnterEvent(QHoverEvent *event) override; + void hoverLeaveEvent(QHoverEvent *event) override; void setTouchEventsEnabled(bool enable); #endif diff --git a/src/quick/items/qquickopenglshadereffectnode.cpp b/src/quick/items/qquickopenglshadereffectnode.cpp index 5dbfee73cb..a6431135eb 100644 --- a/src/quick/items/qquickopenglshadereffectnode.cpp +++ b/src/quick/items/qquickopenglshadereffectnode.cpp @@ -67,16 +67,16 @@ class QQuickCustomMaterialShader : public QSGMaterialShader { public: QQuickCustomMaterialShader(const QQuickOpenGLShaderEffectMaterialKey &key, const QVector<QByteArray> &attributes); - void deactivate() Q_DECL_OVERRIDE; - void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) Q_DECL_OVERRIDE; - char const *const *attributeNames() const Q_DECL_OVERRIDE; + void deactivate() override; + void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; + char const *const *attributeNames() const override; protected: friend class QQuickOpenGLShaderEffectNode; - void compile() Q_DECL_OVERRIDE; - const char *vertexShader() const Q_DECL_OVERRIDE; - const char *fragmentShader() const Q_DECL_OVERRIDE; + void compile() override; + const char *vertexShader() const override; + const char *fragmentShader() const override; const QQuickOpenGLShaderEffectMaterialKey m_key; QVector<QByteArray> m_attributes; diff --git a/src/quick/items/qquickopenglshadereffectnode_p.h b/src/quick/items/qquickopenglshadereffectnode_p.h index 784294d9eb..68eece7660 100644 --- a/src/quick/items/qquickopenglshadereffectnode_p.h +++ b/src/quick/items/qquickopenglshadereffectnode_p.h @@ -110,9 +110,9 @@ public: }; explicit QQuickOpenGLShaderEffectMaterial(QQuickOpenGLShaderEffectNode *node = 0); - QSGMaterialType *type() const Q_DECL_OVERRIDE; - QSGMaterialShader *createShader() const Q_DECL_OVERRIDE; - int compare(const QSGMaterial *other) const Q_DECL_OVERRIDE; + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; + int compare(const QSGMaterial *other) const override; QVector<QByteArray> attributes; QVector<UniformData> uniforms[QQuickOpenGLShaderEffectMaterialKey::ShaderTypeCount]; @@ -151,7 +151,7 @@ public: QQuickOpenGLShaderEffectNode(); virtual ~QQuickOpenGLShaderEffectNode(); - void preprocess() Q_DECL_OVERRIDE; + void preprocess() override; Q_SIGNALS: void logAndStatusChanged(const QString &, int status); diff --git a/src/quick/items/qquickpainteditem.h b/src/quick/items/qquickpainteditem.h index e8b471ac01..66a0ea83c9 100644 --- a/src/quick/items/qquickpainteditem.h +++ b/src/quick/items/qquickpainteditem.h @@ -57,7 +57,7 @@ class Q_QUICK_EXPORT QQuickPaintedItem : public QQuickItem Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged) public: - explicit QQuickPaintedItem(QQuickItem *parent = Q_NULLPTR); + explicit QQuickPaintedItem(QQuickItem *parent = nullptr); virtual ~QQuickPaintedItem(); enum RenderTarget { @@ -107,8 +107,8 @@ public: virtual void paint(QPainter *painter) = 0; - bool isTextureProvider() const Q_DECL_OVERRIDE; - QSGTextureProvider *textureProvider() const Q_DECL_OVERRIDE; + bool isTextureProvider() const override; + QSGTextureProvider *textureProvider() const override; Q_SIGNALS: void fillColorChanged(); @@ -118,10 +118,10 @@ Q_SIGNALS: void textureSizeChanged(); protected: - QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent = Q_NULLPTR); - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; - void releaseResources() Q_DECL_OVERRIDE; - void itemChange(ItemChange, const ItemChangeData &) Q_DECL_OVERRIDE; + QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent = nullptr); + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; + void releaseResources() override; + void itemChange(ItemChange, const ItemChangeData &) override; private Q_SLOTS: void invalidateSceneGraph(); diff --git a/src/quick/items/qquickpincharea_p.h b/src/quick/items/qquickpincharea_p.h index fc96594a4b..2363f1e2d4 100644 --- a/src/quick/items/qquickpincharea_p.h +++ b/src/quick/items/qquickpincharea_p.h @@ -286,13 +286,13 @@ Q_SIGNALS: Q_REVISION(1) void smartZoom(QQuickPinchEvent *pinch); protected: - bool childMouseEventFilter(QQuickItem *i, QEvent *e) Q_DECL_OVERRIDE; - void touchEvent(QTouchEvent *event) Q_DECL_OVERRIDE; + bool childMouseEventFilter(QQuickItem *i, QEvent *e) override; + void touchEvent(QTouchEvent *event) override; void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void itemChange(ItemChange change, const ItemChangeData& value) Q_DECL_OVERRIDE; - bool event(QEvent *) Q_DECL_OVERRIDE; + const QRectF &oldGeometry) override; + void itemChange(ItemChange change, const ItemChangeData& value) override; + bool event(QEvent *) override; private: void clearPinch(); diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h index 9ae7029d69..ce583aefe8 100644 --- a/src/quick/items/qquickpositioners_p.h +++ b/src/quick/items/qquickpositioners_p.h @@ -158,10 +158,10 @@ public: protected: QQuickBasePositioner(QQuickBasePositionerPrivate &dd, PositionerType at, QQuickItem *parent); - void componentComplete() Q_DECL_OVERRIDE; - void itemChange(ItemChange, const ItemChangeData &) Q_DECL_OVERRIDE; + void componentComplete() override; + void itemChange(ItemChange, const ItemChangeData &) override; - void updatePolish() Q_DECL_OVERRIDE; + void updatePolish() override; Q_SIGNALS: void spacingChanged(); @@ -234,8 +234,8 @@ public: QQuickColumn(QQuickItem *parent=0); protected: - void doPositioning(QSizeF *contentSize) Q_DECL_OVERRIDE; - void reportConflictingAnchors() Q_DECL_OVERRIDE; + void doPositioning(QSizeF *contentSize) override; + void reportConflictingAnchors() override; private: Q_DISABLE_COPY(QQuickColumn) }; @@ -258,8 +258,8 @@ Q_SIGNALS: void effectiveLayoutDirectionChanged(); protected: - void doPositioning(QSizeF *contentSize) Q_DECL_OVERRIDE; - void reportConflictingAnchors() Q_DECL_OVERRIDE; + void doPositioning(QSizeF *contentSize) override; + void reportConflictingAnchors() override; private: Q_DISABLE_COPY(QQuickRow) Q_DECLARE_PRIVATE(QQuickRow) @@ -335,8 +335,8 @@ Q_SIGNALS: Q_REVISION(1) void verticalAlignmentChanged(VAlignment alignment); protected: - void doPositioning(QSizeF *contentSize) Q_DECL_OVERRIDE; - void reportConflictingAnchors() Q_DECL_OVERRIDE; + void doPositioning(QSizeF *contentSize) override; + void reportConflictingAnchors() override; private: int m_rows; @@ -377,8 +377,8 @@ Q_SIGNALS: void effectiveLayoutDirectionChanged(); protected: - void doPositioning(QSizeF *contentSize) Q_DECL_OVERRIDE; - void reportConflictingAnchors() Q_DECL_OVERRIDE; + void doPositioning(QSizeF *contentSize) override; + void reportConflictingAnchors() override; protected: QQuickFlow(QQuickFlowPrivate &dd, QQuickItem *parent); private: diff --git a/src/quick/items/qquickpositioners_p_p.h b/src/quick/items/qquickpositioners_p_p.h index 0be4c56df6..f4cb283a22 100644 --- a/src/quick/items/qquickpositioners_p_p.h +++ b/src/quick/items/qquickpositioners_p_p.h @@ -122,7 +122,7 @@ public: Qt::LayoutDirection layoutDirection; - void mirrorChange() Q_DECL_OVERRIDE { + void mirrorChange() override { effectiveLayoutDirectionChange(); } bool isLeftToRight() const { @@ -132,24 +132,24 @@ public: return effectiveLayoutMirror ? layoutDirection == Qt::RightToLeft : layoutDirection == Qt::LeftToRight; } - void itemSiblingOrderChanged(QQuickItem* other) Q_DECL_OVERRIDE + void itemSiblingOrderChanged(QQuickItem* other) override { Q_UNUSED(other); setPositioningDirty(); } - void itemGeometryChanged(QQuickItem *, QQuickGeometryChange change, const QRectF &) Q_DECL_OVERRIDE + void itemGeometryChanged(QQuickItem *, QQuickGeometryChange change, const QRectF &) override { if (change.sizeChange()) setPositioningDirty(); } - void itemVisibilityChanged(QQuickItem *) Q_DECL_OVERRIDE + void itemVisibilityChanged(QQuickItem *) override { setPositioningDirty(); } - void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE + void itemDestroyed(QQuickItem *item) override { Q_Q(QQuickBasePositioner); int index = q->positionedItems.find(QQuickBasePositioner::PositionedItem(item)); diff --git a/src/quick/items/qquickrectangle_p.h b/src/quick/items/qquickrectangle_p.h index 724a06013c..52f0bc975b 100644 --- a/src/quick/items/qquickrectangle_p.h +++ b/src/quick/items/qquickrectangle_p.h @@ -170,7 +170,7 @@ Q_SIGNALS: void radiusChanged(); protected: - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; private Q_SLOTS: void doUpdate(); diff --git a/src/quick/items/qquickrendercontrol.h b/src/quick/items/qquickrendercontrol.h index 31ea176cc1..a626216f84 100644 --- a/src/quick/items/qquickrendercontrol.h +++ b/src/quick/items/qquickrendercontrol.h @@ -55,7 +55,7 @@ class Q_QUICK_EXPORT QQuickRenderControl : public QObject Q_OBJECT public: - explicit QQuickRenderControl(QObject *parent = Q_NULLPTR); + explicit QQuickRenderControl(QObject *parent = nullptr); ~QQuickRenderControl(); void prepareThread(QThread *targetThread); @@ -68,8 +68,8 @@ public: QImage grab(); - static QWindow *renderWindowFor(QQuickWindow *win, QPoint *offset = Q_NULLPTR); - virtual QWindow *renderWindow(QPoint *offset) { Q_UNUSED(offset); return Q_NULLPTR; } + static QWindow *renderWindowFor(QQuickWindow *win, QPoint *offset = nullptr); + virtual QWindow *renderWindow(QPoint *offset) { Q_UNUSED(offset); return nullptr; } Q_SIGNALS: void renderRequested(); diff --git a/src/quick/items/qquickrepeater_p.h b/src/quick/items/qquickrepeater_p.h index c14c1fb8cb..b630999547 100644 --- a/src/quick/items/qquickrepeater_p.h +++ b/src/quick/items/qquickrepeater_p.h @@ -94,8 +94,8 @@ private: void regenerate(); protected: - void componentComplete() Q_DECL_OVERRIDE; - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void componentComplete() override; + void itemChange(ItemChange change, const ItemChangeData &value) override; private Q_SLOTS: void createdItem(int index, QObject *item); diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index 8f0866f417..592485d6fa 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -876,7 +876,7 @@ void QQuickShaderEffectPrivate::updatePolish() #if QT_CONFIG(opengl) bool QQuickShaderEffect::isOpenGLShaderEffect() const { - return m_glImpl != Q_NULLPTR; + return m_glImpl != nullptr; } #endif diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h index aa3112b5a5..f3ac956f60 100644 --- a/src/quick/items/qquickshadereffectmesh_p.h +++ b/src/quick/items/qquickshadereffectmesh_p.h @@ -95,10 +95,10 @@ class QQuickGridMesh : public QQuickShaderEffectMesh Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged) public: QQuickGridMesh(QObject *parent = 0); - bool validateAttributes(const QVector<QByteArray> &attributes, int *posIndex) Q_DECL_OVERRIDE; + bool validateAttributes(const QVector<QByteArray> &attributes, int *posIndex) override; QSGGeometry *updateGeometry(QSGGeometry *geometry, int attrCount, int posIndex, - const QRectF &srcRect, const QRectF &rect) Q_DECL_OVERRIDE; - QString log() const Q_DECL_OVERRIDE { return m_log; } + const QRectF &srcRect, const QRectF &rect) override; + QString log() const override { return m_log; } void setResolution(const QSize &res); QSize resolution() const; diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp index f61bad1179..b4a45431c5 100644 --- a/src/quick/items/qquickshadereffectsource.cpp +++ b/src/quick/items/qquickshadereffectsource.cpp @@ -87,7 +87,7 @@ public: : texture(t) , provider(p) {} - void run() Q_DECL_OVERRIDE { + void run() override { delete texture; delete provider; } diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h index d9f9079a3d..185c5179b6 100644 --- a/src/quick/items/qquickshadereffectsource_p.h +++ b/src/quick/items/qquickshadereffectsource_p.h @@ -146,8 +146,8 @@ public: TextureMirroring textureMirroring() const; void setTextureMirroring(TextureMirroring mirroring); - bool isTextureProvider() const Q_DECL_OVERRIDE { return true; } - QSGTextureProvider *textureProvider() const Q_DECL_OVERRIDE; + bool isTextureProvider() const override { return true; } + QSGTextureProvider *textureProvider() const override; Q_INVOKABLE void scheduleUpdate(); @@ -174,11 +174,11 @@ private Q_SLOTS: void invalidateSceneGraph(); protected: - void releaseResources() Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + void releaseResources() override; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; - void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) Q_DECL_OVERRIDE; - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override; + void itemChange(ItemChange change, const ItemChangeData &value) override; private: void ensureTexture(); diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h index d68a45ecc0..2f7f6da5c0 100644 --- a/src/quick/items/qquicksprite_p.h +++ b/src/quick/items/qquicksprite_p.h @@ -161,7 +161,7 @@ public: return m_frameDurationVariation; } - int variedDuration() const Q_DECL_OVERRIDE; + int variedDuration() const override; bool frameSync() const { diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h index 4e5458a938..a1c156fa94 100644 --- a/src/quick/items/qquickspriteengine_p.h +++ b/src/quick/items/qquickspriteengine_p.h @@ -290,8 +290,8 @@ public: int spriteCount() const;//Like state count int maxFrames() const; - void restart(int index=0) Q_DECL_OVERRIDE; - void advance(int index=0) Q_DECL_OVERRIDE; + void restart(int index=0) override; + void advance(int index=0) override; //Similar API to QQuickPixmap for async loading convenience bool isNull() const { return status() == QQuickPixmap::Null; } diff --git a/src/quick/items/qquickspritesequence_p.h b/src/quick/items/qquickspritesequence_p.h index b80a8348aa..ffcefecaec 100644 --- a/src/quick/items/qquickspritesequence_p.h +++ b/src/quick/items/qquickspritesequence_p.h @@ -105,7 +105,7 @@ private Q_SLOTS: protected: void reset(); - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; private: void prepareNextFrame(QSGSpriteNode *node); QSGSpriteNode* initNode(); diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp index a4ce13a199..386bb058b5 100644 --- a/src/quick/items/qquickstateoperations.cpp +++ b/src/quick/items/qquickstateoperations.cpp @@ -510,7 +510,7 @@ QQuickStateActionEvent::EventType QQuickParentChange::type() const return ParentChange; } -bool QQuickParentChange::override(QQuickStateActionEvent*other) +bool QQuickParentChange::mayOverride(QQuickStateActionEvent*other) { Q_D(QQuickParentChange); if (other->type() != ParentChange) @@ -1302,7 +1302,7 @@ void QQuickAnchorChanges::clearBindings() } } -bool QQuickAnchorChanges::override(QQuickStateActionEvent*other) +bool QQuickAnchorChanges::mayOverride(QQuickStateActionEvent*other) { if (other->type() != AnchorChanges) return false; diff --git a/src/quick/items/qquickstateoperations_p.h b/src/quick/items/qquickstateoperations_p.h index 48b4b23a76..d61ed294cb 100644 --- a/src/quick/items/qquickstateoperations_p.h +++ b/src/quick/items/qquickstateoperations_p.h @@ -110,17 +110,17 @@ public: void setRotation(QQmlScriptString rotation); bool rotationIsSet() const; - ActionList actions() Q_DECL_OVERRIDE; + ActionList actions() override; - void saveOriginals() Q_DECL_OVERRIDE; + void saveOriginals() override; //virtual void copyOriginals(QQuickStateActionEvent*); - void execute() Q_DECL_OVERRIDE; - bool isReversable() Q_DECL_OVERRIDE; - void reverse() Q_DECL_OVERRIDE; - EventType type() const Q_DECL_OVERRIDE; - bool override(QQuickStateActionEvent*other) Q_DECL_OVERRIDE; - void rewind() Q_DECL_OVERRIDE; - void saveCurrentValues() Q_DECL_OVERRIDE; + void execute() override; + bool isReversable() override; + void reverse() override; + EventType type() const override; + bool mayOverride(QQuickStateActionEvent*other) override; + void rewind() override; + void saveCurrentValues() override; }; class QQuickAnchorChanges; @@ -190,28 +190,28 @@ public: QQuickAnchorChanges(QObject *parent=0); ~QQuickAnchorChanges(); - ActionList actions() Q_DECL_OVERRIDE; + ActionList actions() override; QQuickAnchorSet *anchors() const; QQuickItem *object() const; void setObject(QQuickItem *); - void execute() Q_DECL_OVERRIDE; - bool isReversable() Q_DECL_OVERRIDE; - void reverse() Q_DECL_OVERRIDE; - EventType type() const Q_DECL_OVERRIDE; - bool override(QQuickStateActionEvent*other) Q_DECL_OVERRIDE; - bool changesBindings() Q_DECL_OVERRIDE; - void saveOriginals() Q_DECL_OVERRIDE; - bool needsCopy() Q_DECL_OVERRIDE { return true; } - void copyOriginals(QQuickStateActionEvent*) Q_DECL_OVERRIDE; - void clearBindings() Q_DECL_OVERRIDE; - void rewind() Q_DECL_OVERRIDE; - void saveCurrentValues() Q_DECL_OVERRIDE; + void execute() override; + bool isReversable() override; + void reverse() override; + EventType type() const override; + bool mayOverride(QQuickStateActionEvent*other) override; + bool changesBindings() override; + void saveOriginals() override; + bool needsCopy() override { return true; } + void copyOriginals(QQuickStateActionEvent*) override; + void clearBindings() override; + void rewind() override; + void saveCurrentValues() override; QList<QQuickStateAction> additionalActions() const; - void saveTargetValues() Q_DECL_OVERRIDE; + void saveTargetValues() override; }; QT_END_NAMESPACE diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h index a56bcdb87b..6c48dd86a9 100644 --- a/src/quick/items/qquicktext_p.h +++ b/src/quick/items/qquicktext_p.h @@ -212,15 +212,15 @@ public: FontSizeMode fontSizeMode() const; void setFontSizeMode(FontSizeMode mode); - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; int resourcesLoading() const; // mainly for testing qreal contentWidth() const; qreal contentHeight() const; - QRectF boundingRect() const Q_DECL_OVERRIDE; - QRectF clipRect() const Q_DECL_OVERRIDE; + QRectF boundingRect() const override; + QRectF clipRect() const override; Q_INVOKABLE void doLayout(); // ### Qt 6: remove Q_REVISION(9) Q_INVOKABLE void forceLayout(); @@ -291,18 +291,18 @@ Q_SIGNALS: protected: QQuickText(QQuickTextPrivate &dd, QQuickItem *parent = 0); - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void itemChange(ItemChange change, const ItemChangeData &value) override; void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + const QRectF &oldGeometry) override; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; - void updatePolish() Q_DECL_OVERRIDE; + void updatePolish() override; - void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverEnterEvent(QHoverEvent *event) override; + void hoverMoveEvent(QHoverEvent *event) override; + void hoverLeaveEvent(QHoverEvent *event) override; void invalidateFontCaches(); private Q_SLOTS: diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index 87f5162384..6fd0876a5f 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -78,7 +78,7 @@ public: void updateLayout(); bool determineHorizontalAlignment(); bool setHAlign(QQuickText::HAlignment, bool forceAlign = false); - void mirrorChange() Q_DECL_OVERRIDE; + void mirrorChange() override; bool isLineLaidOutConnected(); void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height); @@ -177,8 +177,8 @@ public: static const QChar elideChar; - qreal getImplicitWidth() const Q_DECL_OVERRIDE; - qreal getImplicitHeight() const Q_DECL_OVERRIDE; + qreal getImplicitWidth() const override; + qreal getImplicitHeight() const override; qreal availableWidth() const; qreal availableHeight() const; diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h index 70104a97e0..862a81af28 100644 --- a/src/quick/items/qquicktextcontrol_p.h +++ b/src/quick/items/qquicktextcontrol_p.h @@ -177,9 +177,9 @@ public: bool cursorOn() const; protected: - void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *e) override; - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; private: Q_DISABLE_COPY(QQuickTextControl) diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index da11913bde..8f3a8998f5 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -2511,7 +2511,7 @@ void QQuickTextEdit::updateSize() if (d->isImplicitResizeEnabled()) { // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. - if (!widthValid() && !d->requireImplicitWidth) + if (!widthValid()) setImplicitSize(newWidth + leftPadding() + rightPadding(), newHeight + topPadding() + bottomPadding()); else setImplicitHeight(newHeight + topPadding() + bottomPadding()); diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h index 23033edb88..c883e39168 100644 --- a/src/quick/items/qquicktextedit_p.h +++ b/src/quick/items/qquicktextedit_p.h @@ -235,7 +235,7 @@ public: bool canUndo() const; bool canRedo() const; - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; /* FROM EDIT */ void setReadOnly(bool); @@ -244,7 +244,7 @@ public: QRectF cursorRectangle() const; #if QT_CONFIG(im) - QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const override; Q_REVISION(4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; #endif @@ -260,8 +260,8 @@ public: Q_INVOKABLE void moveCursorSelection(int pos); Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode); - QRectF boundingRect() const Q_DECL_OVERRIDE; - QRectF clipRect() const Q_DECL_OVERRIDE; + QRectF boundingRect() const override; + QRectF clipRect() const override; bool isInputMethodComposing() const; @@ -387,28 +387,28 @@ protected: QQuickTextEdit(QQuickTextEditPrivate &dd, QQuickItem *parent = 0); void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; + const QRectF &oldGeometry) override; - bool event(QEvent *) Q_DECL_OVERRIDE; - void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; - void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE; - void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; - void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *) override; + void keyPressEvent(QKeyEvent *) override; + void keyReleaseEvent(QKeyEvent *) override; + void focusInEvent(QFocusEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; - void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverEnterEvent(QHoverEvent *event) override; + void hoverMoveEvent(QHoverEvent *event) override; + void hoverLeaveEvent(QHoverEvent *event) override; // mouse filter? - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; #if QT_CONFIG(im) - void inputMethodEvent(QInputMethodEvent *e) Q_DECL_OVERRIDE; + void inputMethodEvent(QInputMethodEvent *e) override; #endif - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) Q_DECL_OVERRIDE; - void updatePolish() Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; + void updatePolish() override; friend class QQuickTextUtil; friend class QQuickTextDocument; diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h index 455fffbcbc..09718cb49a 100644 --- a/src/quick/items/qquicktextedit_p_p.h +++ b/src/quick/items/qquicktextedit_p_p.h @@ -143,8 +143,8 @@ public: void relayoutDocument(); bool determineHorizontalAlignment(); bool setHAlign(QQuickTextEdit::HAlignment, bool forceAlign = false); - void mirrorChange() Q_DECL_OVERRIDE; - qreal getImplicitWidth() const Q_DECL_OVERRIDE; + void mirrorChange() override; + qreal getImplicitWidth() const override; Qt::LayoutDirection textDirection(const QString &text) const; bool isLinkHoveredConnected(); diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h index c4da807471..b7d3fb00fa 100644 --- a/src/quick/items/qquicktextinput_p.h +++ b/src/quick/items/qquicktextinput_p.h @@ -118,7 +118,7 @@ public: QQuickTextInput(QQuickItem * parent=0); ~QQuickTextInput(); - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; enum EchoMode {//To match QLineEdit::EchoMode Normal, @@ -267,12 +267,12 @@ public: bool hasAcceptableInput() const; #if QT_CONFIG(im) - QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const override; Q_REVISION(3) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; #endif - QRectF boundingRect() const Q_DECL_OVERRIDE; - QRectF clipRect() const Q_DECL_OVERRIDE; + QRectF boundingRect() const override; + QRectF clipRect() const override; bool canPaste() const; @@ -366,23 +366,23 @@ protected: QQuickTextInput(QQuickTextInputPrivate &dd, QQuickItem *parent = 0); void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; + const QRectF &oldGeometry) override; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void keyPressEvent(QKeyEvent* ev) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + void keyPressEvent(QKeyEvent* ev) override; #if QT_CONFIG(im) - void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; + void inputMethodEvent(QInputMethodEvent *) override; #endif - void mouseUngrabEvent() Q_DECL_OVERRIDE; - bool event(QEvent *e) Q_DECL_OVERRIDE; - void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; - void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE; - void updatePolish() Q_DECL_OVERRIDE; + void mouseUngrabEvent() override; + bool event(QEvent *e) override; + void focusOutEvent(QFocusEvent *event) override; + void focusInEvent(QFocusEvent *event) override; + void timerEvent(QTimerEvent *event) override; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override; + void updatePolish() override; public Q_SLOTS: void selectAll(); diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h index c3218197a4..c795aebfa9 100644 --- a/src/quick/items/qquicktextinput_p_p.h +++ b/src/quick/items/qquicktextinput_p_p.h @@ -172,7 +172,7 @@ public: void updateVerticalScroll(); bool determineHorizontalAlignment(); bool setHAlign(QQuickTextInput::HAlignment, bool forceAlign = false); - void mirrorChange() Q_DECL_OVERRIDE; + void mirrorChange() override; bool sendMouseEventToInputContext(QMouseEvent *event); #if QT_CONFIG(im) Qt::InputMethodHints effectiveInputMethodHints() const; @@ -451,7 +451,7 @@ public: void updateLayout(); void updateBaselineOffset(); - qreal getImplicitWidth() const Q_DECL_OVERRIDE; + qreal getImplicitWidth() const override; inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; } void setTopPadding(qreal value, bool reset = false); diff --git a/src/quick/items/qquicktranslate_p.h b/src/quick/items/qquicktranslate_p.h index 1bceba20cf..b0199cef40 100644 --- a/src/quick/items/qquicktranslate_p.h +++ b/src/quick/items/qquicktranslate_p.h @@ -75,7 +75,7 @@ public: qreal y() const; void setY(qreal); - void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE; + void applyTo(QMatrix4x4 *matrix) const override; Q_SIGNALS: void xChanged(); @@ -111,7 +111,7 @@ public: qreal zScale() const; void setZScale(qreal); - void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE; + void applyTo(QMatrix4x4 *matrix) const override; Q_SIGNALS: void originChanged(); @@ -146,7 +146,7 @@ public: void setAxis(const QVector3D &axis); void setAxis(Qt::Axis axis); - void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE; + void applyTo(QMatrix4x4 *matrix) const override; Q_SIGNALS: void originChanged(); @@ -170,7 +170,7 @@ public: QMatrix4x4 matrix() const; void setMatrix(const QMatrix4x4& matrix); - void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE; + void applyTo(QMatrix4x4 *matrix) const override; Q_SIGNALS: void matrixChanged(); diff --git a/src/quick/items/qquickview.h b/src/quick/items/qquickview.h index 6d3b30e4c4..142607fa39 100644 --- a/src/quick/items/qquickview.h +++ b/src/quick/items/qquickview.h @@ -60,9 +60,9 @@ class Q_QUICK_EXPORT QQuickView : public QQuickWindow Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) public: - explicit QQuickView(QWindow *parent = Q_NULLPTR); + explicit QQuickView(QWindow *parent = nullptr); QQuickView(QQmlEngine* engine, QWindow *parent); - explicit QQuickView(const QUrl &source, QWindow *parent = Q_NULLPTR); + explicit QQuickView(const QUrl &source, QWindow *parent = nullptr); virtual ~QQuickView(); QUrl source() const; diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index bd1a5076fd..3dfc1295fb 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -132,7 +132,7 @@ public: } protected: - void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE + void timerEvent(QTimerEvent *) override { killTimer(m_timer); m_timer = 0; @@ -163,7 +163,7 @@ public slots: void animationStopped() { incubate(); } protected: - void incubatingObjectCountChanged(int count) Q_DECL_OVERRIDE + void incubatingObjectCountChanged(int count) override { if (count && !m_renderLoop->interleaveIncubation()) incubateAgain(); diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index 022c4738f2..58cfff5ace 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -106,7 +106,7 @@ public: }; Q_ENUM(TextRenderType) - explicit QQuickWindow(QWindow *parent = Q_NULLPTR); + explicit QQuickWindow(QWindow *parent = nullptr); explicit QQuickWindow(QQuickRenderControl *renderControl); virtual ~QQuickWindow(); @@ -114,7 +114,7 @@ public: QQuickItem *contentItem() const; QQuickItem *activeFocusItem() const; - QObject *focusObject() const Q_DECL_OVERRIDE; + QObject *focusObject() const override; QQuickItem *mouseGrabberItem() const; @@ -136,7 +136,7 @@ public: QQmlIncubationController *incubationController() const; #if QT_CONFIG(accessibility) - QAccessibleInterface *accessibleRoot() const Q_DECL_OVERRIDE; + QAccessibleInterface *accessibleRoot() const override; #endif // Scene graph specific functions @@ -202,27 +202,27 @@ public Q_SLOTS: void releaseResources(); protected: - QQuickWindow(QQuickWindowPrivate &dd, QWindow *parent = Q_NULLPTR); + QQuickWindow(QQuickWindowPrivate &dd, QWindow *parent = nullptr); - void exposeEvent(QExposeEvent *) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void exposeEvent(QExposeEvent *) override; + void resizeEvent(QResizeEvent *) override; - void showEvent(QShowEvent *) Q_DECL_OVERRIDE; - void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *) override; + void hideEvent(QHideEvent *) override; // TODO Qt 6: reimplement QWindow::closeEvent to emit closing - void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE; - void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *) override; + void focusOutEvent(QFocusEvent *) override; - bool event(QEvent *) Q_DECL_OVERRIDE; - void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; - void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; - void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) override; + void keyPressEvent(QKeyEvent *) override; + void keyReleaseEvent(QKeyEvent *) override; + void mousePressEvent(QMouseEvent *) override; + void mouseReleaseEvent(QMouseEvent *) override; + void mouseDoubleClickEvent(QMouseEvent *) override; + void mouseMoveEvent(QMouseEvent *) override; #if QT_CONFIG(wheelevent) - void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; + void wheelEvent(QWheelEvent *) override; #endif private Q_SLOTS: diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index 0399b26f62..c636719258 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -333,7 +333,7 @@ class QQuickWindowQObjectCleanupJob : public QRunnable { public: QQuickWindowQObjectCleanupJob(QObject *o) : object(o) { } - void run() Q_DECL_OVERRIDE { delete object; } + void run() override { delete object; } QObject *object; static void schedule(QQuickWindow *window, QObject *object) { Q_ASSERT(window); diff --git a/src/quick/items/qquickwindowattached.cpp b/src/quick/items/qquickwindowattached.cpp index c8d71139ca..ae62a7a496 100644 --- a/src/quick/items/qquickwindowattached.cpp +++ b/src/quick/items/qquickwindowattached.cpp @@ -68,12 +68,12 @@ bool QQuickWindowAttached::isActive() const QQuickItem *QQuickWindowAttached::activeFocusItem() const { - return (m_window ? m_window->activeFocusItem() : Q_NULLPTR); + return (m_window ? m_window->activeFocusItem() : nullptr); } QQuickItem *QQuickWindowAttached::contentItem() const { - return (m_window ? m_window->contentItem() : Q_NULLPTR); + return (m_window ? m_window->contentItem() : nullptr); } int QQuickWindowAttached::width() const diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h index 869d5b9a8e..e7033e9b8d 100644 --- a/src/quick/items/qquickwindowmodule_p.h +++ b/src/quick/items/qquickwindowmodule_p.h @@ -70,7 +70,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWindowQmlImpl : public QQuickWindow, public Q Q_PROPERTY(QObject *screen READ screen WRITE setScreen NOTIFY screenChanged REVISION 2) public: - QQuickWindowQmlImpl(QWindow *parent = Q_NULLPTR); + QQuickWindowQmlImpl(QWindow *parent = nullptr); void setVisible(bool visible); void setVisibility(Visibility visibility); @@ -86,8 +86,8 @@ Q_SIGNALS: Q_REVISION(2) void screenChanged(); protected: - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; + void classBegin() override; + void componentComplete() override; private Q_SLOTS: void setWindowVisibility(); diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarelayer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarelayer.cpp index 2954f591ad..bd5d8f72c0 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarelayer.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarelayer.cpp @@ -50,7 +50,7 @@ QSGSoftwareLayer::QSGSoftwareLayer(QSGRenderContext *renderContext) , m_renderer(0) , m_device_pixel_ratio(1) , m_mirrorHorizontal(false) - , m_mirrorVertical(false) + , m_mirrorVertical(true) , m_live(true) , m_grab(true) , m_recursive(false) diff --git a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h index eb9e7cea7c..304dc008d5 100644 --- a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h +++ b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h @@ -90,7 +90,7 @@ Q_SIGNALS: void sceneGraphChanged(); protected: - explicit QSGAbstractRenderer(QObject *parent = Q_NULLPTR); + explicit QSGAbstractRenderer(QObject *parent = nullptr); virtual void nodeChanged(QSGNode *node, QSGNode::DirtyState state) = 0; private: diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index b0a14d23b9..5c39242029 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -627,9 +627,9 @@ public: }; protected: - void nodeChanged(QSGNode *node, QSGNode::DirtyState state) Q_DECL_OVERRIDE; - void render() Q_DECL_OVERRIDE; - void releaseCachedResources() Q_DECL_OVERRIDE; + void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override; + void render() override; + void releaseCachedResources() override; private: enum ClipTypeBit @@ -698,7 +698,7 @@ private: void visualizeOverdraw(); void visualizeOverdraw_helper(Node *node); void visualizeDrawGeometry(const QSGGeometry *g); - void setCustomRenderMode(const QByteArray &mode) Q_DECL_OVERRIDE; + void setCustomRenderMode(const QByteArray &mode) override; QSGDefaultRenderContext *m_context; QSet<Node *> m_taggedRoots; diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index 1467f2233d..f2708b2b96 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -151,7 +151,7 @@ public: QT_DEPRECATED void clearDirty() { } void markDirty(DirtyState bits); - QT_DEPRECATED DirtyState dirtyState() const { return Q_NULLPTR; } + QT_DEPRECATED DirtyState dirtyState() const { return nullptr; } virtual bool isSubtreeBlocked() const; diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp index 8fbd402a2f..3ae79a933f 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp @@ -50,7 +50,9 @@ QT_BEGIN_NAMESPACE +#if QT_CONFIG(opengl) static const bool qsg_sanity_check = qEnvironmentVariableIntValue("QSG_SANITY_CHECK"); +#endif static QElapsedTimer frameTimer; static qint64 preprocessTime; diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h index 1cb4c56316..b890728fd8 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h @@ -86,8 +86,8 @@ public: bool isMirrored() const; void renderScene(const QSGBindable &bindable); - virtual void renderScene(uint fboId = 0) Q_DECL_OVERRIDE; - virtual void nodeChanged(QSGNode *node, QSGNode::DirtyState state) Q_DECL_OVERRIDE; + void renderScene(uint fboId = 0) override; + void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override; QSGNodeUpdater *nodeUpdater() const; void setNodeUpdater(QSGNodeUpdater *updater); diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index d460794573..fb66a6ebb1 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -143,7 +143,7 @@ public: qCDebug(QSG_LOG_INFO, "Animation Driver: using walltime"); } - void start() Q_DECL_OVERRIDE + void start() override { m_time = 0; m_timer.start(); @@ -151,14 +151,14 @@ public: QAnimationDriver::start(); } - qint64 elapsed() const Q_DECL_OVERRIDE + qint64 elapsed() const override { return m_mode == VSyncMode ? qint64(m_time) : qint64(m_time) + m_wallTime.elapsed(); } - void advance() Q_DECL_OVERRIDE + void advance() override { qint64 delta = m_timer.restart(); diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index bd311d3b46..6583883d0c 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -122,14 +122,14 @@ QSGAdaptationBackendData *contextFactory() } } - if (requestedBackend.isEmpty() && qEnvironmentVariableIsSet("QMLSCENE_DEVICE")) - requestedBackend = QString::fromLocal8Bit(qgetenv("QMLSCENE_DEVICE")); + if (requestedBackend.isEmpty()) + requestedBackend = qEnvironmentVariable("QMLSCENE_DEVICE"); // A modern alternative. Scenegraph adaptations can represent backends // for different graphics APIs as well, instead of being specific to // some device or platform. - if (requestedBackend.isEmpty() && qEnvironmentVariableIsSet("QT_QUICK_BACKEND")) - requestedBackend = QString::fromLocal8Bit(qgetenv("QT_QUICK_BACKEND")); + if (requestedBackend.isEmpty()) + requestedBackend = qEnvironmentVariable("QT_QUICK_BACKEND"); // If this platform does not support OpenGL, and no backend has been set // default to the software renderer diff --git a/src/quick/scenegraph/qsgcontextplugin_p.h b/src/quick/scenegraph/qsgcontextplugin_p.h index 5914b42809..02d4b79b76 100644 --- a/src/quick/scenegraph/qsgcontextplugin_p.h +++ b/src/quick/scenegraph/qsgcontextplugin_p.h @@ -90,7 +90,7 @@ public: explicit QSGContextPlugin(QObject *parent = 0); virtual ~QSGContextPlugin(); - virtual QStringList keys() const override = 0; + QStringList keys() const override = 0; QQuickTextureFactory *createTextureFactoryFromImage(const QImage &) override { return 0; } QSGRenderLoop *createWindowManager() override { return 0; } diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index edb6e92a0d..0169f097bc 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -301,7 +301,7 @@ public: setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/32bitcolortext.frag")); } - void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) Q_DECL_OVERRIDE; + void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; }; void QSG32BitColorTextShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) @@ -310,7 +310,7 @@ void QSG32BitColorTextShader::updateState(const RenderState &state, QSGMaterial QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect); QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect); - if (oldMaterial == Q_NULLPTR || material->color() != oldMaterial->color() || state.isOpacityDirty()) { + if (oldMaterial == nullptr || material->color() != oldMaterial->color() || state.isOpacityDirty()) { float opacity = material->color().w() * state.opacity(); program()->setUniformValue(m_color_id, opacity); } diff --git a/src/quick/scenegraph/qsgdefaultlayer.cpp b/src/quick/scenegraph/qsgdefaultlayer.cpp index 86d74acf54..cd9c4a9a90 100644 --- a/src/quick/scenegraph/qsgdefaultlayer.cpp +++ b/src/quick/scenegraph/qsgdefaultlayer.cpp @@ -60,7 +60,7 @@ namespace public: BindableFbo(QOpenGLFramebufferObject *fbo, QSGDepthStencilBuffer *depthStencil); virtual ~BindableFbo(); - void bind() const Q_DECL_OVERRIDE; + void bind() const override; private: QOpenGLFramebufferObject *m_fbo; QSGDepthStencilBuffer *m_depthStencil; diff --git a/src/quick/scenegraph/qsgdefaultlayer_p.h b/src/quick/scenegraph/qsgdefaultlayer_p.h index 7b09293095..06355e0c21 100644 --- a/src/quick/scenegraph/qsgdefaultlayer_p.h +++ b/src/quick/scenegraph/qsgdefaultlayer_p.h @@ -69,56 +69,56 @@ public: QSGDefaultLayer(QSGRenderContext *context); ~QSGDefaultLayer(); - bool updateTexture() Q_DECL_OVERRIDE; + bool updateTexture() override; // The item's "paint node", not effect node. QSGNode *item() const { return m_item; } - void setItem(QSGNode *item) Q_DECL_OVERRIDE; + void setItem(QSGNode *item) override; QRectF rect() const { return m_rect; } - void setRect(const QRectF &rect) Q_DECL_OVERRIDE; + void setRect(const QRectF &rect) override; QSize size() const { return m_size; } - void setSize(const QSize &size) Q_DECL_OVERRIDE; + void setSize(const QSize &size) override; - void setHasMipmaps(bool mipmap) Q_DECL_OVERRIDE; + void setHasMipmaps(bool mipmap) override; - void bind() Q_DECL_OVERRIDE; + void bind() override; - bool hasAlphaChannel() const Q_DECL_OVERRIDE; - bool hasMipmaps() const Q_DECL_OVERRIDE; - int textureId() const Q_DECL_OVERRIDE; - QSize textureSize() const Q_DECL_OVERRIDE { return m_size; } + bool hasAlphaChannel() const override; + bool hasMipmaps() const override; + int textureId() const override; + QSize textureSize() const override { return m_size; } GLenum format() const { return m_format; } - void setFormat(GLenum format) Q_DECL_OVERRIDE; + void setFormat(GLenum format) override; bool live() const { return bool(m_live); } - void setLive(bool live) Q_DECL_OVERRIDE; + void setLive(bool live) override; bool recursive() const { return bool(m_recursive); } - void setRecursive(bool recursive) Q_DECL_OVERRIDE; + void setRecursive(bool recursive) override; - void setDevicePixelRatio(qreal ratio) Q_DECL_OVERRIDE { m_device_pixel_ratio = ratio; } + void setDevicePixelRatio(qreal ratio) override { m_device_pixel_ratio = ratio; } bool mirrorHorizontal() const { return bool(m_mirrorHorizontal); } - void setMirrorHorizontal(bool mirror) Q_DECL_OVERRIDE; + void setMirrorHorizontal(bool mirror) override; bool mirrorVertical() const { return bool(m_mirrorVertical); } - void setMirrorVertical(bool mirror) Q_DECL_OVERRIDE; + void setMirrorVertical(bool mirror) override; - void scheduleUpdate() Q_DECL_OVERRIDE; + void scheduleUpdate() override; - QImage toImage() const Q_DECL_OVERRIDE; + QImage toImage() const override; - QRectF normalizedTextureSubRect() const Q_DECL_OVERRIDE; + QRectF normalizedTextureSubRect() const override; int samples() const { return m_samples; } - void setSamples(int samples) Q_DECL_OVERRIDE { m_samples = samples; } + void setSamples(int samples) override { m_samples = samples; } public Q_SLOTS: - void markDirtyTexture() Q_DECL_OVERRIDE; - void invalidated() Q_DECL_OVERRIDE; + void markDirtyTexture() override; + void invalidated() override; private: void grab(); diff --git a/src/quick/scenegraph/qsgdefaultspritenode.cpp b/src/quick/scenegraph/qsgdefaultspritenode.cpp index 5eb8fb6e08..7fe6048d59 100644 --- a/src/quick/scenegraph/qsgdefaultspritenode.cpp +++ b/src/quick/scenegraph/qsgdefaultspritenode.cpp @@ -109,7 +109,7 @@ public: setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/sprite.frag")); } - void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) Q_DECL_OVERRIDE + void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) override { QQuickSpriteMaterial *m = static_cast<QQuickSpriteMaterial *>(newEffect); m->texture->bind(); @@ -122,14 +122,14 @@ public: program()->setUniformValue(m_matrix_id, state.combinedMatrix()); } - void initialize() Q_DECL_OVERRIDE { + void initialize() override { m_matrix_id = program()->uniformLocation("qt_Matrix"); m_opacity_id = program()->uniformLocation("qt_Opacity"); m_animData_id = program()->uniformLocation("animData"); m_animPos_id = program()->uniformLocation("animPos"); } - char const *const *attributeNames() const Q_DECL_OVERRIDE { + char const *const *attributeNames() const override { static const char *attr[] = { "vPos", "vTex", diff --git a/src/quick/scenegraph/util/qsgengine.h b/src/quick/scenegraph/util/qsgengine.h index 3c8b61852e..514e6e8c2b 100644 --- a/src/quick/scenegraph/util/qsgengine.h +++ b/src/quick/scenegraph/util/qsgengine.h @@ -67,7 +67,7 @@ public: }; Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption) - explicit QSGEngine(QObject *parent = Q_NULLPTR); + explicit QSGEngine(QObject *parent = nullptr); ~QSGEngine(); void initialize(QOpenGLContext *context); diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h index a7abc5a004..7a1bd8ff13 100644 --- a/src/quick/util/qquickanimation_p_p.h +++ b/src/quick/util/qquickanimation_p_p.h @@ -199,7 +199,7 @@ public: QQuickAnimationGroup *group; QAbstractAnimationJob* animationInstance; - static QQmlProperty createProperty(QObject *obj, const QString &str, QObject *infoObj, QString *errorMessage = Q_NULLPTR); + static QQmlProperty createProperty(QObject *obj, const QString &str, QObject *infoObj, QString *errorMessage = nullptr); }; class QQuickPauseAnimationPrivate : public QQuickAbstractAnimationPrivate diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 14ead56740..5f8d2b94d3 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -398,7 +398,7 @@ public: return QMatrix4x4(matVals); } - const QMetaObject *getMetaObjectForMetaType(int type) Q_DECL_OVERRIDE + const QMetaObject *getMetaObjectForMetaType(int type) override { switch (type) { case QMetaType::QColor: @@ -422,7 +422,7 @@ public: return 0; } - bool init(int type, QVariant& dst) Q_DECL_OVERRIDE + bool init(int type, QVariant& dst) override { switch (type) { case QMetaType::QColor: @@ -452,7 +452,7 @@ public: return false; } - bool create(int type, int argc, const void *argv[], QVariant *v) Q_DECL_OVERRIDE + bool create(int type, int argc, const void *argv[], QVariant *v) override { switch (type) { case QMetaType::QFont: // must specify via js-object. @@ -519,7 +519,7 @@ public: return true; } - bool createFromString(int type, const QString &s, void *data, size_t dataSize) Q_DECL_OVERRIDE + bool createFromString(int type, const QString &s, void *data, size_t dataSize) override { bool ok = false; @@ -542,7 +542,7 @@ public: return false; } - bool createStringFrom(int type, const void *data, QString *s) Q_DECL_OVERRIDE + bool createStringFrom(int type, const void *data, QString *s) override { if (type == QMetaType::QColor) { const QColor *color = reinterpret_cast<const QColor *>(data); @@ -553,7 +553,7 @@ public: return false; } - bool variantFromString(const QString &s, QVariant *v) Q_DECL_OVERRIDE + bool variantFromString(const QString &s, QVariant *v) override { QColor c(s); if (c.isValid()) { @@ -596,7 +596,7 @@ public: return false; } - bool variantFromString(int type, const QString &s, QVariant *v) Q_DECL_OVERRIDE + bool variantFromString(int type, const QString &s, QVariant *v) override { bool ok = false; @@ -639,7 +639,7 @@ public: return false; } - bool variantFromJsObject(int type, QQmlV4Handle object, QV4::ExecutionEngine *v4, QVariant *v) Q_DECL_OVERRIDE + bool variantFromJsObject(int type, QQmlV4Handle object, QV4::ExecutionEngine *v4, QVariant *v) override { QV4::Scope scope(v4); #ifndef QT_NO_DEBUG @@ -665,7 +665,7 @@ public: return (*(reinterpret_cast<const T *>(lhs)) == rhs.value<T>()); } - bool equal(int type, const void *lhs, const QVariant &rhs) Q_DECL_OVERRIDE + bool equal(int type, const void *lhs, const QVariant &rhs) override { switch (type) { case QMetaType::QColor: @@ -698,7 +698,7 @@ public: return true; } - bool store(int type, const void *src, void *dst, size_t dstSize) Q_DECL_OVERRIDE + bool store(int type, const void *src, void *dst, size_t dstSize) override { Q_UNUSED(dstSize); switch (type) { @@ -728,7 +728,7 @@ public: return true; } - bool read(const QVariant &src, void *dst, int dstType) Q_DECL_OVERRIDE + bool read(const QVariant &src, void *dst, int dstType) override { switch (dstType) { case QMetaType::QColor: @@ -762,7 +762,7 @@ public: return false; } - bool write(int type, const void *src, QVariant& dst) Q_DECL_OVERRIDE + bool write(int type, const void *src, QVariant& dst) override { switch (type) { case QMetaType::QColor: diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp index 61380b3ea0..4a9b4a95c1 100644 --- a/src/quick/util/qquickpropertychanges.cpp +++ b/src/quick/util/qquickpropertychanges.cpp @@ -180,7 +180,7 @@ public: rewindExpression = QQmlPropertyPrivate::signalExpression(property); } - bool override(QQuickStateActionEvent *other) override { + bool mayOverride(QQuickStateActionEvent *other) override { if (other == this) return true; if (other->type() != type()) diff --git a/src/quick/util/qquickshortcut_p.h b/src/quick/util/qquickshortcut_p.h index db918058b2..c5d5501cb7 100644 --- a/src/quick/util/qquickshortcut_p.h +++ b/src/quick/util/qquickshortcut_p.h @@ -74,7 +74,7 @@ class QQuickShortcut : public QObject, public QQmlParserStatus Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext NOTIFY contextChanged FINAL) public: - explicit QQuickShortcut(QObject *parent = Q_NULLPTR); + explicit QQuickShortcut(QObject *parent = nullptr); ~QQuickShortcut(); QVariant sequence() const; @@ -106,9 +106,9 @@ Q_SIGNALS: void activatedAmbiguously(); protected: - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; - bool event(QEvent *event) Q_DECL_OVERRIDE; + void classBegin() override; + void componentComplete() override; + bool event(QEvent *event) override; struct Shortcut { Shortcut() : id(0) { } diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp index 0a49d41491..65e51feb81 100644 --- a/src/quick/util/qquickstate.cpp +++ b/src/quick/util/qquickstate.cpp @@ -106,7 +106,7 @@ void QQuickStateActionEvent::clearBindings() { } -bool QQuickStateActionEvent::override(QQuickStateActionEvent *other) +bool QQuickStateActionEvent::mayOverride(QQuickStateActionEvent *other) { Q_UNUSED(other); return false; @@ -574,7 +574,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert) for (int jj = 0; jj < d->revertList.count(); ++jj) { QQuickStateActionEvent *event = d->revertList.at(jj).event(); if (event && event->type() == action.event->type()) { - if (action.event->override(event)) { + if (action.event->mayOverride(event)) { found = true; if (action.event != d->revertList.at(jj).event() && action.event->needsCopy()) { @@ -636,7 +636,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert) for (int jj = 0; !found && jj < applyList.count(); ++jj) { const QQuickStateAction &action = applyList.at(jj); if (action.event && action.event->type() == event->type()) { - if (action.event->override(event)) + if (action.event->mayOverride(event)) found = true; } } diff --git a/src/quick/util/qquickstate_p.h b/src/quick/util/qquickstate_p.h index 7d22ca9f8c..ac720f4189 100644 --- a/src/quick/util/qquickstate_p.h +++ b/src/quick/util/qquickstate_p.h @@ -115,7 +115,7 @@ public: virtual bool changesBindings(); virtual void clearBindings(); - virtual bool override(QQuickStateActionEvent*other); + virtual bool mayOverride(QQuickStateActionEvent*other); }; //### rename to QQuickStateChange? diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 6784155d25..1fea73818c 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -80,7 +80,7 @@ class QQuickWidgetRenderControl : public QQuickRenderControl { public: QQuickWidgetRenderControl(QQuickWidget *quickwidget) : m_quickWidget(quickwidget) {} - QWindow *renderWindow(QPoint *offset) Q_DECL_OVERRIDE { + QWindow *renderWindow(QPoint *offset) override { if (offset) *offset = m_quickWidget->mapTo(m_quickWidget->window(), QPoint()); return m_quickWidget->window()->windowHandle(); diff --git a/src/quickwidgets/qquickwidget.h b/src/quickwidgets/qquickwidget.h index 2d159778ed..e7fbc62967 100644 --- a/src/quickwidgets/qquickwidget.h +++ b/src/quickwidgets/qquickwidget.h @@ -64,9 +64,9 @@ class Q_QUICKWIDGETS_EXPORT QQuickWidget : public QWidget Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) public: - explicit QQuickWidget(QWidget *parent = Q_NULLPTR); + explicit QQuickWidget(QWidget *parent = nullptr); QQuickWidget(QQmlEngine* engine, QWidget *parent); - explicit QQuickWidget(const QUrl &source, QWidget *parent = Q_NULLPTR); + explicit QQuickWidget(const QUrl &source, QWidget *parent = nullptr); virtual ~QQuickWidget(); QUrl source() const; diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h index 6892e6e0b4..a92fb9f6bd 100644 --- a/src/quickwidgets/qquickwidget_p.h +++ b/src/quickwidgets/qquickwidget_p.h @@ -87,7 +87,7 @@ public: ~QQuickWidgetPrivate(); void execute(); - void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) override; void initResize(); void updateSize(); void updatePosition(); @@ -100,8 +100,8 @@ public: void handleContextCreationFailure(const QSurfaceFormat &format, bool isEs); #if QT_CONFIG(opengl) - GLuint textureId() const Q_DECL_OVERRIDE; - QImage grabFramebuffer() Q_DECL_OVERRIDE; + GLuint textureId() const override; + QImage grabFramebuffer() override; #else QImage grabFramebuffer(); #endif |