summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2018-07-11 18:25:33 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2018-08-13 14:15:51 +0000
commit6694065148e5222df2c4cac7bfbf1e36251acde8 (patch)
tree3b9d23d94db9313e999976a8ce75ba1adc1b0645 /src/corelib
parentd283d81c1c65b945662f90403f58124cb7fb8f47 (diff)
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>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qcollator_icu.cpp4
-rw-r--r--src/corelib/tools/qcollator_p.h10
2 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp
index 43bbe0ea79..fd621983d3 100644
--- a/src/corelib/tools/qcollator_icu.cpp
+++ b/src/corelib/tools/qcollator_icu.cpp
@@ -61,7 +61,7 @@ void QCollatorPrivate::init()
collator = ucol_open(name.constData(), &status);
if (U_FAILURE(status)) {
qWarning("Could not create collator: %d", status);
- collator = 0;
+ collator = nullptr;
dirty = false;
return;
}
@@ -100,7 +100,7 @@ void QCollatorPrivate::cleanup()
{
if (collator)
ucol_close(collator);
- collator = 0;
+ collator = nullptr;
}
int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const
diff --git a/src/corelib/tools/qcollator_p.h b/src/corelib/tools/qcollator_p.h
index 18a43f0de6..f244a7721a 100644
--- a/src/corelib/tools/qcollator_p.h
+++ b/src/corelib/tools/qcollator_p.h
@@ -68,21 +68,25 @@ QT_BEGIN_NAMESPACE
#if QT_CONFIG(icu)
typedef UCollator *CollatorType;
typedef QByteArray CollatorKeyType;
+const CollatorType NoCollator = nullptr;
#elif defined(Q_OS_OSX)
typedef CollatorRef CollatorType;
typedef QVector<UCCollationValue> CollatorKeyType;
+const CollatorType NoCollator = 0;
#elif defined(Q_OS_WIN)
typedef QString CollatorKeyType;
typedef int CollatorType;
+const CollatorType NoCollator = 0;
# ifdef Q_OS_WINRT
# define USE_COMPARESTRINGEX
# endif
-#else //posix
+#else // posix - ignores CollatorType collator, only handles system locale
typedef QVector<wchar_t> CollatorKeyType;
typedef int CollatorType;
+const CollatorType NoCollator = 0;
#endif
class QCollatorPrivate
@@ -102,14 +106,14 @@ public:
bool ignorePunctuation = false;
bool dirty = true;
- CollatorType collator = 0;
+ CollatorType collator = NoCollator;
QCollatorPrivate(const QLocale &locale) : locale(locale) {}
~QCollatorPrivate() { cleanup(); }
void clear() {
cleanup();
- collator = 0;
+ collator = NoCollator;
}
// Implemented by each back-end, in its own way: