summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale.cpp
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-02-15 17:50:38 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-02-17 13:33:00 (GMT)
commit8a74c5112aa81c5638b14d8b5285e6ef8474a195 (patch)
treea6cceb01c8163f195c82586f9850cdefdfdffc2c /src/corelib/tools/qlocale.cpp
parent049cc0e6717f684453d40f78e9ec0e9093df2c1d (diff)
downloadQt-8a74c5112aa81c5638b14d8b5285e6ef8474a195.zip
Qt-8a74c5112aa81c5638b14d8b5285e6ef8474a195.tar.gz
Qt-8a74c5112aa81c5638b14d8b5285e6ef8474a195.tar.bz2
Fixed QString creation for certain cases in QLocale
If the data that was requested is missing from CLDR, then we do not need to try to create QString out of empty data, but return a shared_empty QString instead. i.e. QString::fromRawData(data, 0/*length==0*/) - instead of doing that just return a default constructed QString. Reviewed-by: Zeno Albisser
Diffstat (limited to 'src/corelib/tools/qlocale.cpp')
-rw-r--r--src/corelib/tools/qlocale.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 3f19c27..5debabb 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -1522,12 +1522,14 @@ static QString getLocaleListData(const ushort *data, int size, int index)
const ushort *end = data;
while (size > 0 && *end != separator)
++end, --size;
+ if (end-data == 0)
+ return QString();
return QString::fromRawData(reinterpret_cast<const QChar*>(data), end-data);
}
static inline QString getLocaleData(const ushort *data, int size)
{
- return QString::fromRawData(reinterpret_cast<const QChar*>(data), size);
+ return size ? QString::fromRawData(reinterpret_cast<const QChar*>(data), size) : QString();
}