Make QLocalePrivate POD
QSharedDataPointer does not actually need a class derived from QSharedData. All it needs is a member called "ref". Change-Id: I2f7fe4cc143478ef7ef64681eada16e2d4c2e63a Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
This commit is contained in:
parent
50ab31a5df
commit
08ac38a6e3
@ -702,12 +702,12 @@ const QLocaleData *QLocalePrivate::dataPointerForIndex(quint16 index)
|
||||
|
||||
static QLocalePrivate *localePrivateByName(const QString &name)
|
||||
{
|
||||
return new QLocalePrivate(findLocaleData(name));
|
||||
return QLocalePrivate::create(findLocaleData(name));
|
||||
}
|
||||
|
||||
static QLocalePrivate *defaultLocalePrivate()
|
||||
{
|
||||
return new QLocalePrivate(defaultData(), default_number_options);
|
||||
return QLocalePrivate::create(defaultData(), default_number_options);
|
||||
}
|
||||
|
||||
static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Script script,
|
||||
@ -722,7 +722,7 @@ static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Sc
|
||||
numberOptions = default_number_options;
|
||||
data = defaultData();
|
||||
}
|
||||
return new QLocalePrivate(data, numberOptions);
|
||||
return QLocalePrivate::create(data, numberOptions);
|
||||
}
|
||||
|
||||
|
||||
@ -2108,7 +2108,7 @@ QString QLocale::toString(double i, char f, int prec) const
|
||||
|
||||
QLocale QLocale::system()
|
||||
{
|
||||
return QLocale(*new QLocalePrivate(systemData()));
|
||||
return QLocale(*QLocalePrivate::create(systemData()));
|
||||
}
|
||||
|
||||
|
||||
@ -2143,7 +2143,7 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
|
||||
&& (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) {
|
||||
if ((script == QLocale::AnyScript || data->m_script_id == uint(script))
|
||||
&& (country == QLocale::AnyCountry || data->m_country_id == uint(country))) {
|
||||
QLocale locale(*new QLocalePrivate(data));
|
||||
QLocale locale(*QLocalePrivate::create(data));
|
||||
result.append(locale);
|
||||
}
|
||||
++data;
|
||||
|
@ -205,16 +205,16 @@ public:
|
||||
quint16 m_weekend_end : 3;
|
||||
};
|
||||
|
||||
class Q_CORE_EXPORT QLocalePrivate : public QSharedData
|
||||
class Q_CORE_EXPORT QLocalePrivate
|
||||
{
|
||||
public:
|
||||
explicit QLocalePrivate(const QLocaleData *data, int numberOptions = 0)
|
||||
: m_data(data), m_numberOptions(numberOptions)
|
||||
{
|
||||
}
|
||||
|
||||
~QLocalePrivate()
|
||||
static QLocalePrivate *create(const QLocaleData *data, int numberOptions = 0)
|
||||
{
|
||||
QLocalePrivate *retval = new QLocalePrivate;
|
||||
retval->m_data = data;
|
||||
retval->ref.store(1);
|
||||
retval->m_numberOptions = numberOptions;
|
||||
return retval;
|
||||
}
|
||||
|
||||
QChar decimal() const { return QChar(m_data->m_decimal); }
|
||||
@ -332,9 +332,18 @@ public:
|
||||
const QLocale *q) const;
|
||||
|
||||
const QLocaleData *m_data;
|
||||
QBasicAtomicInt ref;
|
||||
quint16 m_numberOptions;
|
||||
};
|
||||
|
||||
template <>
|
||||
inline QLocalePrivate *QSharedDataPointer<QLocalePrivate>::clone()
|
||||
{
|
||||
// cannot use QLocalePrivate's copy constructor
|
||||
// since it is deleted in C++11
|
||||
return QLocalePrivate::create(d->m_data, d->m_numberOptions);
|
||||
}
|
||||
|
||||
inline char QLocalePrivate::digitToCLocale(QChar in) const
|
||||
{
|
||||
const QChar _zero = zero();
|
||||
|
Loading…
Reference in New Issue
Block a user