From 97f6dbcd27fa0a2f72d3a58b0bd9aea1b930e464 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 20 Dec 2011 15:33:47 +1000 Subject: [PATCH] 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 --- src/declarative/qml/qdeclarativepropertycache.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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; -- 2.7.4