aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp6
-rw-r--r--src/qml/qml/ftw/qqmlthread_p.h24
-rw-r--r--src/qml/qml/qqml.h1
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp17
-rw-r--r--src/qml/qml/qqmlapplicationengine.h6
-rw-r--r--src/qml/qml/qqmlbinding.cpp2
-rw-r--r--src/qml/qml/qqmlbinding_p.h4
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp2
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h4
-rw-r--r--src/qml/qml/qqmlcomponent.cpp8
-rw-r--r--src/qml/qml/qqmlcomponent_p.h4
-rw-r--r--src/qml/qml/qqmlcontext_p.h6
-rw-r--r--src/qml/qml/qqmlengine.cpp22
-rw-r--r--src/qml/qml/qqmlengine.h2
-rw-r--r--src/qml/qml/qqmlexpression.cpp2
-rw-r--r--src/qml/qml/qqmlexpression_p.h4
-rw-r--r--src/qml/qml/qqmlextensionplugin.h4
-rw-r--r--src/qml/qml/qqmlfileselector_p.h2
-rw-r--r--src/qml/qml/qqmlimport.cpp72
-rw-r--r--src/qml/qml/qqmlincubator.cpp2
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h2
-rw-r--r--src/qml/qml/qqmlloggingcategory.cpp4
-rw-r--r--src/qml/qml/qqmlmetatype.cpp46
-rw-r--r--src/qml/qml/qqmlmetatype_p.h5
-rw-r--r--src/qml/qml/qqmlnotifier_p.h12
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h6
-rw-r--r--src/qml/qml/qqmlopenmetaobject_p.h6
-rw-r--r--src/qml/qml/qqmlproperty.cpp9
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp32
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h14
-rw-r--r--src/qml/qml/qqmlproxymetaobject_p.h4
-rw-r--r--src/qml/qml/qqmltypeloader.cpp21
-rw-r--r--src/qml/qml/qqmltypeloader_p.h38
-rw-r--r--src/qml/qml/qqmltypenamecache.cpp8
-rw-r--r--src/qml/qml/qqmltypenamecache_p.h14
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h6
-rw-r--r--src/qml/qml/qqmlvaluetypeproxybinding.cpp2
-rw-r--r--src/qml/qml/qqmlvaluetypeproxybinding_p.h6
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp4
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp34
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h38
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp9
-rw-r--r--src/qml/qml/v8/qv8engine_p.h6
44 files changed, 298 insertions, 224 deletions
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
index 1523817c9e..ffa6e29290 100644
--- a/src/qml/qml/ftw/qqmlthread.cpp
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -55,7 +55,7 @@ public:
QQmlThreadPrivate(QQmlThread *);
QQmlThread *q;
- virtual void run();
+ void run() override;
inline void lock() { _mutex.lock(); }
inline void unlock() { _mutex.unlock(); }
@@ -81,12 +81,12 @@ public:
void threadEvent();
protected:
- virtual bool event(QEvent *);
+ bool event(QEvent *) override;
private:
struct MainObject : public QObject {
MainObject(QQmlThreadPrivate *p);
- virtual bool event(QEvent *e);
+ bool event(QEvent *e) override;
QQmlThreadPrivate *p;
};
MainObject m_mainObject;
diff --git a/src/qml/qml/ftw/qqmlthread_p.h b/src/qml/qml/ftw/qqmlthread_p.h
index 9f180b1f14..295235e255 100644
--- a/src/qml/qml/ftw/qqmlthread_p.h
+++ b/src/qml/qml/ftw/qqmlthread_p.h
@@ -142,7 +142,7 @@ void QQmlThread::callMethodInThread(void (O::*Member)())
struct I : public Message {
void (O::*Member)();
I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)();
}
@@ -157,7 +157,7 @@ void QQmlThread::callMethodInThread(void (O::*Member)(V), const T &arg)
void (O::*Member)(V);
T arg;
I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg);
}
@@ -173,7 +173,7 @@ void QQmlThread::callMethodInThread(void (O::*Member)(V, V2), const T &arg, cons
T arg;
T2 arg2;
I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg, arg2);
}
@@ -187,7 +187,7 @@ void QQmlThread::callMethodInMain(void (O::*Member)())
struct I : public Message {
void (O::*Member)();
I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)();
}
@@ -202,7 +202,7 @@ void QQmlThread::callMethodInMain(void (O::*Member)(V), const T &arg)
void (O::*Member)(V);
T arg;
I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg);
}
@@ -218,7 +218,7 @@ void QQmlThread::callMethodInMain(void (O::*Member)(V, V2), const T &arg, const
T arg;
T2 arg2;
I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg, arg2);
}
@@ -232,7 +232,7 @@ void QQmlThread::postMethodToThread(void (O::*Member)())
struct I : public Message {
void (O::*Member)();
I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)();
}
@@ -247,7 +247,7 @@ void QQmlThread::postMethodToThread(void (O::*Member)(V), const T &arg)
void (O::*Member)(V);
T arg;
I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg);
}
@@ -263,7 +263,7 @@ void QQmlThread::postMethodToThread(void (O::*Member)(V, V2), const T &arg, cons
T arg;
T2 arg2;
I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg, arg2);
}
@@ -277,7 +277,7 @@ void QQmlThread::postMethodToMain(void (O::*Member)())
struct I : public Message {
void (O::*Member)();
I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)();
}
@@ -292,7 +292,7 @@ void QQmlThread::postMethodToMain(void (O::*Member)(V), const T &arg)
void (O::*Member)(V);
T arg;
I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg);
}
@@ -308,7 +308,7 @@ void QQmlThread::postMethodToMain(void (O::*Member)(V, V2), const T &arg, const
T arg;
T2 arg2;
I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg, arg2);
}
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index 39764b8001..f0973338ea 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -526,6 +526,7 @@ QT_WARNING_POP
//The C++ version of protected namespaces in qmldir
Q_QML_EXPORT bool qmlProtectModule(const char* uri, int majVersion);
+Q_QML_EXPORT void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor);
template<typename T>
QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index 21a1a13687..8a97b7eba7 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -287,14 +287,27 @@ void QQmlApplicationEngine::loadData(const QByteArray &data, const QUrl &url)
Returns a list of all the root objects instantiated by the
QQmlApplicationEngine. This will only contain objects loaded via load() or a
convenience constructor.
+
+ \note In Qt versions prior to 5.9, this function is marked as non-\c{const}.
*/
-QList<QObject *> QQmlApplicationEngine::rootObjects()
+QList<QObject *> QQmlApplicationEngine::rootObjects() const
{
- Q_D(QQmlApplicationEngine);
+ Q_D(const QQmlApplicationEngine);
return d->objects;
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \overload
+ \internal
+*/
+QList<QObject *> QQmlApplicationEngine::rootObjects()
+{
+ return qAsConst(*this).rootObjects();
+}
+#endif // < Qt 6
+
QT_END_NAMESPACE
#include "moc_qqmlapplicationengine.cpp"
diff --git a/src/qml/qml/qqmlapplicationengine.h b/src/qml/qml/qqmlapplicationengine.h
index ff7dce5f8b..e64d7495cd 100644
--- a/src/qml/qml/qqmlapplicationengine.h
+++ b/src/qml/qml/qqmlapplicationengine.h
@@ -58,7 +58,11 @@ public:
QQmlApplicationEngine(const QString &filePath, QObject *parent = Q_NULLPTR);
~QQmlApplicationEngine();
- QList<QObject*> rootObjects();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ QList<QObject*> rootObjects(); // ### Qt 6: remove
+#endif
+ QList<QObject*> rootObjects() const;
+
public Q_SLOTS:
void load(const QUrl &url);
void load(const QString &filePath);
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index ab6cb60c7b..284ae1f36f 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -420,7 +420,7 @@ QVariant QQmlBinding::evaluate()
return scope.engine->toVariant(scope.result, qMetaTypeId<QList<QObject*> >());
}
-QString QQmlBinding::expressionIdentifier()
+QString QQmlBinding::expressionIdentifier() const
{
auto f = function();
QString url = f->sourceFile();
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index af95bbb5db..0f2fb329f5 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -97,8 +97,8 @@ public:
QVariant evaluate();
- QString expressionIdentifier() Q_DECL_OVERRIDE;
- void expressionChanged() Q_DECL_OVERRIDE;
+ QString expressionIdentifier() const override;
+ void expressionChanged() override;
protected:
virtual void doUpdate(const DeleteWatcher &watcher,
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index c4af82133a..254d5e1907 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -154,7 +154,7 @@ QQmlBoundSignalExpression::~QQmlBoundSignalExpression()
{
}
-QString QQmlBoundSignalExpression::expressionIdentifier()
+QString QQmlBoundSignalExpression::expressionIdentifier() const
{
QQmlSourceLocation loc = sourceLocation();
return loc.sourceFile + QLatin1Char(':') + QString::number(loc.line);
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index 173c0f7288..3a0b8aed59 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -79,8 +79,8 @@ public:
QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction);
// inherited from QQmlJavaScriptExpression.
- virtual QString expressionIdentifier();
- virtual void expressionChanged();
+ QString expressionIdentifier() const override;
+ void expressionChanged() override;
// evaluation of a bound signal expression doesn't return any value
void evaluate(void **a);
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 8be5172cd4..6ebcd142fb 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -376,7 +376,7 @@ QQmlComponent::~QQmlComponent()
if (isError()) {
qWarning() << "This may have been caused by one of the following errors:";
- foreach (const QQmlError &error, d->state.errors)
+ for (const QQmlError &error : qAsConst(d->state.errors))
qWarning().nospace().noquote() << QLatin1String(" ") << error;
}
@@ -709,7 +709,7 @@ QString QQmlComponent::errorString() const
QString ret;
if(!isError())
return ret;
- foreach(const QQmlError &e, d->state.errors) {
+ for (const QQmlError &e : d->state.errors) {
ret += e.url().toString() + QLatin1Char(':') +
QString::number(e.line()) + QLatin1Char(' ') +
e.description() + QLatin1Char('\n');
@@ -1098,13 +1098,13 @@ public:
, incubatorObject(inc)
{}
- virtual void statusChanged(Status s) {
+ void statusChanged(Status s) override {
QV4::Scope scope(incubatorObject->internalClass->engine);
QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject);
i->statusChanged(s);
}
- virtual void setInitialState(QObject *o) {
+ void setInitialState(QObject *o) override {
QV4::Scope scope(incubatorObject->internalClass->engine);
QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject);
i->setInitialState(o);
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
index 3a84e724da..d01a987acc 100644
--- a/src/qml/qml/qqmlcomponent_p.h
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -89,8 +89,8 @@ public:
static void setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v);
QQmlTypeData *typeData;
- virtual void typeDataReady(QQmlTypeData *);
- virtual void typeDataProgress(QQmlTypeData *, qreal);
+ void typeDataReady(QQmlTypeData *) override;
+ void typeDataProgress(QQmlTypeData *, qreal) override;
void fromTypeData(QQmlTypeData *data);
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h
index 62cd3d4877..4d2bb72352 100644
--- a/src/qml/qml/qqmlcontext_p.h
+++ b/src/qml/qml/qqmlcontext_p.h
@@ -197,7 +197,7 @@ public:
{
inline ContextGuard();
inline ContextGuard &operator=(QObject *obj);
- inline void objectDestroyed(QObject *);
+ inline void objectDestroyed(QObject *) override;
inline bool wasSet() const;
@@ -235,7 +235,7 @@ public:
inline QQmlGuardedContextData(QQmlContextData *);
inline ~QQmlGuardedContextData();
- inline QQmlContextData *contextData();
+ inline QQmlContextData *contextData() const;
inline void setContextData(QQmlContextData *);
inline bool isNull() const { return !m_contextData; }
@@ -285,7 +285,7 @@ void QQmlGuardedContextData::setContextData(QQmlContextData *contextData)
}
}
-QQmlContextData *QQmlGuardedContextData::contextData()
+QQmlContextData *QQmlGuardedContextData::contextData() const
{
return m_contextData;
}
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 2a439bde98..c2915c840b 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -537,6 +537,10 @@ The following functions are also on the Qt object.
\li This is the application name set on the QCoreApplication instance. This property can be written
to in order to set the application name.
\row
+ \li \c application.displayName (since Qt 5.9)
+ \li This is the application display name set on the QGuiApplication instance. This property can be written
+ to in order to set the application display name.
+ \row
\li \c application.version
\li This is the application version set on the QCoreApplication instance. This property can be written
to in order to set the application version.
@@ -554,6 +558,18 @@ The following functions are also on the Qt object.
\li This read-only property can be used to determine whether or not the
platform supports multiple windows. Some embedded platforms do not support
multiple windows, for example.
+
+ \row
+ \li \c application.screens
+ \li An array containing the descriptions of all connected screens. The
+ elements of the array are objects with the same properties as the
+ \l{Screen} attached object. In practice the array corresponds to the screen
+ list returned by QGuiApplication::screens(). In addition to examining
+ properties like name, width, height, etc., the array elements can also be
+ assigned to the targetScreen property of Window items, thus serving as an
+ alternative to the C++ side's QWindow::setScreen(). This property has been
+ added in Qt 5.9.
+
\endtable
The object also has one signal, aboutToQuit(), which is the same as \l QCoreApplication::aboutToQuit().
@@ -570,6 +586,8 @@ The following functions are also on the Qt object.
\li application.layoutDirection
\li application.font
\endlist
+
+ \sa Screen, Window, Window.targetScreen
*/
/*!
@@ -1006,8 +1024,8 @@ QQmlEngine::~QQmlEngine()
// we do this here and not in the private dtor since otherwise a crash can
// occur (if we are the QObject parent of the QObject singleton instance)
// XXX TODO: performance -- store list of singleton types separately?
- QList<QQmlType*> singletonTypes = QQmlMetaType::qmlSingletonTypes();
- foreach (QQmlType *currType, singletonTypes)
+ const QList<QQmlType*> singletonTypes = QQmlMetaType::qmlSingletonTypes();
+ for (QQmlType *currType : singletonTypes)
currType->singletonInstanceInfo()->destroy(this);
delete d->rootContext;
diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h
index 2c0c39d0b4..3102a20fac 100644
--- a/src/qml/qml/qqmlengine.h
+++ b/src/qml/qml/qqmlengine.h
@@ -151,7 +151,7 @@ public:
static ObjectOwnership objectOwnership(QObject *);
protected:
QQmlEngine(QQmlEnginePrivate &dd, QObject *p);
- virtual bool event(QEvent *);
+ bool event(QEvent *) override;
Q_SIGNALS:
void quit();
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index 94b1eaab52..1e1fbcf448 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -436,7 +436,7 @@ void QQmlExpressionPrivate::expressionChanged()
emit q->valueChanged();
}
-QString QQmlExpressionPrivate::expressionIdentifier()
+QString QQmlExpressionPrivate::expressionIdentifier() const
{
return QLatin1Char('"') + expression + QLatin1Char('"');
}
diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h
index 809a57b169..44342a957b 100644
--- a/src/qml/qml/qqmlexpression_p.h
+++ b/src/qml/qml/qqmlexpression_p.h
@@ -85,8 +85,8 @@ public:
bool expressionFunctionValid:1;
// Inherited from QQmlJavaScriptExpression
- virtual QString expressionIdentifier();
- virtual void expressionChanged();
+ QString expressionIdentifier() const override;
+ void expressionChanged() override;
QString expression;
diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h
index de482d0352..c0915c0abe 100644
--- a/src/qml/qml/qqmlextensionplugin.h
+++ b/src/qml/qml/qqmlextensionplugin.h
@@ -63,8 +63,8 @@ public:
QUrl baseUrl() const;
- virtual void registerTypes(const char *uri) = 0;
- virtual void initializeEngine(QQmlEngine *engine, const char *uri);
+ void registerTypes(const char *uri) override = 0;
+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
private:
Q_DISABLE_COPY(QQmlExtensionPlugin)
diff --git a/src/qml/qml/qqmlfileselector_p.h b/src/qml/qml/qqmlfileselector_p.h
index 57ef194c10..a7360f83d9 100644
--- a/src/qml/qml/qqmlfileselector_p.h
+++ b/src/qml/qml/qqmlfileselector_p.h
@@ -80,7 +80,7 @@ public:
QQmlFileSelectorInterceptor(QQmlFileSelectorPrivate* pd);
QQmlFileSelectorPrivate* d;
protected:
- virtual QUrl intercept(const QUrl &path, DataType type);
+ QUrl intercept(const QUrl &path, DataType type) override;
};
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index f2cbf5a94f..8712b638c5 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -57,6 +57,7 @@
#include <QtCore/qjsonarray.h>
#include <algorithm>
+#include <functional>
QT_BEGIN_NAMESPACE
@@ -229,7 +230,7 @@ public:
};
QList<Import *> imports;
- Import *findImport(const QString &uri);
+ Import *findImport(const QString &uri) const;
bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef& type,
int *vmajor, int *vminor, QQmlType** type_return,
@@ -453,7 +454,7 @@ QList<QQmlImports::ScriptReference> QQmlImports::resolvedScripts() const
for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
const QQmlImportNamespace::Import *import = set.imports.at(ii);
- foreach (const QQmlDirParser::Script &script, import->qmlDirScripts) {
+ for (const QQmlDirParser::Script &script : import->qmlDirScripts) {
ScriptReference ref;
ref.nameSpace = script.nameSpace;
ref.location = QUrl(import->url).resolved(QUrl(script.fileName));
@@ -467,7 +468,7 @@ QList<QQmlImports::ScriptReference> QQmlImports::resolvedScripts() const
for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
const QQmlImportNamespace::Import *import = set.imports.at(ii);
- foreach (const QQmlDirParser::Script &script, import->qmlDirScripts) {
+ for (const QQmlDirParser::Script &script : import->qmlDirScripts) {
ScriptReference ref;
ref.nameSpace = script.nameSpace;
ref.qualifier = set.prefix;
@@ -784,14 +785,13 @@ bool QQmlImportsPrivate::resolveType(const QHashedStringRef& type, int *vmajor,
return false;
}
-QQmlImportNamespace::Import *QQmlImportNamespace::findImport(const QString &uri)
+QQmlImportNamespace::Import *QQmlImportNamespace::findImport(const QString &uri) const
{
- for (QList<Import *>::iterator it = imports.begin(), end = imports.end(); it != end; ++it) {
- if ((*it)->uri == uri)
- return *it;
+ for (Import *import : imports) {
+ if (import->uri == uri)
+ return import;
}
-
- return 0;
+ return nullptr;
}
bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef &type,
@@ -898,6 +898,21 @@ static QStringList versionUriList(const QString &uri, int vmaj, int vmin)
}
#if QT_CONFIG(library)
+static QVector<QStaticPlugin> makePlugins()
+{
+ QVector<QStaticPlugin> plugins;
+ // To avoid traversing all static plugins for all imports, we cut down
+ // the list the first time called to only contain QML plugins:
+ const auto staticPlugins = QPluginLoader::staticPlugins();
+ for (const QStaticPlugin &plugin : staticPlugins) {
+ if (plugin.metaData().value(QLatin1String("IID")).toString()
+ == QLatin1String(QQmlExtensionInterface_iid)) {
+ plugins.append(plugin);
+ }
+ }
+ return plugins;
+}
+
/*!
Get all static plugins that are QML plugins and has a meta data URI that matches with one of
\a versionUris, which is a list of all possible versioned URI combinations - see versionUriList()
@@ -906,17 +921,8 @@ static QStringList versionUriList(const QString &uri, int vmaj, int vmin)
bool QQmlImportsPrivate::populatePluginPairVector(QVector<StaticPluginPair> &result, const QString &uri, const QStringList &versionUris,
const QString &qmldirPath, QList<QQmlError> *errors)
{
- static QVector<QStaticPlugin> plugins;
- if (plugins.isEmpty()) {
- // To avoid traversing all static plugins for all imports, we cut down
- // the list the first time called to only contain QML plugins:
- foreach (const QStaticPlugin &plugin, QPluginLoader::staticPlugins()) {
- if (plugin.metaData().value(QLatin1String("IID")).toString() == QLatin1String(QQmlExtensionInterface_iid))
- plugins.append(plugin);
- }
- }
-
- foreach (const QStaticPlugin &plugin, plugins) {
+ static const QVector<QStaticPlugin> plugins = makePlugins();
+ for (const QStaticPlugin &plugin : plugins) {
// Since a module can list more than one plugin, we keep iterating even after we found a match.
if (QQmlExtensionPlugin *instance = qobject_cast<QQmlExtensionPlugin *>(plugin.instance())) {
const QJsonArray metaTagsUriList = plugin.metaData().value(QLatin1String("uri")).toArray();
@@ -931,7 +937,7 @@ bool QQmlImportsPrivate::populatePluginPairVector(QVector<StaticPluginPair> &res
return false;
}
// A plugin can be set up to handle multiple URIs, so go through the list:
- foreach (const QJsonValue &metaTagUri, metaTagsUriList) {
+ for (const QJsonValue &metaTagUri : metaTagsUriList) {
if (versionUris.contains(metaTagUri.toString())) {
result.append(qMakePair(plugin, metaTagsUriList));
break;
@@ -998,7 +1004,8 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
int staticPluginsFound = 0;
#if defined(QT_SHARED)
- foreach (const QQmlDirParser::Plugin &plugin, qmldir->plugins()) {
+ const auto qmldirPlugins = qmldir->plugins();
+ for (const QQmlDirParser::Plugin &plugin : qmldirPlugins) {
QString resolvedFilePath = database->resolvePlugin(typeLoader, qmldirPath, plugin.path, plugin.name);
if (!resolvedFilePath.isEmpty()) {
dynamicPluginsFound++;
@@ -1032,8 +1039,8 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
const QString basePath = QFileInfo(qmldirPath).absoluteFilePath();
for (const QString &versionUri : versionUris) {
- foreach (const StaticPluginPair &pair, pluginPairs) {
- foreach (const QJsonValue &metaTagUri, pair.second) {
+ for (const StaticPluginPair &pair : qAsConst(pluginPairs)) {
+ for (const QJsonValue &metaTagUri : pair.second) {
if (versionUri == metaTagUri.toString()) {
staticPluginsFound++;
QObject *instance = pair.first.instance();
@@ -1117,20 +1124,16 @@ bool QQmlImportsPrivate::getQmldirContent(const QString &qmldirIdentifier, const
QString QQmlImportsPrivate::resolvedUri(const QString &dir_arg, QQmlImportDatabase *database)
{
- struct I { static bool greaterThan(const QString &s1, const QString &s2) {
- return s1 > s2;
- } };
-
QString dir = dir_arg;
if (dir.endsWith(Slash) || dir.endsWith(Backslash))
dir.chop(1);
QStringList paths = database->fileImportPath;
if (!paths.isEmpty())
- std::sort(paths.begin(), paths.end(), I::greaterThan); // Ensure subdirs preceed their parents.
+ std::sort(paths.begin(), paths.end(), std::greater<QString>()); // Ensure subdirs preceed their parents.
QString stableRelativePath = dir;
- foreach(const QString &path, paths) {
+ for (const QString &path : qAsConst(paths)) {
if (dir.startsWith(path)) {
stableRelativePath = dir.mid(path.length()+1);
break;
@@ -1671,8 +1674,7 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader,
if (!qmldirPluginPathIsRelative)
searchPaths.prepend(qmldirPluginPath);
- foreach (const QString &pluginPath, searchPaths) {
-
+ for (const QString &pluginPath : qAsConst(searchPaths)) {
QString resolvedPath;
if (pluginPath == QLatin1String(".")) {
if (qmldirPluginPathIsRelative && !qmldirPluginPath.isEmpty() && qmldirPluginPath != QLatin1String("."))
@@ -1694,7 +1696,7 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader,
resolvedPath += Slash;
resolvedPath += prefix + baseName;
- foreach (const QString &suffix, suffixes) {
+ for (const QString &suffix : suffixes) {
const QString absolutePath = typeLoader->absoluteFilePath(resolvedPath + suffix);
if (!absolutePath.isEmpty())
return absolutePath;
@@ -1836,7 +1838,7 @@ QStringList QQmlImportDatabase::importPathList(PathType type) const
return fileImportPath;
QStringList list;
- foreach (const QString &path, fileImportPath) {
+ for (const QString &path : fileImportPath) {
bool localPath = isPathAbsolute(path) || QQmlFile::isLocalFile(path);
if (localPath == (type == Local))
list.append(path);
@@ -1930,7 +1932,7 @@ bool QQmlImportDatabase::registerPluginTypes(QObject *instance, const QString &b
if (!registrationFailures.isEmpty()) {
if (errors) {
- foreach (const QString &failure, registrationFailures) {
+ for (const QString &failure : qAsConst(registrationFailures)) {
QQmlError error;
error.setDescription(failure);
errors->prepend(error);
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
index 0ce769aaea..963638ca34 100644
--- a/src/qml/qml/qqmlincubator.cpp
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -206,7 +206,7 @@ public:
}
protected:
- virtual void timerEvent(QTimerEvent *) {
+ void timerEvent(QTimerEvent *) override {
incubateFor(5);
}
};
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index 0724038382..646cc5ab3d 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -100,7 +100,7 @@ public:
QQmlJavaScriptExpression();
virtual ~QQmlJavaScriptExpression();
- virtual QString expressionIdentifier() = 0;
+ virtual QString expressionIdentifier() const = 0;
virtual void expressionChanged() = 0;
void evaluate(QV4::CallData *callData, bool *isUndefined, QV4::Scope &scope);
diff --git a/src/qml/qml/qqmlloggingcategory.cpp b/src/qml/qml/qqmlloggingcategory.cpp
index fd8fb477c7..70e59db07b 100644
--- a/src/qml/qml/qqmlloggingcategory.cpp
+++ b/src/qml/qml/qqmlloggingcategory.cpp
@@ -112,13 +112,13 @@ void QQmlLoggingCategory::componentComplete()
{
m_initialized = true;
if (m_name.isNull())
- qmlInfo(this) << QString(QLatin1String("Declaring the name of the LoggingCategory is mandatory and cannot be changed later !"));
+ qmlInfo(this) << QLatin1String("Declaring the name of the LoggingCategory is mandatory and cannot be changed later !");
}
void QQmlLoggingCategory::setName(const QString &name)
{
if (m_initialized) {
- qmlInfo(this) << QString(QLatin1String("The name of a LoggingCategory cannot be changed after the Item is created"));
+ qmlInfo(this) << QLatin1String("The name of a LoggingCategory cannot be changed after the Item is created");
return;
}
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 51964a7d11..520c44f4da 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1049,7 +1049,7 @@ void QQmlTypeModulePrivate::add(QQmlType *type)
list.append(type);
}
-QQmlType *QQmlTypeModule::type(const QHashedStringRef &name, int minor)
+QQmlType *QQmlTypeModule::type(const QHashedStringRef &name, int minor) const
{
QMutexLocker lock(metaTypeDataLock());
@@ -1063,7 +1063,7 @@ QQmlType *QQmlTypeModule::type(const QHashedStringRef &name, int minor)
return 0;
}
-QQmlType *QQmlTypeModule::type(const QV4::String *name, int minor)
+QQmlType *QQmlTypeModule::type(const QV4::String *name, int minor) const
{
QMutexLocker lock(metaTypeDataLock());
@@ -1268,6 +1268,19 @@ bool checkRegistration(QQmlType::RegistrationType typeType, QQmlMetaTypeData *da
}
// NOTE: caller must hold a QMutexLocker on "data"
+QQmlTypeModule *getTypeModule(const QHashedString &uri, int majorVersion, QQmlMetaTypeData *data)
+{
+ QQmlMetaTypeData::VersionedUri versionedUri(uri, majorVersion);
+ QQmlTypeModule *module = data->uriToModule.value(versionedUri);
+ if (!module) {
+ module = new QQmlTypeModule;
+ module->d->uri = versionedUri;
+ data->uriToModule.insert(versionedUri, module);
+ }
+ return module;
+}
+
+// NOTE: caller must hold a QMutexLocker on "data"
void addTypeToData(QQmlType* type, QQmlMetaTypeData *data)
{
if (!type->elementName().isEmpty())
@@ -1293,13 +1306,8 @@ void addTypeToData(QQmlType* type, QQmlMetaTypeData *data)
if (!type->module().isEmpty()) {
const QHashedString &mod = type->module();
- QQmlMetaTypeData::VersionedUri versionedUri(mod, type->majorVersion());
- QQmlTypeModule *module = data->uriToModule.value(versionedUri);
- if (!module) {
- module = new QQmlTypeModule;
- module->d->uri = versionedUri;
- data->uriToModule.insert(versionedUri, module);
- }
+ QQmlTypeModule *module = getTypeModule(mod, type->majorVersion(), data);
+ Q_ASSERT(module);
module->d->add(type);
}
}
@@ -1442,13 +1450,27 @@ bool qmlProtectModule(const char *uri, int majVersion)
return false;
}
-bool QQmlMetaType::namespaceContainsRegistrations(const QString &uri, int majorVersion)
+//From qqml.h
+void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
{
+ QMutexLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
+ QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), versionMajor, data);
+ Q_ASSERT(module);
+
+ QQmlTypeModulePrivate *p = QQmlTypeModulePrivate::get(module);
+ p->minMinorVersion = qMin(p->minMinorVersion, versionMinor);
+ p->maxMinorVersion = qMax(p->maxMinorVersion, versionMinor);
+}
+
+bool QQmlMetaType::namespaceContainsRegistrations(const QString &uri, int majorVersion)
+{
+ const QQmlMetaTypeData *data = metaTypeData();
+
// Has any type previously been installed to this namespace?
QHashedString nameSpace(uri);
- foreach (const QQmlType *type, data->types)
+ for (const QQmlType *type : data->types)
if (type->module() == nameSpace && type->majorVersion() == majorVersion)
return true;
@@ -1957,7 +1979,7 @@ QString QQmlMetaType::prettyTypeName(const QObject *object)
marker = typeName.indexOf(QLatin1String("_QML_"));
if (marker != -1) {
- typeName = typeName.left(marker) + QLatin1Char('*');
+ typeName = typeName.leftRef(marker) + QLatin1Char('*');
type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
if (type) {
typeName = type->qmlTypeName();
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 9afe4825dc..2b615e645a 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -259,13 +259,14 @@ public:
int minimumMinorVersion() const;
int maximumMinorVersion() const;
- QQmlType *type(const QHashedStringRef &, int);
- QQmlType *type(const QV4::String *, int);
+ QQmlType *type(const QHashedStringRef &, int) const;
+ QQmlType *type(const QV4::String *, int) const;
QList<QQmlType*> singletonTypes(int) const;
private:
//Used by register functions and creates the QQmlTypeModule for them
+ friend QQmlTypeModule *getTypeModule(const QHashedString &uri, int majorVersion, QQmlMetaTypeData *data);
friend void addTypeToData(QQmlType* type, QQmlMetaTypeData *data);
friend struct QQmlMetaTypeData;
friend Q_QML_EXPORT void qmlClearTypeRegistrations();
diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h
index 14024c0113..dad79e0e55 100644
--- a/src/qml/qml/qqmlnotifier_p.h
+++ b/src/qml/qml/qqmlnotifier_p.h
@@ -96,9 +96,9 @@ public:
inline QQmlNotifierEndpoint(Callback callback);
inline ~QQmlNotifierEndpoint();
- inline bool isConnected();
- inline bool isConnected(QObject *source, int sourceSignal);
- inline bool isConnected(QQmlNotifier *);
+ inline bool isConnected() const;
+ inline bool isConnected(QObject *source, int sourceSignal) const;
+ inline bool isConnected(QQmlNotifier *) const;
void connect(QObject *source, int sourceSignal, QQmlEngine *engine);
inline void connect(QQmlNotifier *);
@@ -164,7 +164,7 @@ QQmlNotifierEndpoint::~QQmlNotifierEndpoint()
disconnect();
}
-bool QQmlNotifierEndpoint::isConnected()
+bool QQmlNotifierEndpoint::isConnected() const
{
return prev != 0;
}
@@ -173,13 +173,13 @@ bool QQmlNotifierEndpoint::isConnected()
\a sourceSignal MUST be in the signal index range (see QObjectPrivate::signalIndex()).
This is different from QMetaMethod::methodIndex().
*/
-bool QQmlNotifierEndpoint::isConnected(QObject *source, int sourceSignal)
+bool QQmlNotifierEndpoint::isConnected(QObject *source, int sourceSignal) const
{
return this->sourceSignal != -1 && senderAsObject() == source &&
this->sourceSignal == sourceSignal;
}
-bool QQmlNotifierEndpoint::isConnected(QQmlNotifier *notifier)
+bool QQmlNotifierEndpoint::isConnected(QQmlNotifier *notifier) const
{
return sourceSignal == -1 && senderAsNotifier() == notifier;
}
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index e3312f9df5..caee7b9d1d 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -92,13 +92,13 @@ public:
QQmlContextData *finalize(QQmlInstantiationInterrupt &interrupt);
void clear();
- QQmlComponentAttached **componentAttachment() { return &sharedState->componentAttached; }
+ QQmlComponentAttached **componentAttachment() const { return &sharedState->componentAttached; }
- QList<QQmlEnginePrivate::FinalizeCallback> *finalizeCallbacks() { return &sharedState->finalizeCallbacks; }
+ QList<QQmlEnginePrivate::FinalizeCallback> *finalizeCallbacks() const { return &sharedState->finalizeCallbacks; }
QList<QQmlError> errors;
- QQmlContextData *parentContextData() { return parentContext.contextData(); }
+ QQmlContextData *parentContextData() const { return parentContext.contextData(); }
QFiniteStack<QPointer<QObject> > &allCreatedObjects() const { return sharedState->allCreatedObjects; }
private:
diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h
index f1562131fc..4bb92489a5 100644
--- a/src/qml/qml/qqmlopenmetaobject_p.h
+++ b/src/qml/qml/qqmlopenmetaobject_p.h
@@ -83,7 +83,7 @@ public:
protected:
virtual void propertyCreated(int, QMetaPropertyBuilder &);
- virtual void clear();
+ void clear() override;
private:
QQmlOpenMetaObjectTypePrivate *d;
@@ -122,8 +122,8 @@ public:
void emitPropertyNotification(const QByteArray &propertyName);
protected:
- virtual int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a);
- virtual int createProperty(const char *, const char *);
+ int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override;
+ int createProperty(const char *, const char *) override;
virtual void propertyRead(int);
virtual void propertyWrite(int);
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index c62fef7c3d..df336f0803 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -285,7 +285,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
QQmlPropertyData local;
QQmlPropertyData *property =
- QQmlPropertyCache::property(engine, currentObject, pathName.toString(), context, local);
+ QQmlPropertyCache::property(engine, currentObject, pathName, context, local);
if (!property) return; // Not a property
if (property->isFunction())
@@ -350,7 +350,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
// Try property
if (signalName.endsWith(QLatin1String("Changed"))) {
- QString propName = signalName.mid(0, signalName.length() - 7);
+ const QStringRef propName = signalName.midRef(0, signalName.length() - 7);
QQmlPropertyData *d = ddata->propertyCache->property(propName, currentObject, context);
while (d && d->isFunction())
d = ddata->propertyCache->overrideData(d);
@@ -374,14 +374,13 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
}
// Property
- const QString terminalString = terminal.toString();
QQmlPropertyData local;
QQmlPropertyData *property =
- QQmlPropertyCache::property(engine, currentObject, terminalString, context, local);
+ QQmlPropertyCache::property(engine, currentObject, terminal, context, local);
if (property && !property->isFunction()) {
object = currentObject;
core = *property;
- nameCache = terminalString;
+ nameCache = terminal.toString();
isNameCached = true;
}
}
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index a110dccee2..562aa1c88a 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -193,7 +193,7 @@ void QQmlPropertyData::load(const QMetaMethod &m)
if (m.parameterCount()) {
_flags.hasArguments = true;
- if ((m.parameterCount() == 1) && (m.parameterTypes().first() == "QQmlV4Function*")) {
+ if ((m.parameterCount() == 1) && (m.parameterTypes().constFirst() == "QQmlV4Function*")) {
_flags.isV4Function = true;
}
}
@@ -228,7 +228,7 @@ void QQmlPropertyData::lazyLoad(const QMetaMethod &m)
const int paramCount = m.parameterCount();
if (paramCount) {
_flags.hasArguments = true;
- if ((paramCount == 1) && (m.parameterTypes().first() == "QQmlV4Function*")) {
+ if ((paramCount == 1) && (m.parameterTypes().constFirst() == "QQmlV4Function*")) {
_flags.isV4Function = true;
}
}
@@ -269,8 +269,8 @@ QQmlPropertyCache::~QQmlPropertyCache()
QQmlPropertyCacheMethodArguments *args = argumentsCache;
while (args) {
QQmlPropertyCacheMethodArguments *next = args->next;
- if (args->signalParameterStringForJS) delete args->signalParameterStringForJS;
- if (args->names) delete args->names;
+ delete args->signalParameterStringForJS;
+ delete args->names;
free(args);
args = next;
}
@@ -978,7 +978,8 @@ int QQmlPropertyCache::originalClone(QObject *object, int index)
return index;
}
-QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QString &property)
+template<typename T>
+static QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const T& propertyName)
{
Q_ASSERT(metaObject);
@@ -995,8 +996,6 @@ QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QS
// These indices don't apply to gadgets, so don't block them.
const bool preventDestruction = metaObject->superClass() || metaObject == &QObject::staticMetaObject;
- const QByteArray propertyName = property.toUtf8();
-
int methodCount = metaObject->methodCount();
for (int ii = methodCount - 1; ii >= 0; --ii) {
if (preventDestruction && (ii == destroyedIdx1 || ii == destroyedIdx2 || ii == deleteLaterIdx))
@@ -1038,14 +1037,19 @@ QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QS
return rv;
}
-inline const QString &qQmlPropertyCacheToString(const QString &string)
+static inline const char *qQmlPropertyCacheToString(QLatin1String string)
+{
+ return string.data();
+}
+
+static inline QByteArray qQmlPropertyCacheToString(const QStringRef &string)
{
- return string;
+ return string.toUtf8();
}
-inline QString qQmlPropertyCacheToString(const QV4::String *string)
+static inline QByteArray qQmlPropertyCacheToString(const QV4::String *string)
{
- return string->toQString();
+ return string->toQString().toUtf8();
}
template<typename T>
@@ -1090,10 +1094,10 @@ QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QV4::String *
}
QQmlPropertyData *
-QQmlPropertyCache::property(QJSEngine *engine, QObject *obj,
- const QString &name, QQmlContextData *context, QQmlPropertyData &local)
+QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QStringRef &name,
+ QQmlContextData *context, QQmlPropertyData &local)
{
- return qQmlPropertyCacheProperty<const QString &>(engine, obj, name, context, local);
+ return qQmlPropertyCacheProperty<const QStringRef &>(engine, obj, name, context, local);
}
QQmlPropertyData *
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 60414188a5..64be1cb206 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -406,13 +406,19 @@ public:
inline QQmlPropertyData *overrideData(QQmlPropertyData *) const;
inline bool isAllowedInRevision(QQmlPropertyData *) const;
- static QQmlPropertyData *property(QJSEngine *, QObject *, const QString &,
+ static QQmlPropertyData *property(QJSEngine *, QObject *, const QStringRef &,
QQmlContextData *, QQmlPropertyData &);
static QQmlPropertyData *property(QJSEngine *, QObject *, const QLatin1String &,
QQmlContextData *, QQmlPropertyData &);
static QQmlPropertyData *property(QJSEngine *, QObject *, const QV4::String *,
QQmlContextData *, QQmlPropertyData &);
+ static QQmlPropertyData *property(QJSEngine *engine, QObject *obj, const QString &name,
+ QQmlContextData *context, QQmlPropertyData &local)
+ {
+ return property(engine, obj, QStringRef(&name), context, local);
+ }
+
//see QMetaObjectPrivate::originalClone
int originalClone(int index);
static int originalClone(QObject *, int index);
@@ -441,8 +447,8 @@ public:
QByteArray checksum(bool *ok);
protected:
- virtual void destroy();
- virtual void clear();
+ void destroy() override;
+ void clear() override;
private:
friend class QQmlEnginePrivate;
@@ -474,7 +480,7 @@ private:
void updateRecur(const QMetaObject *);
template<typename K>
- QQmlPropertyData *findNamedProperty(const K &key)
+ QQmlPropertyData *findNamedProperty(const K &key) const
{
StringCache::mapped_type *it = stringCache.value(key);
return it ? it->second : 0;
diff --git a/src/qml/qml/qqmlproxymetaobject_p.h b/src/qml/qml/qqmlproxymetaobject_p.h
index 7083f88fa7..2b7a980361 100644
--- a/src/qml/qml/qqmlproxymetaobject_p.h
+++ b/src/qml/qml/qqmlproxymetaobject_p.h
@@ -74,10 +74,10 @@ public:
};
QQmlProxyMetaObject(QObject *, QList<ProxyData> *);
- virtual ~QQmlProxyMetaObject();
+ ~QQmlProxyMetaObject();
protected:
- virtual int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a);
+ int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override;
private:
QList<ProxyData> *metaObjects;
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 7ad18c8efb..76ac15e2f1 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -165,7 +165,7 @@ public:
void initializeEngine(QQmlExtensionInterface *, const char *);
protected:
- virtual void shutdownThread();
+ void shutdownThread() override;
private:
void loadThread(QQmlDataBlob *b);
@@ -1363,7 +1363,8 @@ bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QV4::Compile
// Does this library contain any qualified scripts?
QUrl libraryUrl(qmldirUrl);
const QmldirContent *qmldir = typeLoader()->qmldirContent(qmldirIdentifier);
- foreach (const QQmlDirParser::Script &script, qmldir->scripts()) {
+ const auto qmldirScripts = qmldir->scripts();
+ for (const QQmlDirParser::Script &script : qmldirScripts) {
QUrl scriptUrl = libraryUrl.resolved(QUrl(script.fileName));
QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
addDependency(blob);
@@ -1410,7 +1411,8 @@ bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QL
// Does this library contain any qualified scripts?
QUrl libraryUrl(qmldirUrl);
const QmldirContent *qmldir = typeLoader()->qmldirContent(qmldirFilePath);
- foreach (const QQmlDirParser::Script &script, qmldir->scripts()) {
+ const auto qmldirScripts = qmldir->scripts();
+ for (const QQmlDirParser::Script &script : qmldirScripts) {
QUrl scriptUrl = libraryUrl.resolved(QUrl(script.fileName));
QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
addDependency(blob);
@@ -1615,7 +1617,7 @@ QQmlTypeLoader::~QQmlTypeLoader()
invalidate();
}
-QQmlImportDatabase *QQmlTypeLoader::importDatabase()
+QQmlImportDatabase *QQmlTypeLoader::importDatabase() const
{
return &QQmlEnginePrivate::get(engine())->importDatabase;
}
@@ -2381,7 +2383,7 @@ bool QQmlTypeData::loadFromSource()
if (!compiler.generateFromQml(code, finalUrlString(), m_document.data())) {
QList<QQmlError> errors;
errors.reserve(compiler.errors.count());
- foreach (const QQmlJS::DiagnosticMessage &msg, compiler.errors) {
+ for (const QQmlJS::DiagnosticMessage &msg : qAsConst(compiler.errors)) {
QQmlError e;
e.setUrl(finalUrl());
e.setLine(msg.loc.startLine);
@@ -2516,8 +2518,8 @@ void QQmlTypeData::compile(const QQmlRefPointer<QQmlTypeNameCache> &importCache,
void QQmlTypeData::resolveTypes()
{
// Add any imported scripts to our resolved set
- foreach (const QQmlImports::ScriptReference &script, m_importCache.resolvedScripts())
- {
+ const auto resolvedScripts = m_importCache.resolvedScripts();
+ for (const QQmlImports::ScriptReference &script : resolvedScripts) {
QQmlScriptBlob *blob = typeLoader()->getScript(script.location);
addDependency(blob);
@@ -2537,7 +2539,8 @@ void QQmlTypeData::resolveTypes()
}
// Lets handle resolved composite singleton types
- foreach (const QQmlImports::CompositeSingletonReference &csRef, m_importCache.resolvedCompositeSingletons()) {
+ const auto resolvedCompositeSingletons = m_importCache.resolvedCompositeSingletons();
+ for (const QQmlImports::CompositeSingletonReference &csRef : resolvedCompositeSingletons) {
TypeReference ref;
QString typeName;
if (!csRef.prefix.isEmpty()) {
@@ -2887,7 +2890,7 @@ QQmlScriptData *QQmlScriptBlob::scriptData() const
struct EmptyCompilationUnit : public QV4::CompiledData::CompilationUnit
{
- virtual void linkBackendToEngine(QV4::ExecutionEngine *) {}
+ void linkBackendToEngine(QV4::ExecutionEngine *) override {}
};
void QQmlScriptBlob::dataReceived(const Data &data)
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index 53cf4234e1..b1d6451974 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -243,8 +243,8 @@ public:
virtual void scriptImported(QQmlScriptBlob *, const QV4::CompiledData::Location &, const QString &, const QString &) {}
- virtual void dependencyError(QQmlDataBlob *);
- virtual void dependencyComplete(QQmlDataBlob *);
+ void dependencyError(QQmlDataBlob *) override;
+ void dependencyComplete(QQmlDataBlob *) override;
protected:
virtual QString stringAt(int) const { return QString(); }
@@ -287,7 +287,7 @@ public:
QQmlTypeLoader(QQmlEngine *);
~QQmlTypeLoader();
- QQmlImportDatabase *importDatabase();
+ QQmlImportDatabase *importDatabase() const;
QQmlTypeData *getType(const QUrl &url, Mode mode = PreferSynchronous);
QQmlTypeData *getType(const QByteArray &, const QUrl &url, Mode mode = PreferSynchronous);
@@ -434,14 +434,14 @@ public:
void unregisterCallback(TypeDataCallback *);
protected:
- virtual void done();
- virtual void completed();
- virtual void dataReceived(const Data &);
- virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit);
- virtual void allDependenciesDone();
- virtual void downloadProgressChanged(qreal);
+ void done() override;
+ void completed() override;
+ void dataReceived(const Data &) override;
+ void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override;
+ void allDependenciesDone() override;
+ void downloadProgressChanged(qreal) override;
- virtual QString stringAt(int index) const;
+ QString stringAt(int index) const override;
private:
bool tryLoadFromDiskCache();
@@ -458,7 +458,7 @@ private:
const QV4::CompiledData::ResolvedTypeReferenceMap &resolvedTypeCache);
bool resolveType(const QString &typeName, int &majorVersion, int &minorVersion, TypeReference &ref);
- virtual void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace);
+ void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override;
qint64 m_sourceTimeStamp = 0;
@@ -510,7 +510,7 @@ public:
QV4::ReturnedValue scriptValueForContext(QQmlContextData *parentCtxt);
protected:
- virtual void clear(); // From QQmlCleanup
+ void clear() override; // From QQmlCleanup
private:
friend class QQmlScriptBlob;
@@ -546,14 +546,14 @@ public:
QQmlScriptData *scriptData() const;
protected:
- virtual void dataReceived(const Data &);
- virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit);
- virtual void done();
+ void dataReceived(const Data &) override;
+ void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override;
+ void done() override;
- virtual QString stringAt(int index) const;
+ QString stringAt(int index) const override;
private:
- virtual void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace);
+ void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override;
void initializeFromCompilationUnit(QV4::CompiledData::CompilationUnit *unit);
QList<ScriptReference> m_scripts;
@@ -577,8 +577,8 @@ public:
void setPriority(int);
protected:
- virtual void dataReceived(const Data &);
- virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*);
+ void dataReceived(const Data &) override;
+ void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) override;
private:
QString m_content;
diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp
index 34e1fc87f2..c2098bc9a1 100644
--- a/src/qml/qml/qqmltypenamecache.cpp
+++ b/src/qml/qml/qqmltypenamecache.cpp
@@ -84,7 +84,7 @@ void QQmlTypeNameCache::add(const QHashedString &name, int importedScriptIndex,
m_namedImports.insert(name, import);
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name)
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name) const
{
Result result = query(m_namedImports, name);
@@ -98,7 +98,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name)
}
QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
- const void *importNamespace)
+ const void *importNamespace) const
{
Q_ASSERT(importNamespace);
const Import *i = static_cast<const Import *>(importNamespace);
@@ -112,7 +112,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
return result;
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name)
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name) const
{
Result result = query(m_namedImports, name);
@@ -125,7 +125,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name)
return result;
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, const void *importNamespace)
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, const void *importNamespace) const
{
Q_ASSERT(importNamespace);
const Import *i = static_cast<const Import *>(importNamespace);
diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h
index 7591075102..8a387bed5f 100644
--- a/src/qml/qml/qqmltypenamecache_p.h
+++ b/src/qml/qml/qqmltypenamecache_p.h
@@ -87,10 +87,10 @@ public:
const void *importNamespace;
int scriptIndex;
};
- Result query(const QHashedStringRef &);
- Result query(const QHashedStringRef &, const void *importNamespace);
- Result query(const QV4::String *);
- Result query(const QV4::String *, const void *importNamespace);
+ Result query(const QHashedStringRef &) const;
+ Result query(const QHashedStringRef &, const void *importNamespace) const;
+ Result query(const QV4::String *) const;
+ Result query(const QV4::String *, const void *importNamespace) const;
private:
friend class QQmlImports;
@@ -108,7 +108,7 @@ private:
};
template<typename Key>
- Result query(const QStringHash<Import> &imports, Key key)
+ Result query(const QStringHash<Import> &imports, Key key) const
{
Import *i = imports.value(key);
if (i) {
@@ -123,7 +123,7 @@ private:
}
template<typename Key>
- Result query(const QStringHash<QUrl> &urls, Key key)
+ Result query(const QStringHash<QUrl> &urls, Key key) const
{
QUrl *url = urls.value(key);
if (url) {
@@ -136,7 +136,7 @@ private:
}
template<typename Key>
- Result typeSearch(const QVector<QQmlTypeModuleVersion> &modules, Key key)
+ Result typeSearch(const QVector<QQmlTypeModuleVersion> &modules, Key key) const
{
QVector<QQmlTypeModuleVersion>::const_iterator end = modules.constEnd();
for (QVector<QQmlTypeModuleVersion>::const_iterator it = modules.constBegin(); it != end; ++it) {
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index 11e1dfdb00..0502a5d665 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -74,9 +74,9 @@ public:
void setValue(const QVariant &);
// ---- dynamic meta object data interface
- virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *);
- virtual void objectDestroyed(QObject *);
- virtual int metaCall(QObject *obj, QMetaObject::Call type, int _id, void **argv);
+ QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) override;
+ void objectDestroyed(QObject *) override;
+ int metaCall(QObject *obj, QMetaObject::Call type, int _id, void **argv) override;
// ----
private:
diff --git a/src/qml/qml/qqmlvaluetypeproxybinding.cpp b/src/qml/qml/qqmlvaluetypeproxybinding.cpp
index 56f073121e..4e2e7b06c7 100644
--- a/src/qml/qml/qqmlvaluetypeproxybinding.cpp
+++ b/src/qml/qml/qqmlvaluetypeproxybinding.cpp
@@ -72,7 +72,7 @@ bool QQmlValueTypeProxyBinding::isValueTypeProxy() const
return true;
}
-QQmlAbstractBinding *QQmlValueTypeProxyBinding::binding(QQmlPropertyIndex propertyIndex)
+QQmlAbstractBinding *QQmlValueTypeProxyBinding::binding(QQmlPropertyIndex propertyIndex) const
{
QQmlAbstractBinding *binding = m_bindings.data();
diff --git a/src/qml/qml/qqmlvaluetypeproxybinding_p.h b/src/qml/qml/qqmlvaluetypeproxybinding_p.h
index 9a487d6992..92b5470f39 100644
--- a/src/qml/qml/qqmlvaluetypeproxybinding_p.h
+++ b/src/qml/qml/qqmlvaluetypeproxybinding_p.h
@@ -60,11 +60,11 @@ class QQmlValueTypeProxyBinding : public QQmlAbstractBinding
public:
QQmlValueTypeProxyBinding(QObject *o, QQmlPropertyIndex coreIndex);
- QQmlAbstractBinding *binding(QQmlPropertyIndex targetPropertyIndex);
+ QQmlAbstractBinding *binding(QQmlPropertyIndex targetPropertyIndex) const;
void removeBindings(quint32 mask);
- virtual void setEnabled(bool, QQmlPropertyData::WriteFlags);
- virtual bool isValueTypeProxy() const;
+ void setEnabled(bool, QQmlPropertyData::WriteFlags) override;
+ bool isValueTypeProxy() const override;
protected:
~QQmlValueTypeProxyBinding();
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index bbef62186a..6ce52bb9e5 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -274,9 +274,9 @@ void QQmlValueTypeWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value
QV4::Object::advanceIterator(m, it, name, index, p, attributes);
}
-bool QQmlValueTypeWrapper::isEqual(const QVariant& value)
+bool QQmlValueTypeWrapper::isEqual(const QVariant& value) const
{
- if (QQmlValueTypeReference *ref = as<QQmlValueTypeReference>())
+ if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>())
if (!ref->readReferenceValue())
return false;
return (value == d()->toVariant());
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index b8ca5a16f4..fec54df770 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -101,7 +101,7 @@ public:
QVariant toVariant() const;
bool toGadget(void *data) const;
- bool isEqual(const QVariant& value);
+ bool isEqual(const QVariant& value) const;
int typeId() const;
bool write(QObject *target, int propertyIndex) const;
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index d2cbb99b6a..545daa96f8 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -343,7 +343,7 @@ QQmlVMEMetaObject::~QQmlVMEMetaObject()
qDeleteAll(varObjectGuards);
}
-QV4::MemberData *QQmlVMEMetaObject::propertyAndMethodStorageAsMemberData()
+QV4::MemberData *QQmlVMEMetaObject::propertyAndMethodStorageAsMemberData() const
{
if (propertyAndMethodStorage.isUndefined()) {
if (propertyAndMethodStorage.valueRef())
@@ -442,7 +442,7 @@ void QQmlVMEMetaObject::writeProperty(int id, QObject* v)
guard->setGuardedValue(v, this, id);
}
-int QQmlVMEMetaObject::readPropertyAsInt(int id)
+int QQmlVMEMetaObject::readPropertyAsInt(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -455,7 +455,7 @@ int QQmlVMEMetaObject::readPropertyAsInt(int id)
return sv->integerValue();
}
-bool QQmlVMEMetaObject::readPropertyAsBool(int id)
+bool QQmlVMEMetaObject::readPropertyAsBool(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -468,7 +468,7 @@ bool QQmlVMEMetaObject::readPropertyAsBool(int id)
return sv->booleanValue();
}
-double QQmlVMEMetaObject::readPropertyAsDouble(int id)
+double QQmlVMEMetaObject::readPropertyAsDouble(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -481,7 +481,7 @@ double QQmlVMEMetaObject::readPropertyAsDouble(int id)
return sv->doubleValue();
}
-QString QQmlVMEMetaObject::readPropertyAsString(int id)
+QString QQmlVMEMetaObject::readPropertyAsString(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -494,7 +494,7 @@ QString QQmlVMEMetaObject::readPropertyAsString(int id)
return QString();
}
-QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id)
+QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -508,7 +508,7 @@ QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id)
return v->d()->data().value<QUrl>();
}
-QDate QQmlVMEMetaObject::readPropertyAsDate(int id)
+QDate QQmlVMEMetaObject::readPropertyAsDate(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -536,7 +536,7 @@ QDateTime QQmlVMEMetaObject::readPropertyAsDateTime(int id)
return v->d()->data().value<QDateTime>();
}
-QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id)
+QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -550,7 +550,7 @@ QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id)
return v->d()->data().value<QSizeF>();
}
-QPointF QQmlVMEMetaObject::readPropertyAsPointF(int id)
+QPointF QQmlVMEMetaObject::readPropertyAsPointF(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -564,7 +564,7 @@ QPointF QQmlVMEMetaObject::readPropertyAsPointF(int id)
return v->d()->data().value<QPointF>();
}
-QObject* QQmlVMEMetaObject::readPropertyAsQObject(int id)
+QObject* QQmlVMEMetaObject::readPropertyAsQObject(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -578,7 +578,7 @@ QObject* QQmlVMEMetaObject::readPropertyAsQObject(int id)
return wrapper->object();
}
-QList<QObject *> *QQmlVMEMetaObject::readPropertyAsList(int id)
+QList<QObject *> *QQmlVMEMetaObject::readPropertyAsList(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -594,7 +594,7 @@ QList<QObject *> *QQmlVMEMetaObject::readPropertyAsList(int id)
return static_cast<QList<QObject *> *>(v->d()->data().data());
}
-QRectF QQmlVMEMetaObject::readPropertyAsRectF(int id)
+QRectF QQmlVMEMetaObject::readPropertyAsRectF(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -976,7 +976,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
#pragma optimize("", on)
#endif
-QV4::ReturnedValue QQmlVMEMetaObject::method(int index)
+QV4::ReturnedValue QQmlVMEMetaObject::method(int index) const
{
if (!ctxt || !ctxt->isValid() || !compiledObject) {
qWarning("QQmlVMEMetaObject: Internal error - attempted to evaluate a function in an invalid context");
@@ -990,7 +990,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::method(int index)
return (md->data() + index + compiledObject->nProperties)->asReturnedValue();
}
-QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id)
+QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id) const
{
Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].type == QV4::CompiledData::Property::Var);
@@ -1000,7 +1000,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id)
return QV4::Primitive::undefinedValue().asReturnedValue();
}
-QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id)
+QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (md) {
@@ -1107,7 +1107,7 @@ void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value)
}
}
-QV4::ReturnedValue QQmlVMEMetaObject::vmeMethod(int index)
+QV4::ReturnedValue QQmlVMEMetaObject::vmeMethod(int index) const
{
if (index < methodOffset()) {
Q_ASSERT(parentVMEMetaObject());
@@ -1139,7 +1139,7 @@ void QQmlVMEMetaObject::setVmeMethod(int index, const QV4::Value &function)
*(md->data() + methodIndex + compiledObject->nProperties) = function;
}
-QV4::ReturnedValue QQmlVMEMetaObject::vmeProperty(int index)
+QV4::ReturnedValue QQmlVMEMetaObject::vmeProperty(int index) const
{
if (index < propOffset()) {
Q_ASSERT(parentVMEMetaObject());
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index 031bfdfb9b..bb6fede7c8 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -83,7 +83,7 @@ public:
inline QQmlVMEVariantQObjectPtr();
inline ~QQmlVMEVariantQObjectPtr();
- inline void objectDestroyed(QObject *);
+ inline void objectDestroyed(QObject *) override;
inline void setGuardedValue(QObject *obj, QQmlVMEMetaObject *target, int index);
QQmlVMEMetaObject *m_target;
@@ -148,9 +148,9 @@ public:
~QQmlVMEMetaObject();
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const;
- QV4::ReturnedValue vmeMethod(int index);
+ QV4::ReturnedValue vmeMethod(int index) const;
void setVmeMethod(int index, const QV4::Value &function);
- QV4::ReturnedValue vmeProperty(int index);
+ QV4::ReturnedValue vmeProperty(int index) const;
void setVMEProperty(int index, const QV4::Value &v);
void connectAliasSignal(int index, bool indexInSignalRange);
@@ -174,20 +174,20 @@ public:
QQmlVMEMetaObjectEndpoint *aliasEndpoints;
QV4::WeakValue propertyAndMethodStorage;
- QV4::MemberData *propertyAndMethodStorageAsMemberData();
-
- int readPropertyAsInt(int id);
- bool readPropertyAsBool(int id);
- double readPropertyAsDouble(int id);
- QString readPropertyAsString(int id);
- QSizeF readPropertyAsSizeF(int id);
- QPointF readPropertyAsPointF(int id);
- QUrl readPropertyAsUrl(int id);
- QDate readPropertyAsDate(int id);
+ QV4::MemberData *propertyAndMethodStorageAsMemberData() const;
+
+ int readPropertyAsInt(int id) const;
+ bool readPropertyAsBool(int id) const;
+ double readPropertyAsDouble(int id) const;
+ QString readPropertyAsString(int id) const;
+ QSizeF readPropertyAsSizeF(int id) const;
+ QPointF readPropertyAsPointF(int id) const;
+ QUrl readPropertyAsUrl(int id) const;
+ QDate readPropertyAsDate(int id) const;
QDateTime readPropertyAsDateTime(int id);
- QRectF readPropertyAsRectF(int id);
- QObject *readPropertyAsQObject(int id);
- QList<QObject *> *readPropertyAsList(int id);
+ QRectF readPropertyAsRectF(int id) const;
+ QObject *readPropertyAsQObject(int id) const;
+ QList<QObject *> *readPropertyAsList(int id) const;
void writeProperty(int id, int v);
void writeProperty(int id, bool v);
@@ -207,11 +207,11 @@ public:
void connectAlias(int aliasId);
- QV4::ReturnedValue method(int);
+ QV4::ReturnedValue method(int) const;
- QV4::ReturnedValue readVarProperty(int);
+ QV4::ReturnedValue readVarProperty(int) const;
void writeVarProperty(int, const QV4::Value &);
- QVariant readPropertyAsVariant(int);
+ QVariant readPropertyAsVariant(int) const;
void writeProperty(int, const QVariant &);
inline QQmlVMEMetaObject *parentVMEMetaObject() const;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 47751aa2c6..22c3c49c58 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -830,7 +830,8 @@ ReturnedValue Document::load(ExecutionEngine *v4, const QByteArray &data)
}
nodeStack.append(node);
- foreach (const QXmlStreamAttribute &a, reader.attributes()) {
+ const auto attributes = reader.attributes();
+ for (const QXmlStreamAttribute &a : attributes) {
NodeImpl *attr = new NodeImpl;
attr->document = document;
attr->type = NodeImpl::Attr;
@@ -1184,10 +1185,10 @@ QString QQmlXMLHttpRequest::headers() const
void QQmlXMLHttpRequest::fillHeadersList()
{
- QList<QByteArray> headerList = m_network->rawHeaderList();
+ const QList<QByteArray> headerList = m_network->rawHeaderList();
m_headersList.clear();
- foreach (const QByteArray &header, headerList) {
+ for (const QByteArray &header : headerList) {
HeaderPair pair (header.toLower(), m_network->rawHeader(header));
if (pair.first == "set-cookie" ||
pair.first == "set-cookie2")
@@ -1445,7 +1446,7 @@ void QQmlXMLHttpRequest::finished()
void QQmlXMLHttpRequest::readEncoding()
{
- foreach (const HeaderPair &header, m_headersList) {
+ for (const HeaderPair &header : qAsConst(m_headersList)) {
if (header.first == "content-type") {
int separatorIdx = header.second.indexOf(';');
if (separatorIdx == -1) {
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 0cbe34fd30..3bd3517968 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -117,7 +117,7 @@ class QQmlV4Function
{
public:
int length() const { return callData->argc; }
- QV4::ReturnedValue operator[](int idx) { return (idx < callData->argc ? callData->args[idx].asReturnedValue() : QV4::Encode::undefined()); }
+ QV4::ReturnedValue operator[](int idx) const { return (idx < callData->argc ? callData->args[idx].asReturnedValue() : QV4::Encode::undefined()); }
void setReturnValue(QV4::ReturnedValue rv) { *retVal = rv; }
QV4::ExecutionEngine *v4engine() const { return e; }
private:
@@ -181,9 +181,9 @@ public:
QV4::ReturnedValue global();
QQmlDelayedCallQueue *delayedCallQueue() { return &m_delayedCallQueue; }
- void *xmlHttpRequestData() { return m_xmlHttpRequestData; }
+ void *xmlHttpRequestData() const { return m_xmlHttpRequestData; }
- Deletable *listModelData() { return m_listModelData; }
+ Deletable *listModelData() const { return m_listModelData; }
void setListModelData(Deletable *d) { if (m_listModelData) delete m_listModelData; m_listModelData = d; }
void freezeObject(const QV4::Value &value);