Supply locale to QCollatorPrivate via its constructor
Both places that new'd it were then setting its locale themselves; they might as well do it tidily by passing it to the constructor. There's also no need to cleanup() in the constructor; every back-end is a no-op when collator has its initial value. Tidied up the class declaration in the process: * moved {con,de}structor to be first methods * comment on the two methods back-ends provide Change-Id: I041669637935e68141e002156552af8b475ba36e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
c39d2ab482
commit
d283d81c1c
@ -77,9 +77,8 @@ QT_BEGIN_NAMESPACE
|
||||
\sa setLocale()
|
||||
*/
|
||||
QCollator::QCollator(const QLocale &locale)
|
||||
: d(new QCollatorPrivate)
|
||||
: d(new QCollatorPrivate(locale))
|
||||
{
|
||||
d->locale = locale;
|
||||
d->init();
|
||||
}
|
||||
|
||||
@ -158,8 +157,7 @@ QCollator &QCollator::operator=(const QCollator &other)
|
||||
void QCollator::detach()
|
||||
{
|
||||
if (d->ref.load() != 1) {
|
||||
QCollatorPrivate *x = new QCollatorPrivate;
|
||||
x->locale = d->locale;
|
||||
QCollatorPrivate *x = new QCollatorPrivate(d->locale);
|
||||
if (!d->ref.deref())
|
||||
delete d;
|
||||
d = x;
|
||||
|
@ -104,19 +104,18 @@ public:
|
||||
|
||||
CollatorType collator = 0;
|
||||
|
||||
QCollatorPrivate(const QLocale &locale) : locale(locale) {}
|
||||
~QCollatorPrivate() { cleanup(); }
|
||||
|
||||
void clear() {
|
||||
cleanup();
|
||||
collator = 0;
|
||||
}
|
||||
|
||||
// Implemented by each back-end, in its own way:
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
QCollatorPrivate()
|
||||
{ cleanup(); }
|
||||
|
||||
~QCollatorPrivate() { cleanup(); }
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QCollatorPrivate)
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user