From 199c49517e184db09cbb5eff60e15d73096b330b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 11 Jul 2018 20:19:48 +0200 Subject: Clean before copying any QCollator This avoids the hazard of both (if on separate threads) trying to init() at the same time, if they were dirty before cloning. Task-number: QTBUG-69361 Change-Id: Iabb06942c074ba073ca58fd0de509d1db15c1093 Reviewed-by: Thiago Macieira --- src/corelib/tools/qcollator.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools/qcollator.cpp') diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp index 2d17b00ba2..5155badcf8 100644 --- a/src/corelib/tools/qcollator.cpp +++ b/src/corelib/tools/qcollator.cpp @@ -89,8 +89,12 @@ QCollator::QCollator(const QLocale &locale) QCollator::QCollator(const QCollator &other) : d(other.d) { - if (d) + if (d) { + // Ensure clean, lest both copies try to init() at the same time: + if (d->dirty) + d->init(); d->ref.ref(); + } } /*! @@ -111,7 +115,12 @@ QCollator &QCollator::operator=(const QCollator &other) if (d && !d->ref.deref()) delete d; d = other.d; - if (d) d->ref.ref(); + if (d) { + // Ensure clean, lest both copies try to init() at the same time: + if (d->dirty) + d->init(); + d->ref.ref(); + } } return *this; } -- cgit v1.2.3