aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-07-22 15:44:53 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-08-09 05:20:37 +0000
commitc3cbbf362c769b065fd0586b0510d043cbae92a4 (patch)
treed87c6c2345a22460b7dfa2113056a18b22fb88dc /src
parent4edeaa48abf8caccb62e623c32f97b0897c3167f (diff)
Qml: use const (and const APIs) more
For CoW types, prefer const methods to avoid needless detach()ing. Change-Id: I13e4d5b091877319984c1ddaed4da8dc59a7c0a3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp2
-rw-r--r--src/qml/qml/qqmlmetatype.cpp8
-rw-r--r--src/qml/qml/qqmlopenmetaobject.cpp2
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp6
-rw-r--r--src/qml/qml/qqmlproxymetaobject.cpp6
-rw-r--r--src/qml/qml/qqmltypeloader.cpp3
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp4
7 files changed, 15 insertions, 16 deletions
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index 8c342e0592..30fc186391 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -134,7 +134,7 @@ void QQmlApplicationEnginePrivate::_q_finishLoad(QObject *o)
break;
case QQmlComponent::Ready:
objects << c->create();
- q->objectCreated(objects.last(), c->url());
+ q->objectCreated(objects.constLast(), c->url());
break;
case QQmlComponent::Loading:
case QQmlComponent::Null:
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 271b4f1b31..ce0f4b798a 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -634,7 +634,7 @@ void QQmlTypePrivate::init() const
QMetaObject *mmo = builder.toMetaObject();
mmo->d.superdata = baseMetaObject;
if (!metaObjects.isEmpty())
- metaObjects.last().metaObject->d.superdata = mmo;
+ metaObjects.constLast().metaObject->d.superdata = mmo;
QQmlProxyMetaObject::ProxyData data = { mmo, t->d->extraData.cd->extFunc, 0, 0 };
metaObjects << data;
}
@@ -656,7 +656,7 @@ void QQmlTypePrivate::init() const
if (metaObjects.isEmpty())
mo = baseMetaObject;
else
- mo = metaObjects.first().metaObject;
+ mo = metaObjects.constFirst().metaObject;
for (int ii = 0; !containsRevisionedAttributes && ii < mo->propertyCount(); ++ii) {
if (isPropertyRevisioned(mo, ii))
@@ -851,7 +851,7 @@ const QMetaObject *QQmlType::metaObject() const
if (d->metaObjects.isEmpty())
return d->baseMetaObject;
else
- return d->metaObjects.first().metaObject;
+ return d->metaObjects.constFirst().metaObject;
}
@@ -1861,7 +1861,7 @@ QQmlType *QQmlMetaType::qmlTypeFromIndex(int idx)
if (idx < 0 || idx >= data->types.count())
return 0;
- return data->types[idx];
+ return data->types.at(idx);
}
/*!
diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp
index 0fd9e63bde..49f02476a2 100644
--- a/src/qml/qml/qqmlopenmetaobject.cpp
+++ b/src/qml/qml/qqmlopenmetaobject.cpp
@@ -278,7 +278,7 @@ int QQmlOpenMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void *
propertyRead(propId);
*reinterpret_cast<QVariant *>(a[0]) = d->getData(propId);
} else if (c == QMetaObject::WriteProperty) {
- if (propId >= d->data.count() || d->data[propId].first != *reinterpret_cast<QVariant *>(a[0])) {
+ if (propId >= d->data.count() || d->data.at(propId).first != *reinterpret_cast<QVariant *>(a[0])) {
propertyWrite(propId);
QPair<QVariant, bool> &prop = d->getDataRef(propId);
prop.first = propertyWriteValue(propId, *reinterpret_cast<QVariant *>(a[0]));
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 31218f5e4c..71b3fd8309 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -195,7 +195,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;
}
}
@@ -231,7 +231,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;
}
}
@@ -390,7 +390,7 @@ void QQmlPropertyCache::appendSignal(const QString &name, QQmlPropertyData::Flag
signalHandlerIndexCache.append(handler);
QString handlerName = QLatin1String("on") + name;
- handlerName[2] = handlerName[2].toUpper();
+ handlerName[2] = handlerName.at(2).toUpper();
setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex, (old != 0));
setNamedProperty(handlerName, signalHandlerIndex + signalOffset(), signalHandlerIndexCache.data() + signalHandlerIndex, (old != 0));
diff --git a/src/qml/qml/qqmlproxymetaobject.cpp b/src/qml/qml/qqmlproxymetaobject.cpp
index bbaab1e155..27e3c13ff8 100644
--- a/src/qml/qml/qqmlproxymetaobject.cpp
+++ b/src/qml/qml/qqmlproxymetaobject.cpp
@@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
QQmlProxyMetaObject::QQmlProxyMetaObject(QObject *obj, QList<ProxyData> *mList)
: metaObjects(mList), proxies(0), parent(0), object(obj)
{
- *static_cast<QMetaObject *>(this) = *metaObjects->first().metaObject;
+ *static_cast<QMetaObject *>(this) = *metaObjects->constFirst().metaObject;
QObjectPrivate *op = QObjectPrivate::get(obj);
if (op->metaObject)
@@ -71,7 +71,7 @@ int QQmlProxyMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void
if ((c == QMetaObject::ReadProperty ||
c == QMetaObject::WriteProperty) &&
- id >= metaObjects->last().propertyOffset) {
+ id >= metaObjects->constLast().propertyOffset) {
for (int ii = 0; ii < metaObjects->count(); ++ii) {
const ProxyData &data = metaObjects->at(ii);
@@ -107,7 +107,7 @@ int QQmlProxyMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void
}
}
} else if (c == QMetaObject::InvokeMetaMethod &&
- id >= metaObjects->last().methodOffset) {
+ id >= metaObjects->constLast().methodOffset) {
QMetaMethod m = object->metaObject()->method(id);
if (m.methodType() == QMetaMethod::Signal) {
QMetaObject::activate(object, id, a);
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 40a2c596e3..75bc98f278 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2002,8 +2002,7 @@ void QQmlTypeLoader::trimCache()
break;
while (!unneededTypes.isEmpty()) {
- TypeCache::Iterator iter = unneededTypes.last();
- unneededTypes.removeLast();
+ TypeCache::Iterator iter = unneededTypes.takeLast();
iter.value()->release();
m_typeCache.erase(iter);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 201d634411..3f56cc24e2 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -502,7 +502,7 @@ ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx)
if (r->d()->d->children.isEmpty())
return Encode::null();
else
- return Node::create(scope.engine, r->d()->d->children.first());
+ return Node::create(scope.engine, r->d()->d->children.constFirst());
}
ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx)
@@ -515,7 +515,7 @@ ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx)
if (r->d()->d->children.isEmpty())
return Encode::null();
else
- return Node::create(scope.engine, r->d()->d->children.last());
+ return Node::create(scope.engine, r->d()->d->children.constLast());
}
ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx)