Send DynamicPropertyChange event only when value is changed.
According to docs DynamicPropertyChange event should be sent from setProperty function only when property is added, removed or changed. Change-Id: I080a27a4119a63580b03172f4b5b367338c6f440 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
b28764c641
commit
3867bc5a10
@ -3809,6 +3809,8 @@ bool QObject::setProperty(const char *name, const QVariant &value)
|
||||
d->extraData->propertyNames.append(name);
|
||||
d->extraData->propertyValues.append(value);
|
||||
} else {
|
||||
if (value == d->extraData->propertyValues.at(idx))
|
||||
return false;
|
||||
d->extraData->propertyValues[idx] = value;
|
||||
}
|
||||
}
|
||||
|
@ -2950,6 +2950,9 @@ void tst_QObject::dynamicProperties()
|
||||
QVERIFY(!obj.setProperty("myuserproperty", "Hello"));
|
||||
QCOMPARE(obj.changedDynamicProperties.count(), 1);
|
||||
QCOMPARE(obj.changedDynamicProperties.first(), QByteArray("myuserproperty"));
|
||||
//check if there is no redundant DynamicPropertyChange events
|
||||
QVERIFY(!obj.setProperty("myuserproperty", "Hello"));
|
||||
QCOMPARE(obj.changedDynamicProperties.count(), 1);
|
||||
obj.changedDynamicProperties.clear();
|
||||
|
||||
QCOMPARE(obj.property("myuserproperty").toString(), QString("Hello"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user