Fix crash in lazy meta object generation.

Inside the property cache, override data can only handle overrides
pointing to either a method or a property, but not to a signal
handler.  This is a bug in itself, but has never come up before due
to no one following override data on methods.  When this
was changed by d2e557c2c2, this bug
was exposed.

This change doesn't actually fix the underlying problem, but it does
restore exactly the same behavior we had previously.  The complete
fix will come in a later change.

Change-Id: I6a890e6ca1e40735da8158b21dfe38dc88091081
Reviewed-by: Martin Jones <martin.jones@nokia.com>
This commit is contained in:
Aaron Kennedy 2012-06-01 15:07:54 +01:00 committed by Qt by Nokia
parent 12d432d1e3
commit 4697937789
3 changed files with 18 additions and 1 deletions

View File

@ -1201,7 +1201,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder)
QQmlPropertyData *olddata = data;
data = This->overrideData(data);
if (data) Insert::in(This, properties, methods, iter, data);
if (data && !data->isFunction()) Insert::in(This, properties, methods, iter, data);
} else {
if (data->coreIndex < This->propertyIndexCacheStart)
return;

View File

@ -0,0 +1,6 @@
import QtQuick 2.0
QtObject {
signal routeStatusChanged
function onRouteStatusChanged() { }
}

View File

@ -268,6 +268,7 @@ private slots:
void qqmldataDestroyed();
void secondAlias();
void varAlias();
void overrideDataAssert();
private:
static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@ -6961,6 +6962,16 @@ void tst_qqmlecmascript::varAlias()
delete object;
}
// Used to trigger an assert in the lazy meta object creation stage
void tst_qqmlecmascript::overrideDataAssert()
{
QQmlComponent c(&engine, testFileUrl("overrideDataAssert.qml"));
QObject *object = c.create();
QVERIFY(object != 0);
object->metaObject();
delete object;
}
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"