Use suitable abstraction for the null value of CollatorType
QCollatorPrivate defines a back-end-specific CollatorType and sets a member of this type to 0; but ICU's version really wants a nullptr not 0. So provide a named constant of the type, that's the NoCollator value for use there. Change-Id: Iad4d2f803ff4807ea568755efe00b9a92f1a8eeb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
d283d81c1c
commit
6694065148
@ -61,7 +61,7 @@ void QCollatorPrivate::init()
|
|||||||
collator = ucol_open(name.constData(), &status);
|
collator = ucol_open(name.constData(), &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
qWarning("Could not create collator: %d", status);
|
qWarning("Could not create collator: %d", status);
|
||||||
collator = 0;
|
collator = nullptr;
|
||||||
dirty = false;
|
dirty = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ void QCollatorPrivate::cleanup()
|
|||||||
{
|
{
|
||||||
if (collator)
|
if (collator)
|
||||||
ucol_close(collator);
|
ucol_close(collator);
|
||||||
collator = 0;
|
collator = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const
|
int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const
|
||||||
|
@ -68,21 +68,25 @@ QT_BEGIN_NAMESPACE
|
|||||||
#if QT_CONFIG(icu)
|
#if QT_CONFIG(icu)
|
||||||
typedef UCollator *CollatorType;
|
typedef UCollator *CollatorType;
|
||||||
typedef QByteArray CollatorKeyType;
|
typedef QByteArray CollatorKeyType;
|
||||||
|
const CollatorType NoCollator = nullptr;
|
||||||
|
|
||||||
#elif defined(Q_OS_OSX)
|
#elif defined(Q_OS_OSX)
|
||||||
typedef CollatorRef CollatorType;
|
typedef CollatorRef CollatorType;
|
||||||
typedef QVector<UCCollationValue> CollatorKeyType;
|
typedef QVector<UCCollationValue> CollatorKeyType;
|
||||||
|
const CollatorType NoCollator = 0;
|
||||||
|
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
typedef QString CollatorKeyType;
|
typedef QString CollatorKeyType;
|
||||||
typedef int CollatorType;
|
typedef int CollatorType;
|
||||||
|
const CollatorType NoCollator = 0;
|
||||||
# ifdef Q_OS_WINRT
|
# ifdef Q_OS_WINRT
|
||||||
# define USE_COMPARESTRINGEX
|
# define USE_COMPARESTRINGEX
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else //posix
|
#else // posix - ignores CollatorType collator, only handles system locale
|
||||||
typedef QVector<wchar_t> CollatorKeyType;
|
typedef QVector<wchar_t> CollatorKeyType;
|
||||||
typedef int CollatorType;
|
typedef int CollatorType;
|
||||||
|
const CollatorType NoCollator = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class QCollatorPrivate
|
class QCollatorPrivate
|
||||||
@ -102,14 +106,14 @@ public:
|
|||||||
bool ignorePunctuation = false;
|
bool ignorePunctuation = false;
|
||||||
bool dirty = true;
|
bool dirty = true;
|
||||||
|
|
||||||
CollatorType collator = 0;
|
CollatorType collator = NoCollator;
|
||||||
|
|
||||||
QCollatorPrivate(const QLocale &locale) : locale(locale) {}
|
QCollatorPrivate(const QLocale &locale) : locale(locale) {}
|
||||||
~QCollatorPrivate() { cleanup(); }
|
~QCollatorPrivate() { cleanup(); }
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
cleanup();
|
cleanup();
|
||||||
collator = 0;
|
collator = NoCollator;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implemented by each back-end, in its own way:
|
// Implemented by each back-end, in its own way:
|
||||||
|
Loading…
Reference in New Issue
Block a user