QMetaObjectBuilder: fix addProperty() recording of the property type
Issue introduced by commit 465701bb98
.
[ChangeLog][QtCore][QMetaObjectBuilder] Fixed a bug that would cause
addProperty() to use the incorrect type for the property if the
property's name matched a valid type registered with QMetaType.
Pick-to: 6.2 6.3
Change-Id: Ic15405335d804bdea761fffd16d402f2c9611f30
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
d34282dba0
commit
8de0493896
@ -558,7 +558,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod &prototy
|
||||
QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QByteArray &name, const QByteArray &type,
|
||||
int notifierId)
|
||||
{
|
||||
return addProperty(name, type, QMetaType::fromName(name), notifierId);
|
||||
return addProperty(name, type, QMetaType::fromName(type), notifierId);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1638,17 +1638,19 @@ void tst_QMetaObjectBuilder::classNameFirstInStringData()
|
||||
}
|
||||
|
||||
struct MyFoo {};
|
||||
struct myParameter {};
|
||||
|
||||
void tst_QMetaObjectBuilder::propertyMetaType()
|
||||
{
|
||||
qRegisterMetaType<myParameter>();
|
||||
QMetaType meta = QMetaType::fromType<MyFoo>();
|
||||
auto metaId = meta.id();
|
||||
QMetaObjectBuilder builder;
|
||||
builder.setClassName("Test");
|
||||
builder.addProperty("test", "MyFoo");
|
||||
builder.addProperty("myParameter", "MyFoo");
|
||||
auto mo = builder.toMetaObject();
|
||||
|
||||
QMetaProperty metaProp = mo->property(mo->indexOfProperty("test"));
|
||||
QMetaProperty metaProp = mo->property(mo->indexOfProperty("myParameter"));
|
||||
QCOMPARE(metaProp.typeName(), meta.name());
|
||||
QCOMPARE(metaProp.typeId(), metaId);
|
||||
QCOMPARE(metaProp.metaType(), meta);
|
||||
|
Loading…
Reference in New Issue
Block a user