summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-12-08 11:15:19 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-12-09 08:59:41 (GMT)
commitd5d39f04c2c473401e9147d57d5a7c62f6111656 (patch)
treee622a118ee8bad5561d913b84af4be591d37187d /src/corelib
parent5a700d89a2263bcfc91d785c1ed444b1ecdacf83 (diff)
downloadQt-d5d39f04c2c473401e9147d57d5a7c62f6111656.zip
Qt-d5d39f04c2c473401e9147d57d5a7c62f6111656.tar.gz
Qt-d5d39f04c2c473401e9147d57d5a7c62f6111656.tar.bz2
Fix regression in qVariantFromValue when converting from complex type to simple type
QVariant v = QColor(Qt::red); v.setValue(1000); Would produce a variant with garbage. the destructor of QColor would not be called, and the 1000 would be in the QVariant::PrivateShared, while most of the QVariant code assume that numbers are dirrectly in the QVariant::Data union Task-number: QTBUG-6602 Reviewed-by: Thierry
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qvariant.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 3c10788..74ff17f 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -458,7 +458,7 @@ inline void qVariantSetValue(QVariant &v, const T &t)
//if possible we reuse the current QVariant private
const uint type = qMetaTypeId<T>(reinterpret_cast<T *>(0));
QVariant::Private &d = v.data_ptr();
- if (v.isDetached() && (type <= uint(QVariant::Char) || type == d.type)) {
+ if (v.isDetached() && (type == d.type || (type <= uint(QVariant::Char) && d.type <= uint(QVariant::Char)))) {
d.type = type;
d.is_null = false;
T *old = reinterpret_cast<T*>(d.is_shared ? d.data.shared->ptr : &d.data.ptr);