QVariant: do reset is_null after setValue()
Issue introduced by a68e4f3b96a82a93898f381e8ddc7f50f9c89d40 ("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 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> (cherry picked from commit 26a81bd4fb1f382b2b1652566652301cfe1270a2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
f9ce500915
commit
843b0b819b
@ -496,6 +496,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));
|
||||
}
|
||||
|
@ -541,6 +541,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…
x
Reference in New Issue
Block a user