diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-06-26 10:01:38 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-06-26 10:03:34 (GMT) |
commit | 56fbd7644b6f292dcd7d8d215bd469d94a0948ae (patch) | |
tree | b0247803e12f05742f889269a82f9641fb16398a /src | |
parent | b914c388a809c17e4f76a4dcc1d3a1006e13c115 (diff) | |
download | Qt-56fbd7644b6f292dcd7d8d215bd469d94a0948ae.zip Qt-56fbd7644b6f292dcd7d8d215bd469d94a0948ae.tar.gz Qt-56fbd7644b6f292dcd7d8d215bd469d94a0948ae.tar.bz2 |
QVariant::setValue had a bug when changing its type
If it was shared and you then set it back to an int type,
it is still marked as shared,. This might even lead to crashes.
The patch was sent through gitorious by Jürgen Starek.
Note: autotest added as well
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qvariant.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 6844d3e..e923844 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -448,7 +448,7 @@ inline void qVariantSetValue(QVariant &v, const T &t) //if possible we reuse the current QVariant private const int type = qMetaTypeId<T>(reinterpret_cast<T *>(0)); QVariant::Private &d = v.data_ptr(); - if (type <= int(QVariant::Char) || (type == d.type && v.isDetached())) { + if (v.isDetached() && (type <= int(QVariant::Char) || type == d.type)) { d.type = type; T *old = reinterpret_cast<T*>(d.is_shared ? d.data.shared->ptr : &d.data.ptr); if (QTypeInfo<T>::isComplex) |