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>
bb10
Edward Welbourne 2018-07-11 20:19:48 +02:00
parent 0b688e2955
commit 199c49517e
1 changed files with 11 additions and 2 deletions

View File

@ -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;
}