diff options
author | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-03-03 13:37:38 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-03-03 13:37:38 +0100 |
commit | c0a5e8c9d77aefd6c403af39908e56414a921522 (patch) | |
tree | c07b28deb9abc9789386f1b10585f1c661bfcba5 /src/corelib | |
parent | 4fd8513475222ee0afb6f18ec90ba384ffb03bc4 (diff) | |
parent | 2b5982aac8ad103443e33379fe5654f5bd419c87 (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
src/plugins/platforms/xcb/qxcbscreen.cpp
Change-Id: Ie42931791a849b34b63d814d2eb5ac653986d868
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/codecs/qsimplecodec.cpp | 2 | ||||
-rw-r--r-- | src/corelib/doc/src/containers.qdoc | 2 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 89 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qdebug.cpp | 16 | ||||
-rw-r--r-- | src/corelib/io/qdebug.h | 14 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 2 | ||||
-rw-r--r-- | src/corelib/itemmodels/qitemselectionmodel.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 9 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qsharedmemory_posix.cpp | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qsharedmemory_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qsystemsemaphore_posix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qsystemsemaphore_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 4 | ||||
-rw-r--r-- | src/corelib/plugin/qplugin.qdoc | 2 | ||||
-rw-r--r-- | src/corelib/plugin/qpluginloader.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_mac.mm | 13 | ||||
-rw-r--r-- | src/corelib/tools/qsimd.cpp | 4 |
19 files changed, 122 insertions, 54 deletions
diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp index c0c1d6d906..9defa3d015 100644 --- a/src/corelib/codecs/qsimplecodec.cpp +++ b/src/corelib/codecs/qsimplecodec.cpp @@ -507,7 +507,7 @@ static const struct { 0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF} }, - { "macintosh", { "Apple Roman", "MacRoman", 0 }, -168, + { "macintosh", { "Apple Roman", "MacRoman", 0 }, 2027, { 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8, 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3, diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index 58c7569964..1979c45e17 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -465,7 +465,7 @@ imaginary item one position past the last item in the container. \l {QList::end()}{end()} marks an invalid position; it must never be dereferenced. It is typically used in a loop's break condition. If the list is - empty, \l{QList::begin}{begin()} equals \l{QList:end()}{end()}, so we never execute the loop. + empty, \l{QList::begin}{begin()} equals \l{QList::end()}{end()}, so we never execute the loop. The diagram below shows the valid iterator positions as red arrows for a vector containing four items: diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 712e84185c..7913af3103 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2014 Intel Corporation +** Copyright (C) 2015 Intel Corporation ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -2120,10 +2120,10 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion() # define USE_ETC_OS_RELEASE struct QUnixOSVersion { - // from /etc/os-release - QString productType; // $ID - QString productVersion; // $VERSION_ID - QString prettyName; // $PRETTY_NAME + // from /etc/os-release older /etc/lsb-release + QString productType; // $ID $DISTRIB_ID + QString productVersion; // $VERSION_ID $DISTRIB_RELEASE + QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION }; static QString unquote(const char *begin, const char *end) @@ -2135,10 +2135,11 @@ static QString unquote(const char *begin, const char *end) return QString::fromLatin1(begin, end - begin); } -static bool readEtcOsRelease(QUnixOSVersion &v) +static bool readEtcFile(QUnixOSVersion &v, const char *filename, + const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey) { // we're avoiding QFile here - int fd = qt_safe_open("/etc/os-release", O_RDONLY); + int fd = qt_safe_open(filename, O_RDONLY); if (fd == -1) return false; @@ -2155,41 +2156,28 @@ static bool readEtcOsRelease(QUnixOSVersion &v) const char *ptr = buffer.constData(); const char *end = buffer.constEnd(); const char *eol; + QByteArray line; for ( ; ptr != end; ptr = eol + 1) { - static const char idString[] = "ID="; - static const char prettyNameString[] = "PRETTY_NAME="; - static const char versionIdString[] = "VERSION_ID="; - // find the end of the line after ptr eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr)); if (!eol) eol = end - 1; + line.setRawData(ptr, eol - ptr); - // note: we're doing a binary search here, so comparison - // must always be sorted - int cmp = strncmp(ptr, idString, strlen(idString)); - if (cmp < 0) - continue; - if (cmp == 0) { - ptr += strlen(idString); + if (line.startsWith(idKey)) { + ptr += idKey.length(); v.productType = unquote(ptr, eol); continue; } - cmp = strncmp(ptr, prettyNameString, strlen(prettyNameString)); - if (cmp < 0) - continue; - if (cmp == 0) { - ptr += strlen(prettyNameString); + if (line.startsWith(prettyNameKey)) { + ptr += prettyNameKey.length(); v.prettyName = unquote(ptr, eol); continue; } - cmp = strncmp(ptr, versionIdString, strlen(versionIdString)); - if (cmp < 0) - continue; - if (cmp == 0) { - ptr += strlen(versionIdString); + if (line.startsWith(versionKey)) { + ptr += versionKey.length(); v.productVersion = unquote(ptr, eol); continue; } @@ -2197,6 +2185,45 @@ static bool readEtcOsRelease(QUnixOSVersion &v) return true; } + +static bool readEtcOsRelease(QUnixOSVersion &v) +{ + return readEtcFile(v, "/etc/os-release", QByteArrayLiteral("ID="), + QByteArrayLiteral("VERSION_ID="), QByteArrayLiteral("PRETTY_NAME=")); +} + +static bool readEtcLsbRelease(QUnixOSVersion &v) +{ + bool ok = readEtcFile(v, "/etc/lsb-release", QByteArrayLiteral("DISTRIB_ID="), + QByteArrayLiteral("DISTRIB_RELEASE="), QByteArrayLiteral("DISTRIB_DESCRIPTION=")); + if (ok && (v.prettyName.isEmpty() || v.prettyName == v.productType)) { + // some distributions have redundant information for the pretty name, + // so try /etc/<lowercasename>-release + + // we're still avoiding QFile here + QByteArray distrorelease = "/etc/" + v.productType.toLatin1().toLower() + "-release"; + int fd = qt_safe_open(distrorelease, O_RDONLY); + if (fd != -1) { + QT_STATBUF sbuf; + if (QT_FSTAT(fd, &sbuf) != -1 && sbuf.st_size > v.prettyName.length()) { + // file apparently contains interesting information + QByteArray buffer(sbuf.st_size, Qt::Uninitialized); + buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size)); + v.prettyName = QString::fromLatin1(buffer.trimmed()); + } + qt_safe_close(fd); + } + } + + return ok; +} + +static bool findUnixOsVersion(QUnixOSVersion &v) +{ + if (readEtcOsRelease(v)) + return true; + return readEtcLsbRelease(v); +} # endif // USE_ETC_OS_RELEASE #endif // Q_OS_UNIX @@ -2531,7 +2558,7 @@ QString QSysInfo::productType() #elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX QUnixOSVersion unixOsVersion; - readEtcOsRelease(unixOsVersion); + findUnixOsVersion(unixOsVersion); if (!unixOsVersion.productType.isEmpty()) return unixOsVersion.productType; #endif @@ -2587,7 +2614,7 @@ QString QSysInfo::productVersion() } #elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX QUnixOSVersion unixOsVersion; - readEtcOsRelease(unixOsVersion); + findUnixOsVersion(unixOsVersion); if (!unixOsVersion.productVersion.isEmpty()) return unixOsVersion.productVersion; #endif @@ -2664,7 +2691,7 @@ QString QSysInfo::prettyProductName() #elif defined(Q_OS_UNIX) # ifdef USE_ETC_OS_RELEASE QUnixOSVersion unixOsVersion; - readEtcOsRelease(unixOsVersion); + findUnixOsVersion(unixOsVersion); if (!unixOsVersion.prettyName.isEmpty()) return unixOsVersion.prettyName; # endif diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 9211ce17e8..322fc2f651 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -230,7 +230,7 @@ QLibraryInfo::licensedProducts() /*! \since 4.6 \deprecated - This function used to return the the installation date for this build of Qt, but now returns an a constant date. + This function used to return the installation date for this build of Qt, but now returns a constant date. */ #ifndef QT_NO_DATESTRING #if QT_DEPRECATED_SINCE(5, 5) @@ -457,8 +457,10 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) defaultValue = QLatin1String(qtConfEntries[loc].value); } #ifndef Q_OS_WIN // On Windows we use the registry - else if (loc == SettingsPath) + else if (loc == SettingsPath) { key = QLatin1String("Settings"); + defaultValue = QLatin1String("."); + } #endif if(!key.isNull()) { diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index f55f68f9b3..357d63137c 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -661,6 +661,20 @@ QDebug qt_QMetaEnum_debugOperator(QDebug &dbg, int value, const QMetaObject *met dbg << ')'; return dbg; } -#endif + +QDebug qt_QMetaEnum_flagDebugOperator(QDebug &debug, quint64 value, const QMetaObject *meta, const char *name) +{ + QDebugStateSaver saver(debug); + debug.resetFormat(); + debug.noquote(); + debug.nospace(); + debug << "QFlags<"; + const QMetaEnum me = meta->enumerator(meta->indexOfEnumerator(name)); + if (const char *scope = me.scope()) + debug << scope << "::"; + debug << me.name() << ">(" << me.valueToKeys(value) << ')'; + return debug; +} +#endif // !QT_NO_QOBJECT QT_END_NAMESPACE diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 435e7450c7..7f1cb82f3a 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -263,6 +263,7 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache) #ifndef QT_NO_QOBJECT Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name); +Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name); template<typename T> typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type @@ -272,10 +273,21 @@ operator<<(QDebug dbg, T value) const char *name = qt_getEnumName(value); return qt_QMetaEnum_debugOperator(dbg, typename QFlags<T>::Int(value), obj, name); } -#endif template <class T> +inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags) +{ + const QMetaObject *obj = qt_getEnumMetaObject(T()); + const char *name = qt_getEnumName(T()); + return qt_QMetaEnum_flagDebugOperator(debug, quint64(flags), obj, name); +} + +template <class T> +inline typename QtPrivate::QEnableIf<!QtPrivate::IsQEnumHelper<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) +#endif { QDebugStateSaver saver(debug); debug.resetFormat(); diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index a1a00016fd..5b18a85dd4 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -544,7 +544,7 @@ bool QFSFileEngine::renameOverwrite(const QString &newName) bool ret = ::DeleteAndRenameFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(), (wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0; if (!ret) { - ret = ::DeleteFile((wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0; + ret = ::DeleteFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0; if (ret) ret = ::MoveFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(), (wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0; diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 7e23709f1b..3882da30a7 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -1200,7 +1200,7 @@ void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel:: \fn void QItemSelectionModel::modelChanged(QAbstractItemModel *model) \since 5.5 - This signal is emitted when the model is successfully set with setModel(). + This signal is emitted when the \a model is successfully set with setModel(). \sa model(), setModel() */ diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 4baf09167b..e89b914227 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2665,20 +2665,21 @@ QByteArray QMetaEnum::valueToKeys(int value) const int count = mobj->d.data[handle + 2]; int data = mobj->d.data[handle + 3]; int v = value; - for(int i = 0; i < count; i++) { + // reverse iterate to ensure values like Qt::Dialog=0x2|Qt::Window are processed first. + for (int i = count - 1; i >= 0; --i) { int k = mobj->d.data[data + 2*i + 1]; if ((k != 0 && (v & k) == k ) || (k == value)) { v = v & ~k; if (!keys.isEmpty()) - keys += '|'; - keys += stringData(mobj, mobj->d.data[data + 2*i]); + keys.prepend('|'); + keys.prepend(stringData(mobj, mobj->d.data[data + 2*i])); } } return keys; } /*! - \fn QMetaEnum QMetaEnum::fromType() const + \fn QMetaEnum QMetaEnum::fromType() \since 5.5 Returns the QMetaEnum corresponding to the type in the template parameter. diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 8adb4a4903..305e998818 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1117,7 +1117,7 @@ bool QMetaType::isRegistered(int type) } /*! - \fn int qMetaTypeTypeImpl(const char *typeName) + \fn int qMetaTypeTypeImpl(const char *typeName, int length) \internal Implementation of QMetaType::type(). diff --git a/src/corelib/kernel/qsharedmemory_posix.cpp b/src/corelib/kernel/qsharedmemory_posix.cpp index 4f9b3b1429..74f98a158a 100644 --- a/src/corelib/kernel/qsharedmemory_posix.cpp +++ b/src/corelib/kernel/qsharedmemory_posix.cpp @@ -46,7 +46,6 @@ #ifndef QT_NO_SHAREDMEMORY #include <sys/types.h> -#include <sys/ipc.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index 4f55e523e3..92184a619b 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -42,8 +42,8 @@ #ifndef QT_NO_SHAREDMEMORY #include <sys/types.h> -#include <sys/ipc.h> #ifndef QT_POSIX_IPC +#include <sys/ipc.h> #include <sys/shm.h> #else #include <sys/mman.h> diff --git a/src/corelib/kernel/qsystemsemaphore_posix.cpp b/src/corelib/kernel/qsystemsemaphore_posix.cpp index abe3cc7e8c..5a8e5941b7 100644 --- a/src/corelib/kernel/qsystemsemaphore_posix.cpp +++ b/src/corelib/kernel/qsystemsemaphore_posix.cpp @@ -45,8 +45,6 @@ #ifndef QT_NO_SYSTEMSEMAPHORE #include <sys/types.h> -#include <sys/ipc.h> -#include <sys/sem.h> #include <fcntl.h> #include <errno.h> diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp index cb34b8aeff..d1ec39ea40 100644 --- a/src/corelib/kernel/qsystemsemaphore_unix.cpp +++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp @@ -40,8 +40,8 @@ #ifndef QT_NO_SYSTEMSEMAPHORE #include <sys/types.h> -#include <sys/ipc.h> #ifndef QT_POSIX_IPC +#include <sys/ipc.h> #include <sys/sem.h> #endif #include <fcntl.h> diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 3dc0805dd1..b14c9ed167 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -460,7 +460,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) { QMetaEnum en = metaEnumFromType(d->type); if (en.isValid()) { - *str = QString::fromUtf8(en.valueToKeys(qConvertToNumber(d, ok))); + *str = QString::fromUtf8(en.valueToKey(qConvertToNumber(d, ok))); return *ok; } } @@ -637,7 +637,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) { QMetaEnum en = metaEnumFromType(d->type); if (en.isValid()) { - *ba = en.valueToKeys(qConvertToNumber(d, ok)); + *ba = en.valueToKey(qConvertToNumber(d, ok)); return *ok; } } diff --git a/src/corelib/plugin/qplugin.qdoc b/src/corelib/plugin/qplugin.qdoc index 35dd52218a..81be1df518 100644 --- a/src/corelib/plugin/qplugin.qdoc +++ b/src/corelib/plugin/qplugin.qdoc @@ -44,7 +44,7 @@ to the interface class called \a ClassName. The \a Identifier must be unique. For example: - \snippet plugins/interfaces.h 3 + \snippet code/doc_src_qplugin.cpp 0 This macro is normally used right after the class definition for \a ClassName, in a header file. See the diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index 2151108bb7..2800656c13 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -428,7 +428,7 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin plugin) /*! Returns a list of static plugin instances (root components) held by the plugin loader. - \sa staticPlugin() + \sa staticPlugins() */ QObjectList QPluginLoader::staticInstances() { diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm index b581e33aef..37a63a2ca4 100644 --- a/src/corelib/tools/qlocale_mac.mm +++ b/src/corelib/tools/qlocale_mac.mm @@ -44,6 +44,18 @@ QT_BEGIN_NAMESPACE +namespace { +class AutoReleasePool +{ +public: + AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {} + ~AutoReleasePool() { [pool release]; } + +private: + NSAutoreleasePool *pool; +}; +} + /****************************************************************************** ** Wrappers for Mac locale system functions */ @@ -414,6 +426,7 @@ QLocale QSystemLocale::fallbackUiLocale() const QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const { + AutoReleasePool pool; switch(type) { // case Name: // return getMacLocaleName(); diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index a031080fdb..52ffc161bf 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -512,7 +512,9 @@ int ffs(int i) #endif } #endif -#endif // Q_OS_WIN +#elif defined(Q_OS_ANDROID) +# define ffs __builtin_ffs +#endif QBasicAtomicInt qt_cpu_features = Q_BASIC_ATOMIC_INITIALIZER(0); |