summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-05-24 00:49:54 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-05-24 00:49:54 (GMT)
commit7104b7598f6c8d61d008edab227cfce3ec4442fc (patch)
treee390a009bbc0826af59b105f7d5501a3f59028a3 /src/corelib
parentb827967fef469f66a5a2f975bfafc3cdb82c4ffb (diff)
parentcb23151d3abfdbdf291abe8a1510592db2011927 (diff)
downloadQt-7104b7598f6c8d61d008edab227cfce3ec4442fc.zip
Qt-7104b7598f6c8d61d008edab227cfce3ec4442fc.tar.gz
Qt-7104b7598f6c8d61d008edab227cfce3ec4442fc.tar.bz2
Merge remote branch 'origin/4.7' into oslo-staging-1
Conflicts: src/gui/styles/qmacstyle_mac.mm
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/thread/qreadwritelock.cpp4
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp3
-rw-r--r--src/corelib/tools/qchar.cpp38
-rw-r--r--src/corelib/tools/qstring.cpp12
4 files changed, 33 insertions, 24 deletions
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp
index bd07a97..1a9eb0b 100644
--- a/src/corelib/thread/qreadwritelock.cpp
+++ b/src/corelib/thread/qreadwritelock.cpp
@@ -252,7 +252,7 @@ bool QReadWriteLock::tryLockForRead(int timeout)
while (d->accessCount < 0 || d->waitingWriters) {
++d->waitingReaders;
- bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : timeout);
+ bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout));
--d->waitingReaders;
if (!success)
return false;
@@ -374,7 +374,7 @@ bool QReadWriteLock::tryLockForWrite(int timeout)
while (d->accessCount != 0) {
++d->waitingWriters;
- bool success = d->writerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : timeout);
+ bool success = d->writerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout));
--d->waitingWriters;
if (!success)
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index 4a05dd8..b371b0e 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -63,7 +63,8 @@ static void report_error(int code, const char *where, const char *what)
-struct QWaitConditionPrivate {
+class QWaitConditionPrivate {
+public:
pthread_mutex_t mutex;
pthread_cond_t cond;
int waiters;
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index ddb1516..ed0af4e 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -1480,9 +1480,9 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion
if (!d || (canonical && tag != QChar::Canonical))
continue;
- s.replace(uc - utf16, ucs4 > 0x10000 ? 2 : 1, (const QChar *)d, length);
- // since the insert invalidates the pointers and we do decomposition recursive
int pos = uc - utf16;
+ s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast<const QChar *>(d), length);
+ // since the insert invalidates the pointers and we do decomposition recursive
utf16 = reinterpret_cast<unsigned short *>(s.data());
uc = utf16 + pos + length;
}
@@ -1567,46 +1567,52 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
int p2 = pos+1;
uint u1 = s.at(pos).unicode();
if (QChar(u1).isHighSurrogate()) {
- ushort low = s.at(pos+1).unicode();
+ ushort low = s.at(p2).unicode();
if (QChar(low).isLowSurrogate()) {
- p2++;
u1 = QChar::surrogateToUcs4(u1, low);
if (p2 >= l)
break;
+ ++p2;
}
}
uint u2 = s.at(p2).unicode();
- if (QChar(u2).isHighSurrogate() && p2 < l-1) {
+ if (QChar(u2).isHighSurrogate() && p2 < l) {
ushort low = s.at(p2+1).unicode();
if (QChar(low).isLowSurrogate()) {
- p2++;
u2 = QChar::surrogateToUcs4(u2, low);
+ ++p2;
}
}
- int c2 = QChar::combiningClass(u2);
- if (QChar::unicodeVersion(u2) > version)
- c2 = 0;
-
+ ushort c2 = 0;
+ {
+ const QUnicodeTables::Properties *p = qGetProp(u2);
+ if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
+ c2 = p->combiningClass;
+ }
if (c2 == 0) {
pos = p2+1;
continue;
}
- int c1 = QChar::combiningClass(u1);
- if (QChar::unicodeVersion(u1) > version)
- c1 = 0;
+
+ ushort c1 = 0;
+ {
+ const QUnicodeTables::Properties *p = qGetProp(u1);
+ if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
+ c1 = p->combiningClass;
+ }
if (c1 > c2) {
QChar *uc = s.data();
int p = pos;
// exchange characters
- if (u2 < 0x10000) {
+ if (!QChar::requiresSurrogates(u2)) {
uc[p++] = u2;
} else {
uc[p++] = QChar::highSurrogate(u2);
uc[p++] = QChar::lowSurrogate(u2);
}
- if (u1 < 0x10000) {
+ if (!QChar::requiresSurrogates(u1)) {
uc[p++] = u1;
} else {
uc[p++] = QChar::highSurrogate(u1);
@@ -1618,7 +1624,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
--pos;
} else {
++pos;
- if (u1 > 0x10000)
+ if (QChar::requiresSurrogates(u1))
++pos;
}
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 612c492..6acbcec 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -939,11 +939,11 @@ int QString::toWCharArray(wchar_t *array) const
const unsigned short *uc = utf16();
for (int i = 0; i < length(); ++i) {
uint u = uc[i];
- if (u >= 0xd800 && u < 0xdc00 && i < length()-1) {
+ if (QChar::isHighSurrogate(u) && i + 1 < length()) {
ushort low = uc[i+1];
- if (low >= 0xdc00 && low < 0xe000) {
+ if (QChar::isLowSurrogate(low)) {
+ u = QChar::surrogateToUcs4(u, low);
++i;
- u = (u - 0xd800)*0x400 + (low - 0xdc00) + 0x10000;
}
}
*a = wchar_t(u);
@@ -6195,8 +6195,10 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::
if (simple)
return;
- QString &s = *data;
- if (version != UNICODE_DATA_VERSION) {
+ if (version == QChar::Unicode_Unassigned) {
+ version = UNICODE_DATA_VERSION;
+ } else if (version != UNICODE_DATA_VERSION) {
+ QString &s = *data;
for (int i = 0; i < NumNormalizationCorrections; ++i) {
const NormalizationCorrection &n = uc_normalization_corrections[i];
if (n.version > version) {