Initialize dynamic meta object extradata.

QMetaObject::invokeMethod attempts to deference the extradata for
meta objects versions 6 and greater which is causing a crash in some
of the qtquick1 tests.

Change-Id: If5b2ca83b15de2cd558976c6b681dd5457c404d1
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
This commit is contained in:
Andrew den Exter 2012-02-08 15:13:22 +10:00 committed by Qt by Nokia
parent 09900d3dc5
commit 979cb5a09e
2 changed files with 35 additions and 0 deletions

View File

@ -1432,6 +1432,7 @@ void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output,
output->d.superdata = superclass; output->d.superdata = superclass;
output->d.stringdata = buf + stringdataOffset; output->d.stringdata = buf + stringdataOffset;
output->d.data = reinterpret_cast<const uint *>(buf + dataOffset); output->d.data = reinterpret_cast<const uint *>(buf + dataOffset);
output->d.extradata = 0;
} }
/*! /*!

View File

@ -64,6 +64,7 @@ private slots:
void staticMetacall(); void staticMetacall();
void copyMetaObject(); void copyMetaObject();
void serialize(); void serialize();
void relocatableData();
void removeNotifySignal(); void removeNotifySignal();
void usage_signal(); void usage_signal();
@ -1028,6 +1029,39 @@ void tst_QMetaObjectBuilder::serialize()
} }
} }
void tst_QMetaObjectBuilder::relocatableData()
{
QMetaObjectBuilder builder;
builder.setClassName("TestObject");
QMetaMethodBuilder intPropChanged = builder.addSignal("intPropChanged(int)");
intPropChanged.setParameterNames(QList<QByteArray>() << "newIntPropValue");
QMetaPropertyBuilder prop = builder.addProperty("intProp", "int");
prop.setNotifySignal(intPropChanged);
QMetaMethodBuilder voidSlotInt = builder.addSlot("voidSlotInt(int)");
voidSlotInt.setParameterNames(QList<QByteArray>() << "slotIntArg");
QMetaMethodBuilder listInvokableQRealQString = builder.addMethod("listInvokableQRealQString(qreal,QString)");
listInvokableQRealQString.setReturnType("QVariantList");
listInvokableQRealQString.setParameterNames(QList<QByteArray>() << "qrealArg" << "qstringArg");
bool ok = false;
QByteArray data = builder.toRelocatableData(&ok);
QVERIFY(ok);
QMetaObjectBuilder builder2;
QMetaObject meta2;
builder2.fromRelocatableData(&meta2, &QObject::staticMetaObject, data);
QMetaObject *meta = builder.toMetaObject();
QVERIFY(sameMetaObject(meta, &meta2));
free(meta);
}
// Check that removing a method updates notify signals appropriately // Check that removing a method updates notify signals appropriately
void tst_QMetaObjectBuilder::removeNotifySignal() void tst_QMetaObjectBuilder::removeNotifySignal()
{ {