summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativepropertycache.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-10-15 06:25:58 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-10-15 06:25:58 (GMT)
commit4c4734cae65b7c5907dc786e02b13b020eb22aaf (patch)
treedbe36b2c18b0acca063f5c679c71f3017188bace /src/declarative/qml/qdeclarativepropertycache.cpp
parent372ad766c953234c3b1f161ab5447daa5569b6b0 (diff)
downloadQt-4c4734cae65b7c5907dc786e02b13b020eb22aaf.zip
Qt-4c4734cae65b7c5907dc786e02b13b020eb22aaf.tar.gz
Qt-4c4734cae65b7c5907dc786e02b13b020eb22aaf.tar.bz2
Allow overloaded methods, and methods with default params, to be called in QML
Task-number: QTBUG-11604
Diffstat (limited to 'src/declarative/qml/qdeclarativepropertycache.cpp')
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
index 259e492..91aaaa4 100644
--- a/src/declarative/qml/qdeclarativepropertycache.cpp
+++ b/src/declarative/qml/qdeclarativepropertycache.cpp
@@ -93,6 +93,7 @@ void QDeclarativePropertyCache::Data::load(const QMetaProperty &p, QDeclarativeE
void QDeclarativePropertyCache::Data::load(const QMetaMethod &m)
{
coreIndex = m.methodIndex();
+ relatedIndex = -1;
flags |= Data::IsFunction;
if (m.methodType() == QMetaMethod::Signal)
flags |= Data::IsSignal;
@@ -141,18 +142,24 @@ void QDeclarativePropertyCache::clear()
}
for (int ii = 0; ii < methodIndexCache.count(); ++ii) {
- if (methodIndexCache.at(ii)) methodIndexCache.at(ii)->release();
+ RData *data = methodIndexCache.at(ii);
+ if (data) data->release();
}
for (StringCache::ConstIterator iter = stringCache.begin();
- iter != stringCache.end(); ++iter)
- (*iter)->release();
+ iter != stringCache.end(); ++iter) {
+ RData *data = (*iter);
+ data->release();
+ }
for (IdentifierCache::ConstIterator iter = identifierCache.begin();
- iter != identifierCache.end(); ++iter)
- (*iter)->release();
+ iter != identifierCache.end(); ++iter) {
+ RData *data = (*iter);
+ data->release();
+ }
indexCache.clear();
+ methodIndexCache.clear();
stringCache.clear();
identifierCache.clear();
}
@@ -206,12 +213,16 @@ QDeclarativePropertyCache *QDeclarativePropertyCache::copy() const
{
QDeclarativePropertyCache *cache = new QDeclarativePropertyCache(engine);
cache->indexCache = indexCache;
+ cache->methodIndexCache = methodIndexCache;
cache->stringCache = stringCache;
cache->identifierCache = identifierCache;
for (int ii = 0; ii < indexCache.count(); ++ii) {
if (indexCache.at(ii)) indexCache.at(ii)->addref();
}
+ for (int ii = 0; ii < methodIndexCache.count(); ++ii) {
+ if (methodIndexCache.at(ii)) methodIndexCache.at(ii)->addref();
+ }
for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter)
(*iter)->addref();
for (IdentifierCache::ConstIterator iter = identifierCache.begin(); iter != identifierCache.end(); ++iter)
@@ -231,7 +242,7 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb
indexCache.resize(propCount);
for (int ii = propOffset; ii < propCount; ++ii) {
QMetaProperty p = metaObject->property(ii);
- if (!p.isScriptable())
+ if (!p.isScriptable())
continue;
QString propName = QString::fromUtf8(p.name());
@@ -261,7 +272,7 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb
methodIndexCache.resize(methodCount);
for (int ii = methodOffset; ii < methodCount; ++ii) {
QMetaMethod m = metaObject->method(ii);
- if (m.access() == QMetaMethod::Private)
+ if (m.access() == QMetaMethod::Private)
continue;
QString methodName = QString::fromUtf8(m.signature());
@@ -271,7 +282,7 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb
RData *data = new RData;
data->identifier = enginePriv->objectClass->createPersistentIdentifier(methodName);
- methodIndexCache[ii] = data;
+ methodIndexCache[ii] = data;
data->load(m);
if (m.methodType() == QMetaMethod::Slot || m.methodType() == QMetaMethod::Method)
@@ -280,6 +291,10 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb
data->flags |= signalFlags;
if (stringCache.contains(methodName)) {
+ RData *old = stringCache[methodName];
+ // We only overload methods in the same class, exactly like C++
+ if (old->flags & Data::IsFunction && old->coreIndex >= methodOffset)
+ data->relatedIndex = old->coreIndex;
stringCache[methodName]->release();
identifierCache[data->identifier.identifier]->release();
}