QVariant: do reset is_null after setValue()
Issue introduced by a68e4f3b96 ("Use the
new QMetaType API in QVariant") in 6.0, which removed the d.is_null
reset at the same time as it replaced the std::destroy_at /
std::construct_at pair with an assignment operation.
[ChangeLog][QtCore][QVariant] Fixed a bug that would allow the class to
keep returning isNull() = true even after calling setValue().
Fixes: QTBUG-125472
Pick-to: 6.5 6.7
Change-Id: If05cb740b64f42eba21efffd17d13f6b1e8113c2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
parent
067f60f792
commit
26a81bd4fb
|
|
@ -497,6 +497,7 @@ public:
|
|||
// If possible we reuse the current QVariant private.
|
||||
if (isDetached() && d.type() == metaType) {
|
||||
*reinterpret_cast<VT *>(const_cast<void *>(constData())) = std::forward<T>(avalue);
|
||||
d.is_null = false;
|
||||
} else {
|
||||
*this = QVariant::fromValue<VT>(std::forward<T>(avalue));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -544,6 +544,9 @@ void tst_QVariant::isNull()
|
|||
var3 = QVariant(QMetaType::fromType<QString>());
|
||||
QVERIFY( var3.isNull() );
|
||||
|
||||
var3.setValue(QString());
|
||||
QVERIFY( !var3.isNull() );
|
||||
|
||||
QVariant var4( 0 );
|
||||
QVERIFY( !var4.isNull() );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue