summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-02-26 13:54:24 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-28 13:50:45 +0000
commit4371cb583457e5dbcdd93183ff82886dfefdfce6 (patch)
tree884ac5ab8ceeac822db5c203d82e0b9a47473982
parente966a340d09a9ffdc9876001a35201f38663ace7 (diff)
QML engine internals: Do not require mutable QObject pointer
All we need is to get the meta-object from the object. This also works with a const pointer, which is helpful for const-correctness in the FSM framework. Change-Id: Ie554fe81e67bced5f74c844c72e7f9b0df7ded58 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit d0db469788039cf73406ba3f489b7a00b0601f01) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp6
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h8
-rw-r--r--src/qml/qml/qqmlmetaobject_p.h4
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp2
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h2
5 files changed, 10 insertions, 12 deletions
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 8fceb94f45..3626d8f9c0 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -64,8 +64,7 @@
QT_BEGIN_NAMESPACE
-QQmlBoundSignalExpression::QQmlBoundSignalExpression(
- QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope,
+QQmlBoundSignalExpression::QQmlBoundSignalExpression(const QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope,
const QString &expression, const QString &fileName, quint16 line, quint16 column,
const QString &handlerName, const QString &parameterString)
: QQmlJavaScriptExpression(),
@@ -104,8 +103,7 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(
setupFunction(context, f->function());
}
-QQmlBoundSignalExpression::QQmlBoundSignalExpression(
- QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt,
+QQmlBoundSignalExpression::QQmlBoundSignalExpression(const QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt,
QObject *scopeObject, QV4::Function *function, QV4::ExecutionContext *scope)
: QQmlJavaScriptExpression(),
m_index(index),
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index d034d874df..881c65db26 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -66,12 +66,12 @@ class Q_QML_PRIVATE_EXPORT QQmlBoundSignalExpression : public QQmlJavaScriptExpr
{
public:
QQmlBoundSignalExpression(
- QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope,
+ const QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope,
const QString &expression, const QString &fileName, quint16 line, quint16 column,
const QString &handlerName = QString(), const QString &parameterString = QString());
QQmlBoundSignalExpression(
- QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt,
+ const QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt,
QObject *scopeObject, QV4::Function *function, QV4::ExecutionContext *scope = nullptr);
// inherited from QQmlJavaScriptExpression.
@@ -83,7 +83,7 @@ public:
void evaluate(const QList<QVariant> &args);
QString expression() const;
- QObject *target() const { return m_target; }
+ const QObject *target() const { return m_target; }
private:
~QQmlBoundSignalExpression() override;
@@ -93,7 +93,7 @@ private:
bool expressionFunctionValid() const { return function() != nullptr; }
int m_index;
- QObject *m_target;
+ const QObject *m_target;
};
class Q_QML_PRIVATE_EXPORT QQmlBoundSignal : public QQmlNotifierEndpoint
diff --git a/src/qml/qml/qqmlmetaobject_p.h b/src/qml/qml/qqmlmetaobject_p.h
index 9465458780..a5b9b758a8 100644
--- a/src/qml/qml/qqmlmetaobject_p.h
+++ b/src/qml/qml/qqmlmetaobject_p.h
@@ -75,7 +75,7 @@ public:
typedef QVarLengthArray<int, 9> ArgTypeStorage;
inline QQmlMetaObject() = default;
- inline QQmlMetaObject(QObject *);
+ inline QQmlMetaObject(const QObject *);
inline QQmlMetaObject(const QMetaObject *);
inline QQmlMetaObject(QQmlPropertyCache *);
inline QQmlMetaObject(const QQmlMetaObject &);
@@ -108,7 +108,7 @@ protected:
};
-QQmlMetaObject::QQmlMetaObject(QObject *o)
+QQmlMetaObject::QQmlMetaObject(const QObject *o)
{
if (o)
_m = o->metaObject();
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 114c5fec10..854cba6f29 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -820,7 +820,7 @@ int QQmlPropertyCache::originalClone(int index)
return index;
}
-int QQmlPropertyCache::originalClone(QObject *object, int index)
+int QQmlPropertyCache::originalClone(const QObject *object, int index)
{
QQmlData *data = QQmlData::get(object, false);
if (data && data->propertyCache) {
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 1adfc53cf5..4c9395601c 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -196,7 +196,7 @@ public:
//see QMetaObjectPrivate::originalClone
int originalClone(int index);
- static int originalClone(QObject *, int index);
+ static int originalClone(const QObject *, int index);
QList<QByteArray> signalParameterNames(int index) const;
static QString signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList<QByteArray> &parameterNameList, QString *errorString = nullptr);