From: Chris Adams Date: Tue, 20 Dec 2011 05:33:47 +0000 (+1000) Subject: Remove hardcoded assumptions about methods in QObject X-Git-Tag: qt-v5.0.0-alpha1~806 X-Git-Url: http://review.tizen.org/git/?p=profile%2Fivi%2Fqtdeclarative.git;a=commitdiff_plain;h=97f6dbcd27fa0a2f72d3a58b0bd9aea1b930e464 Remove hardcoded assumptions about methods in QObject This commit ensures that the number of methods available from the QObject::staticMetaObject is looked up rather than hardcoded to a value in the QDeclarativePropertyCache. Task-number: QTBUG-22985 Change-Id: If61c02f0d32066cddaeac2d8143c58db97acb609 Reviewed-by: Alan Alpert --- diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 67d0cea..bd3bc33 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -357,8 +357,9 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb } } - // 3 to block the destroyed signal and the deleteLater() slot - int methodOffset = qMax(3, metaObject->methodOffset()); + // qMax(defaultMethods, methodOffset) to block the signals and slots of QObject::staticMetaObject + // incl. destroyed signals, objectNameChanged signal, deleteLater slot, _q_reregisterTimers slot. + int methodOffset = qMax(QObject::staticMetaObject.methodCount(), metaObject->methodOffset()); int signalOffset = signalCount - QMetaObjectPrivate::get(metaObject)->signalCount; // update() should have reserved enough space in the vector that this doesn't cause a realloc @@ -757,8 +758,10 @@ QDeclarativePropertyData qDeclarativePropertyCacheCreate(const QMetaObject *meta } int methodCount = metaObject->methodCount(); - for (int ii = methodCount - 1; ii >= 3; --ii) { - // >=3 to block the destroyed signal and deleteLater() slot + int defaultMethods = QObject::staticMetaObject.methodCount(); + for (int ii = methodCount - 1; ii >= defaultMethods; --ii) { + // >=defaultMethods to block the signals and slots of QObject::staticMetaObject + // incl. destroyed signals, objectNameChanged signal, deleteLater slot, _q_reregisterTimers slot. QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) continue;