summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qvariant.h1
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp8
2 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index eb4fb56..4cce529 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -460,6 +460,7 @@ inline void qVariantSetValue(QVariant &v, const T &t)
QVariant::Private &d = v.data_ptr();
if (v.isDetached() && (type <= int(QVariant::Char) || type == d.type)) {
d.type = type;
+ d.is_null = false;
T *old = reinterpret_cast<T*>(d.is_shared ? d.data.shared->ptr : &d.data.ptr);
if (QTypeInfo<T>::isComplex)
old->~T();
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 9295897..de4d7b4 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -318,6 +318,14 @@ void tst_QVariant::constructor()
QVariant var6(qlonglong(0));
QCOMPARE(var6.type(), QVariant::LongLong);
QCOMPARE(var6.typeName(), "qlonglong");
+
+ QVariant var7 = 5;
+ QVERIFY(var7.isValid());
+ QVERIFY(!var7.isNull());
+ QVariant var8;
+ var8.setValue<int>(5);
+ QVERIFY(var8.isValid());
+ QVERIFY(!var8.isNull());
}
void tst_QVariant::copy_constructor()