summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qcollator.cpp13
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;
}