diff options
Diffstat (limited to 'src/corelib')
24 files changed, 80 insertions, 59 deletions
diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri index 86b330c589..bfb677e6fb 100644 --- a/src/corelib/codecs/codecs.pri +++ b/src/corelib/codecs/codecs.pri @@ -3,6 +3,7 @@ HEADERS += \ codecs/qisciicodec_p.h \ codecs/qlatincodec_p.h \ + codecs/qsimplecodec_p.h \ codecs/qtextcodec_p.h \ codecs/qtextcodec.h \ codecs/qtsciicodec_p.h \ @@ -11,6 +12,7 @@ HEADERS += \ SOURCES += \ codecs/qisciicodec.cpp \ codecs/qlatincodec.cpp \ + codecs/qsimplecodec.cpp \ codecs/qtextcodec.cpp \ codecs/qtsciicodec.cpp \ codecs/qutfcodec.cpp @@ -22,7 +24,6 @@ contains(QT_CONFIG,icu) { codecs/qicucodec.cpp } else { HEADERS += \ - codecs/qsimplecodec_p.h \ codecs/qgb18030codec_p.h \ codecs/qeucjpcodec_p.h \ codecs/qjiscodec_p.h \ @@ -31,7 +32,6 @@ contains(QT_CONFIG,icu) { codecs/qbig5codec_p.h SOURCES += \ - codecs/qsimplecodec.cpp \ codecs/qgb18030codec.cpp \ codecs/qjpunicode.cpp \ codecs/qeucjpcodec.cpp \ diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp index 96d62f7084..65cc337708 100644 --- a/src/corelib/codecs/qicucodec.cpp +++ b/src/corelib/codecs/qicucodec.cpp @@ -40,6 +40,7 @@ #include "qlatincodec_p.h" #include "qtsciicodec_p.h" #include "qisciicodec_p.h" +#include "qsimplecodec_p.h" #include "private/qcoreglobaldata_p.h" #include "qdebug.h" @@ -364,6 +365,8 @@ static QTextCodec *loadQtCodec(const char *name) return new QUtf32BECodec; if (!strcmp(name, "UTF-32LE")) return new QUtf32LECodec; + if (!strcmp(name, "ISO-8859-16") || !strcmp(name, "latin10") || !strcmp(name, "iso-ir-226")) + return new QSimpleTextCodec(13 /* == 8859-16*/); #ifndef QT_NO_CODECS if (!strcmp(name, "TSCII")) return new QTsciiCodec; diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 95f5993e4f..354c0e1392 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -290,7 +290,10 @@ operator<<(QDebug dbg, T value) } template <class T> -inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags) +inline typename QtPrivate::QEnableIf< + QtPrivate::IsQEnumHelper<T>::Value || QtPrivate::IsQEnumHelper<QFlags<T> >::Value, + QDebug>::Type +operator<<(QDebug debug, const QFlags<T> &flags) { const QMetaObject *obj = qt_getEnumMetaObject(T()); const char *name = qt_getEnumName(T()); @@ -298,7 +301,10 @@ inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug> } template <class T> -inline typename QtPrivate::QEnableIf<!QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags) +inline typename QtPrivate::QEnableIf< + !QtPrivate::IsQEnumHelper<T>::Value && !QtPrivate::IsQEnumHelper<QFlags<T> >::Value, + QDebug>::Type +operator<<(QDebug debug, const QFlags<T> &flags) #else // !QT_NO_QOBJECT template <class T> inline QDebug operator<<(QDebug debug, const QFlags<T> &flags) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index c9c6704423..7fa53bd850 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -235,7 +235,7 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt firstModified.setTimeSpec(Qt::UTC); secondModified.setTimeSpec(Qt::UTC); - r = firstModified.secsTo(secondModified); + r = firstModified.msecsTo(secondModified); break; } case QDir::Size: diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 1c8da607a7..c663681aaa 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -137,7 +137,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() // (otherwise we'd have to check every write call) // Use operator% from the fast builder to avoid multiple memory allocations. QByteArray fileData = QByteArray::number(QCoreApplication::applicationPid()) % '\n' - % qAppName().toUtf8() % '\n' + % QCoreApplication::applicationName().toUtf8() % '\n' % localHostName() % '\n'; const QByteArray lockFileName = QFile::encodeName(fileName); diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp index 95d952c918..a36e6e93b8 100644 --- a/src/corelib/io/qlockfile_win.cpp +++ b/src/corelib/io/qlockfile_win.cpp @@ -94,7 +94,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() QByteArray fileData; fileData += QByteArray::number(QCoreApplication::applicationPid()); fileData += '\n'; - fileData += qAppName().toUtf8(); + fileData += QCoreApplication::applicationName().toUtf8(); fileData += '\n'; fileData += localHostName(); fileData += '\n'; diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h index b8430cabf5..5fc021c841 100644 --- a/src/corelib/json/qjson_p.h +++ b/src/corelib/json/qjson_p.h @@ -629,7 +629,7 @@ public: if (value.latinKey) s += sizeof(ushort) + qFromLittleEndian(*(ushort *) ((const char *)this + sizeof(Entry))); else - s += sizeof(uint) + qFromLittleEndian(*(int *) ((const char *)this + sizeof(Entry))); + s += sizeof(uint) + sizeof(ushort)*qFromLittleEndian(*(int *) ((const char *)this + sizeof(Entry))); return alignedSize(s); } diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp index c8ddfbc2cc..ae6a3678bd 100644 --- a/src/corelib/json/qjsonvalue.cpp +++ b/src/corelib/json/qjsonvalue.cpp @@ -704,6 +704,11 @@ QJsonValueRef &QJsonValueRef::operator =(const QJsonValueRef &ref) return *this; } +QVariant QJsonValueRef::toVariant() const +{ + return toValue().toVariant(); +} + QJsonArray QJsonValueRef::toArray() const { return toValue().toArray(); diff --git a/src/corelib/json/qjsonvalue.h b/src/corelib/json/qjsonvalue.h index b7e77e4b19..372ae85290 100644 --- a/src/corelib/json/qjsonvalue.h +++ b/src/corelib/json/qjsonvalue.h @@ -146,6 +146,7 @@ public: QJsonValueRef &operator = (const QJsonValue &val); QJsonValueRef &operator = (const QJsonValueRef &val); + QVariant toVariant() const; inline QJsonValue::Type type() const { return toValue().type(); } inline bool isNull() const { return type() == QJsonValue::Null; } inline bool isBool() const { return type() == QJsonValue::Bool; } diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 2c2dbeef9d..55f8fc9b2c 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1364,15 +1364,15 @@ namespace QtPrivate enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(void*) }; }; - char qt_getEnumMetaObject(...); - char qt_getEnumMetaObject(); // Workaround bugs in MSVC. + template<typename T> char qt_getEnumMetaObject(const T&); template<typename T> struct IsQEnumHelper { static const T &declval(); - // If the type was declared with Q_ENUM, the friend qt_getEnumMetaObject(T) declared in the + // If the type was declared with Q_ENUM, the friend qt_getEnumMetaObject() declared in the // Q_ENUM macro will be chosen by ADL, and the return type will be QMetaObject*. - // Otherwise the chosen overload will be qt_getEnumMetaObject(...) which returne 'char' + // Otherwise the chosen overload will be the catch all template function + // qt_getEnumMetaObject(T) which returns 'char' enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) }; }; diff --git a/src/corelib/kernel/qsharedmemory_android.cpp b/src/corelib/kernel/qsharedmemory_android.cpp index f7511ea8b7..cdcd5685e0 100644 --- a/src/corelib/kernel/qsharedmemory_android.cpp +++ b/src/corelib/kernel/qsharedmemory_android.cpp @@ -47,7 +47,7 @@ QSharedMemoryPrivate::QSharedMemoryPrivate() { } -void QSharedMemoryPrivate::setErrorString(const QString &function) +void QSharedMemoryPrivate::setErrorString(QLatin1String function) { Q_UNUSED(function); qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index 0308dde57f..2bcc0d4f6a 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -133,7 +133,7 @@ public: bool attach(QSharedMemory::AccessMode mode); bool detach(); - void setErrorString(const QString &function); + void setErrorString(QLatin1String function); #ifndef QT_NO_SYSTEMSEMAPHORE bool tryLocker(QSharedMemoryLocker *locker, const QString &function) { diff --git a/src/corelib/kernel/qsharedmemory_posix.cpp b/src/corelib/kernel/qsharedmemory_posix.cpp index 74f98a158a..1142d3223c 100644 --- a/src/corelib/kernel/qsharedmemory_posix.cpp +++ b/src/corelib/kernel/qsharedmemory_posix.cpp @@ -94,7 +94,7 @@ bool QSharedMemoryPrivate::create(int size) #endif if (fd == -1) { const int errorNumber = errno; - const QString function = QLatin1String("QSharedMemory::create"); + const QLatin1String function("QSharedMemory::attach (shm_open)"); switch (errorNumber) { case ENAMETOOLONG: case EINVAL: @@ -138,7 +138,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode) #endif if (hand == -1) { const int errorNumber = errno; - const QString function = QLatin1String("QSharedMemory::attach (shm_open)"); + const QLatin1String function("QSharedMemory::attach (shm_open)"); switch (errorNumber) { case ENAMETOOLONG: case EINVAL: diff --git a/src/corelib/kernel/qsharedmemory_systemv.cpp b/src/corelib/kernel/qsharedmemory_systemv.cpp index 953747e41d..29fee12c0b 100644 --- a/src/corelib/kernel/qsharedmemory_systemv.cpp +++ b/src/corelib/kernel/qsharedmemory_systemv.cpp @@ -149,7 +149,7 @@ bool QSharedMemoryPrivate::create(int size) // create if (-1 == shmget(unix_key, size, 0600 | IPC_CREAT | IPC_EXCL)) { - QString function = QLatin1String("QSharedMemory::create"); + const QLatin1String function("QSharedMemory::create"); switch (errno) { case EINVAL: errorString = QSharedMemory::tr("%1: system-imposed size restrictions").arg(QLatin1String("QSharedMemory::handle")); @@ -199,7 +199,7 @@ bool QSharedMemoryPrivate::detach() { // detach from the memory segment if (-1 == shmdt(memory)) { - QString function = QLatin1String("QSharedMemory::detach"); + const QLatin1String function("QSharedMemory::detach"); switch (errno) { case EINVAL: errorString = QSharedMemory::tr("%1: not attached").arg(function); diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index 92184a619b..ec6223142f 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -71,7 +71,7 @@ QSharedMemoryPrivate::QSharedMemoryPrivate() { } -void QSharedMemoryPrivate::setErrorString(const QString &function) +void QSharedMemoryPrivate::setErrorString(QLatin1String function) { // EINVAL is handled in functions so they can give better error strings switch (errno) { diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp index 8e094cb458..4d37368b2e 100644 --- a/src/corelib/kernel/qsharedmemory_win.cpp +++ b/src/corelib/kernel/qsharedmemory_win.cpp @@ -47,9 +47,9 @@ QSharedMemoryPrivate::QSharedMemoryPrivate() : QObjectPrivate(), { } -void QSharedMemoryPrivate::setErrorString(const QString &function) +void QSharedMemoryPrivate::setErrorString(QLatin1String function) { - BOOL windowsError = GetLastError(); + DWORD windowsError = GetLastError(); if (windowsError == 0) return; switch (windowsError) { @@ -91,7 +91,7 @@ void QSharedMemoryPrivate::setErrorString(const QString &function) HANDLE QSharedMemoryPrivate::handle() { if (!hand) { - QString function = QLatin1String("QSharedMemory::handle"); + const QLatin1String function("QSharedMemory::handle"); if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: unable to make key").arg(function); @@ -130,7 +130,7 @@ bool QSharedMemoryPrivate::cleanHandle() bool QSharedMemoryPrivate::create(int size) { - QString function = QLatin1String("QSharedMemory::create"); + const QLatin1String function("QSharedMemory::create"); if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: key error").arg(function); diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp index f86318c9c9..9148ecf6fc 100644 --- a/src/corelib/tools/qcollator.cpp +++ b/src/corelib/tools/qcollator.cpp @@ -275,8 +275,8 @@ bool QCollator::ignorePunctuation() const /*! \fn int QCollator::compare(const QString &s1, const QString &s2) const - Compares \a s1 with \a s2. Returns -1, 0 or 1 depending on whether \a s1 is - smaller, equal or larger than \a s2. + Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero + depending on whether \a s1 is smaller, equal or larger than \a s2. */ /*! @@ -288,8 +288,8 @@ bool QCollator::ignorePunctuation() const \fn int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const \overload - Compares \a s1 with \a s2. Returns -1, 0 or 1 depending on whether \a s1 is - smaller, equal or larger than \a s2. + Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero + depending on whether \a s1 is smaller, equal or larger than \a s2. */ /*! @@ -299,8 +299,9 @@ bool QCollator::ignorePunctuation() const Compares \a s1 with \a s2. \a len1 and \a len2 specify the length of the QChar arrays pointer to by \a s1 and \a s2. - Returns -1, 0 or 1 depending on whether \a s1 is smaller, equal or larger than \a s2. - */ + Returns an integer less than, equal to, or greater than zero + depending on whether \a s1 is smaller, equal or larger than \a s2. +*/ /*! \fn QCollatorSortKey QCollator::sortKey(const QString &string) const diff --git a/src/corelib/tools/qcollator_posix.cpp b/src/corelib/tools/qcollator_posix.cpp index 0b755825b7..352ab0ba31 100644 --- a/src/corelib/tools/qcollator_posix.cpp +++ b/src/corelib/tools/qcollator_posix.cpp @@ -78,8 +78,7 @@ int QCollator::compare(const QString &s1, const QString &s2) const QVarLengthArray<wchar_t> array1, array2; stringToWCharArray(array1, s1); stringToWCharArray(array2, s2); - int result = std::wcscoll(array1.constData(), array2.constData()); - return result > 0 ? 1 : (result == 0 ? 0 : -1); + return std::wcscoll(array1.constData(), array2.constData()); } int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/tools/qunicodetables.cpp index 6a09abd80f..5f7eee947f 100644 --- a/src/corelib/tools/qunicodetables.cpp +++ b/src/corelib/tools/qunicodetables.cpp @@ -31,7 +31,7 @@ ** ****************************************************************************/ -/* This file is autogenerated from the Unicode 6.2 database. Do not edit */ +/* This file is autogenerated from the Unicode 6.3 database. Do not edit */ #include "qunicodetables_p.h" diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h index 4199724993..90340bb360 100644 --- a/src/corelib/tools/qunicodetables_p.h +++ b/src/corelib/tools/qunicodetables_p.h @@ -31,7 +31,7 @@ ** ****************************************************************************/ -/* This file is autogenerated from the Unicode 6.2 database. Do not edit */ +/* This file is autogenerated from the Unicode 6.3 database. Do not edit */ // // W A R N I N G @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE -#define UNICODE_DATA_VERSION QChar::Unicode_6_2 +#define UNICODE_DATA_VERSION QChar::Unicode_6_3 namespace QUnicodeTables { diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 54d97d8762..95cd0447d8 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -42,6 +42,9 @@ #include <string.h> #include <stdlib.h> #include <algorithm> +#ifdef Q_COMPILER_INITIALIZER_LISTS +#include <initializer_list> +#endif QT_BEGIN_NAMESPACE @@ -62,6 +65,14 @@ public: append(other.constData(), other.size()); } +#ifdef Q_COMPILER_INITIALIZER_LISTS + QVarLengthArray(std::initializer_list<T> args) + : a(Prealloc), s(0), ptr(reinterpret_cast<T *>(array)) + { + append(args.begin(), args.size()); + } +#endif + inline ~QVarLengthArray() { if (QTypeInfo<T>::isComplex) { T *i = ptr + s; @@ -457,11 +468,10 @@ bool operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, { if (l.size() != r.size()) return false; - for (int i = 0; i < l.size(); i++) { - if (l.at(i) != r.at(i)) - return false; - } - return true; + const T *rb = r.begin(); + const T *b = l.begin(); + const T *e = l.end(); + return std::equal(b, e, rb); } template <typename T, int Prealloc1, int Prealloc2> diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 6cc9f62c5a..d1b87f381e 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -100,6 +100,17 @@ \l{default-constructed value}. */ + +/*! \fn QVarLengthArray::QVarLengthArray(std::initializer_list<T> args) + \since 5.5 + + Constructs an array from the std::initializer_list given by \a args. + + This constructor is only enabled if the compiler supports C++11 initializer + lists. +*/ + + /*! \fn QVarLengthArray::~QVarLengthArray() Destroys the array. diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp index 1bfca44155..d10f82fbb4 100644 --- a/src/corelib/tools/qvector.cpp +++ b/src/corelib/tools/qvector.cpp @@ -229,7 +229,7 @@ /*! \fn QVector::QVector(std::initializer_list<T> args) \since 4.8 - Construct a vector from the std::initilizer_list given by \a args. + Constructs a vector from the std::initializer_list given by \a args. This constructor is only enabled if the compiler supports C++11 initializer lists. diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index c4c347d6ff..5de0c09a4d 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -161,23 +161,12 @@ contains(QT_CONFIG, zlib) { } contains(QT_CONFIG,icu) { + include($$PWD/../../3rdparty/icu_dependency.pri) + SOURCES += tools/qlocale_icu.cpp \ tools/qcollator_icu.cpp \ tools/qtimezoneprivate_icu.cpp DEFINES += QT_USE_ICU - win32 { - CONFIG(static, static|shared) { - CONFIG(debug, debug|release) { - LIBS_PRIVATE += -lsicuind -lsicuucd -lsicudtd - } else { - LIBS_PRIVATE += -lsicuin -lsicuuc -lsicudt - } - } else { - LIBS_PRIVATE += -licuin -licuuc -licudt - } - } else { - LIBS_PRIVATE += -licui18n -licuuc -licudata - } } else: win32 { SOURCES += tools/qcollator_win.cpp } else: macx { @@ -187,14 +176,10 @@ contains(QT_CONFIG,icu) { } !contains(QT_DISABLED_FEATURES, regularexpression) { + include($$PWD/../../3rdparty/pcre_dependency.pri) + HEADERS += tools/qregularexpression.h SOURCES += tools/qregularexpression.cpp - - pcre { - include($$PWD/../../3rdparty/pcre.pri) - } else { - LIBS_PRIVATE += -lpcre16 - } } INCLUDEPATH += ../3rdparty/harfbuzz/src |