diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2018-07-11 20:19:48 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-07-26 16:36:41 +0000 |
commit | 199c49517e184db09cbb5eff60e15d73096b330b (patch) | |
tree | b7489446faabaedbb38714000437e492d2ada5bb /src/corelib/tools | |
parent | 0b688e29556bfee806bedb17b89a6ce6689e7979 (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qcollator.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
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; } |