summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@digia.com>2013-02-12 14:08:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-20 15:22:55 +0100
commitdacc222d5a3327fb27d69e57d99111cdf9084304 (patch)
treede03a59bba5f628b51fa03a4230b43c215da12ee /src
parentd3a4230757931a704f36dd1eb4917a5ce61f80b4 (diff)
Fix QVector detaching in one thread while another destroys it.
The patch adds handling for a case when a QVector is shared between two threads. In such scenario detaching in one thread could collide with destruction in the other one, causing a memory leak or assert in debug mode. Task-number: QTBUG-29134 Change-Id: Idbff250d9cfc6cf83174954ea91dbf41f8ea4aa4 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qvector.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 191be6292c..94f3008274 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -506,8 +506,7 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
}
if (d != x) {
if (!d->ref.deref()) {
- Q_ASSERT(!isShared);
- if (QTypeInfo<T>::isStatic || !aalloc) {
+ if (QTypeInfo<T>::isStatic || !aalloc || (isShared && QTypeInfo<T>::isComplex)) {
// data was copy constructed, we need to call destructors
// or if !alloc we did nothing to the old 'd'.
freeData(d);