diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qfeatures.h | 5 | ||||
-rw-r--r-- | src/corelib/global/qfeatures.txt | 7 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 22 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_win.cpp | 65 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths.cpp | 42 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_json.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_unix.cpp | 77 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_win.cpp | 6 | ||||
-rw-r--r-- | src/corelib/json/qjson.cpp | 8 | ||||
-rw-r--r-- | src/corelib/json/qjson_p.h | 21 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreevent.h | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 9 | ||||
-rw-r--r-- | src/corelib/mimetypes/qmimetype.cpp | 3 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 15 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_unix.cpp | 70 | ||||
-rw-r--r-- | src/corelib/tools/qsimd.cpp | 6 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 10 | ||||
-rw-r--r-- | src/corelib/tools/tools.pri | 1 |
20 files changed, 254 insertions, 128 deletions
diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index db7ff04bb2..15d5a9db66 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -602,6 +602,11 @@ #define QT_NO_DATAWIDGETMAPPER #endif +// QIdentityProxyModel +#if !defined(QT_NO_IDENTITYPROXYMODEL) && (defined(QT_NO_PROXYMODEL)) +#define QT_NO_IDENTITYPROXYMODEL +#endif + // QListWidget #if !defined(QT_NO_LISTWIDGET) && (defined(QT_NO_LISTVIEW)) #define QT_NO_LISTWIDGET diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 444a23b0e3..cc0594b62a 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -704,6 +704,13 @@ Requires: PROXYMODEL Name: QSortFilterProxyModel SeeAlso: ??? +Feature: IDENTITYPROXYMODEL +Description: Supports proxying a source model unmodified. +Section: ItemViews +Requires: PROXYMODEL +Name: QIdentityProxyModel +SeeAlso: ??? + Feature: STRINGLISTMODEL Description: Supports a model that supplies strings to views. Section: ItemViews diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index cb4e0e753f..801b4d94cd 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -217,14 +217,14 @@ QLibraryInfo::isDebugBuild() static const struct { char key[14], value[13]; } qtConfEntries[] = { - { "Prefix", "" }, + { "Prefix", "." }, { "Documentation", "doc" }, { "Headers", "include" }, { "Libraries", "lib" }, { "Binaries", "bin" }, { "Plugins", "plugins" }, { "Imports", "imports" }, - { "Data", "" }, + { "Data", "." }, { "Translations", "translations" }, { "Examples", "examples" }, { "Tests", "tests" }, @@ -232,7 +232,7 @@ static const struct { { "Sysroot", "" }, { "HostPrefix", "" }, { "HostBinaries", "bin" }, - { "HostData", "" }, + { "HostData", "." }, #endif }; @@ -295,6 +295,12 @@ QLibraryInfo::rawLocation(LibraryLocation loc) ret = config->value(key, defaultValue).toString(); +#ifdef QT_BUILD_QMAKE + if (ret.isEmpty() && loc == HostPrefixPath) + ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key), + QLatin1String(qtConfEntries[PrefixPath].value)).toString(); +#endif + // expand environment variables in the form $(ENVVAR) int rep; QRegExp reg_var(QLatin1String("\\$\\(.*\\)")); @@ -309,16 +315,14 @@ QLibraryInfo::rawLocation(LibraryLocation loc) } } - if (QDir::isRelativePath(ret)) { + if (!ret.isEmpty() && QDir::isRelativePath(ret)) { QString baseDir; #ifdef QT_BUILD_QMAKE - if (loc == HostPrefixPath || loc == PrefixPath) { - // We make the prefix path absolute to the executable's directory. + if (loc == HostPrefixPath || loc == PrefixPath || loc == SysrootPath) { + // We make the prefix/sysroot path absolute to the executable's directory. // loc == PrefixPath while a sysroot is set would make no sense here. + // loc == SysrootPath only makes sense if qmake lives inside the sysroot itself. baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); - } else if (loc == SysrootPath) { - // The sysroot is bare - return ret; } else if (loc > SysrootPath && loc <= LastHostPath) { // We make any other host path absolute to the host prefix directory. baseDir = rawLocation(HostPrefixPath); diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 8cbd4528dc..fedc5eb9ec 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -717,10 +717,10 @@ void qt_message_output(QtMsgType msgType, const QMessageLogContext &context, con int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW); _CrtSetReportMode(_CRT_ERROR, reportMode); #if !defined(Q_OS_WINCE) - int ret = _CrtDbgReport(_CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, buf); + int ret = _CrtDbgReport(_CRT_ERROR, context.file, context.line, QT_VERSION_STR, buf); #else - int ret = _CrtDbgReportW(_CRT_ERROR, _CRT_WIDE(__FILE__), - __LINE__, _CRT_WIDE(QT_VERSION_STR), + int ret = _CrtDbgReportW(_CRT_ERROR, _CRT_WIDE(context.file), + context.line, _CRT_WIDE(QT_VERSION_STR), reinterpret_cast<const wchar_t *> ( QString::fromLatin1(buf).utf16())); #endif diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 715e16bc7e..9b5b188475 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -56,6 +56,13 @@ QT_BEGIN_NAMESPACE +// #define WINQFSW_DEBUG +#ifdef WINQFSW_DEBUG +# define DEBUG qDebug +#else +# define DEBUG if (false) qDebug +#endif + QWindowsFileSystemWatcherEngine::Handle::Handle() : handle(INVALID_HANDLE_VALUE), flags(0u) { @@ -74,7 +81,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, QStringList *files, QStringList *directories) { - // qDebug()<<"Adding"<<paths.count()<<"to existing"<<(files->count() + directories->count())<<"watchers"; + DEBUG() << "Adding" << paths.count() << "to existing" << (files->count() + directories->count()) << "watchers"; QStringList p = paths; QMutableListIterator<QString> it(p); while (it.hasNext()) { @@ -101,7 +108,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, continue; } - // qDebug()<<"Looking for a thread/handle for"<<normalPath; + DEBUG() << "Looking for a thread/handle for" << normalPath; const QString absolutePath = isDir ? fileInfo.absoluteFilePath() : fileInfo.absolutePath(); const uint flags = isDir @@ -132,7 +139,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, handle = thread->handleForDir.value(absolutePath); if (handle.handle != INVALID_HANDLE_VALUE && handle.flags == flags) { // found a thread now insert... - // qDebug()<<" Found a thread"<<thread; + DEBUG() << "Found a thread" << thread; QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h = thread->pathInfoForHandle[handle.handle]; @@ -151,7 +158,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, // no thread found, first create a handle if (handle.handle == INVALID_HANDLE_VALUE || handle.flags != flags) { - // qDebug()<<" No thread found"; + DEBUG() << "No thread found"; // Volume and folder paths need a trailing slash for proper notification // (e.g. "c:" -> "c:/"). const QString effectiveAbsolutePath = @@ -167,8 +174,8 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, foreach(QWindowsFileSystemWatcherEngineThread *thread, threads) { QMutexLocker(&(thread->mutex)); if (thread->handles.count() < MAXIMUM_WAIT_OBJECTS) { - // qDebug() << " Added handle" << handle.handle << "for" << absolutePath << "to watch" << fileInfo.absoluteFilePath(); - // qDebug()<< " to existing thread"<<thread; + DEBUG() << "Added handle" << handle.handle << "for" << absolutePath << "to watch" << fileInfo.absoluteFilePath() + << "to existing thread " << thread; thread->handles.append(handle.handle); thread->handleForDir.insert(absolutePath, handle); @@ -186,7 +193,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, } if (!found) { QWindowsFileSystemWatcherEngineThread *thread = new QWindowsFileSystemWatcherEngineThread(); - //qDebug()<<" ###Creating new thread"<<thread<<"("<<(threads.count()+1)<<"threads)"; + DEBUG() << " ###Creating new thread" << thread << "(" << (threads.count()+1) << "threads)"; thread->handles.append(handle.handle); thread->handleForDir.insert(absolutePath, handle); @@ -215,7 +222,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path QStringList *files, QStringList *directories) { - // qDebug()<<"removePaths"<<paths; + DEBUG() << "removePaths" << paths; QStringList p = paths; QMutableListIterator<QString> it(p); while (it.hasNext()) { @@ -224,7 +231,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path if (normalPath.endsWith(QLatin1Char('/')) || normalPath.endsWith(QLatin1Char('\\'))) normalPath.chop(1); QFileInfo fileInfo(normalPath.toLower()); - // qDebug()<<"removing"<<normalPath; + DEBUG() << "removing" << normalPath; QString absolutePath = fileInfo.absoluteFilePath(); QList<QWindowsFileSystemWatcherEngineThread *>::iterator jt, end; end = threads.end(); @@ -250,7 +257,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path directories->removeAll(path); if (h.isEmpty()) { - // qDebug() << "Closing handle" << handle.handle; + DEBUG() << "Closing handle" << handle.handle; FindCloseChangeNotification(handle.handle); // This one might generate a notification int indexOfHandle = thread->handles.indexOf(handle.handle); @@ -263,7 +270,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path it.remove(); if (thread->handleForDir.isEmpty()) { - // qDebug()<<"Stopping thread "<<thread; + DEBUG() << "Stopping thread " << thread; locker.unlock(); thread->stop(); thread->wait(); @@ -336,7 +343,7 @@ void QWindowsFileSystemWatcherEngineThread::run() forever { QVector<HANDLE> handlesCopy = handles; locker.unlock(); - // qDebug() << "QWindowsFileSystemWatcherThread"<<this<<"waiting on" << handlesCopy.count() << "handles"; + DEBUG() << "QWindowsFileSystemWatcherThread" << this << "waiting on" << handlesCopy.count() << "handles"; DWORD r = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, INFINITE); locker.relock(); do { @@ -344,12 +351,11 @@ void QWindowsFileSystemWatcherEngineThread::run() int m = msg; msg = 0; if (m == 'q') { - // qDebug() << "thread"<<this<<"told to quit"; + DEBUG() << "thread" << this << "told to quit"; return; } - if (m != '@') { - qDebug("QWindowsFileSystemWatcherEngine: unknown message '%c' send to thread", char(m)); - } + if (m != '@') + DEBUG() << "QWindowsFileSystemWatcherEngine: unknown message sent to thread: " << char(m); break; } else if (r > WAIT_OBJECT_0 && r < WAIT_OBJECT_0 + uint(handlesCopy.count())) { int at = r - WAIT_OBJECT_0; @@ -359,10 +365,20 @@ void QWindowsFileSystemWatcherEngineThread::run() // When removing a path, FindCloseChangeNotification might actually fire a notification // for some reason, so we must check if the handle exist in the handles vector if (handles.contains(handle)) { - // qDebug()<<"thread"<<this<<"Acknowledged handle:"<<at<<handle; + DEBUG() << "thread" << this << "Acknowledged handle:" << at << handle; QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h = pathInfoForHandle[handle]; + bool fakeRemove = false; + if (!FindNextChangeNotification(handle)) { const DWORD error = GetLastError(); + + if (error == ERROR_ACCESS_DENIED) { + // for directories, our object's handle appears to be woken up when the target of a + // watch is deleted, before the watched thing is actually deleted... + // anyway.. we're given an error code of ERROR_ACCESS_DENIED in that case. + fakeRemove = true; + } + qErrnoWarning(error, "%s", qPrintable(msgFindNextFailed(h))); } QMutableHashIterator<QString, QWindowsFileSystemWatcherEngine::PathInfo> it(h); @@ -370,9 +386,12 @@ void QWindowsFileSystemWatcherEngineThread::run() QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo>::iterator x = it.next(); QString absolutePath = x.value().absolutePath; QFileInfo fileInfo(x.value().path); - // qDebug() << "checking" << x.key(); - if (!fileInfo.exists()) { - // qDebug() << x.key() << "removed!"; + DEBUG() << "checking" << x.key(); + + // i'm not completely sure the fileInfo.exist() check will ever work... see QTBUG-2331 + // ..however, I'm not completely sure enough to remove it. + if (fakeRemove || !fileInfo.exists()) { + DEBUG() << x.key() << "removed!"; if (x.value().isDir) emit directoryChanged(x.value().path, true); else @@ -381,7 +400,7 @@ void QWindowsFileSystemWatcherEngineThread::run() // close the notification handle if the directory has been removed if (h.isEmpty()) { - // qDebug() << "Thread closing handle" << handle; + DEBUG() << "Thread closing handle" << handle; FindCloseChangeNotification(handle); // This one might generate a notification int indexOfHandle = handles.indexOf(handle); @@ -392,11 +411,11 @@ void QWindowsFileSystemWatcherEngineThread::run() // h is now invalid } } else if (x.value().isDir) { - // qDebug() << x.key() << "directory changed!"; + DEBUG() << x.key() << "directory changed!"; emit directoryChanged(x.value().path, false); x.value() = fileInfo; } else if (x.value() != fileInfo) { - // qDebug() << x.key() << "file changed!"; + DEBUG() << x.key() << "file changed!"; emit fileChanged(x.value().path, false); x.value() = fileInfo; } diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 78bf6c7b96..55f824cdeb 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -267,6 +267,48 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr an empty QString if no relevant location can be found. */ +#ifndef Q_OS_MAC +QString QStandardPaths::displayName(StandardLocation type) +{ + switch (type) { + case DesktopLocation: + return QCoreApplication::translate("QStandardPaths", "Desktop"); + case DocumentsLocation: + return QCoreApplication::translate("QStandardPaths", "Documents"); + case FontsLocation: + return QCoreApplication::translate("QStandardPaths", "Fonts"); + case ApplicationsLocation: + return QCoreApplication::translate("QStandardPaths", "Applications"); + case MusicLocation: + return QCoreApplication::translate("QStandardPaths", "Music"); + case MoviesLocation: + return QCoreApplication::translate("QStandardPaths", "Movies"); + case PicturesLocation: + return QCoreApplication::translate("QStandardPaths", "Pictures"); + case TempLocation: + return QCoreApplication::translate("QStandardPaths", "Temporary Directory"); + case HomeLocation: + return QCoreApplication::translate("QStandardPaths", "Home"); + case DataLocation: + return QCoreApplication::translate("QStandardPaths", "Application Data"); + case CacheLocation: + return QCoreApplication::translate("QStandardPaths", "Cache"); + case GenericDataLocation: + return QCoreApplication::translate("QStandardPaths", "Shared Data"); + case RuntimeLocation: + return QCoreApplication::translate("QStandardPaths", "Runtime"); + case ConfigLocation: + return QCoreApplication::translate("QStandardPaths", "Configuration"); + case GenericCacheLocation: + return QCoreApplication::translate("QStandardPaths", "Shared Cache"); + case DownloadLocation: + return QCoreApplication::translate("QStandardPaths", "Download"); + } + // not reached + return QString(); +} +#endif + QT_END_NAMESPACE #endif // QT_NO_STANDARDPATHS diff --git a/src/corelib/io/qstandardpaths_json.cpp b/src/corelib/io/qstandardpaths_json.cpp index 52b194bea8..7d7a0a9f28 100644 --- a/src/corelib/io/qstandardpaths_json.cpp +++ b/src/corelib/io/qstandardpaths_json.cpp @@ -173,12 +173,6 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) return dirs; } -QString QStandardPaths::displayName(StandardLocation type) -{ - Q_UNUSED(type); - return QString(); -} - QT_END_NAMESPACE #endif // QT_NO_STANDARDPATHS diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 5499751751..1a2ae96edb 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -53,6 +53,16 @@ QT_BEGIN_NAMESPACE +static void appendOrganizationAndApp(QString &path) +{ + const QString org = QCoreApplication::organizationName(); + if (!org.isEmpty()) + path += QLatin1Char('/') + org; + const QString appName = QCoreApplication::applicationName(); + if (!appName.isEmpty()) + path += QLatin1Char('/') + appName; +} + QString QStandardPaths::writableLocation(StandardLocation type) { switch (type) { @@ -67,12 +77,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME")); if (xdgCacheHome.isEmpty()) xdgCacheHome = QDir::homePath() + QLatin1String("/.cache"); - if (type == QStandardPaths::CacheLocation) { - if (!QCoreApplication::organizationName().isEmpty()) - xdgCacheHome += QLatin1Char('/') + QCoreApplication::organizationName(); - if (!QCoreApplication::applicationName().isEmpty()) - xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName(); - } + if (type == QStandardPaths::CacheLocation) + appendOrganizationAndApp(xdgCacheHome); return xdgCacheHome; } case DataLocation: @@ -81,12 +87,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); if (xdgDataHome.isEmpty()) xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); - if (type == QStandardPaths::DataLocation) { - if (!QCoreApplication::organizationName().isEmpty()) - xdgDataHome += QLatin1Char('/') + QCoreApplication::organizationName(); - if (!QCoreApplication::applicationName().isEmpty()) - xdgDataHome += QLatin1Char('/') + QCoreApplication::applicationName(); - } + if (type == QStandardPaths::DataLocation) + appendOrganizationAndApp(xdgDataHome); return xdgDataHome; } case ConfigLocation: @@ -229,36 +231,55 @@ QString QStandardPaths::writableLocation(StandardLocation type) return path; } +static QStringList xdgDataDirs() +{ + QStringList dirs; + // http://standards.freedesktop.org/basedir-spec/latest/ + QString xdgDataDirsEnv = QFile::decodeName(qgetenv("XDG_DATA_DIRS")); + if (xdgDataDirsEnv.isEmpty()) { + dirs.append(QString::fromLatin1("/usr/local/share")); + dirs.append(QString::fromLatin1("/usr/share")); + } else { + dirs = xdgDataDirsEnv.split(QLatin1Char(':')); + } + return dirs; +} + QStringList QStandardPaths::standardLocations(StandardLocation type) { QStringList dirs; - if (type == ConfigLocation) { + switch (type) { + case ConfigLocation: + { // http://standards.freedesktop.org/basedir-spec/latest/ - QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_CONFIG_DIRS")); + const QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_CONFIG_DIRS")); if (xdgConfigDirs.isEmpty()) dirs.append(QString::fromLatin1("/etc/xdg")); else dirs = xdgConfigDirs.split(QLatin1Char(':')); - } else if (type == GenericDataLocation) { - // http://standards.freedesktop.org/basedir-spec/latest/ - QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_DATA_DIRS")); - if (xdgConfigDirs.isEmpty()) { - dirs.append(QString::fromLatin1("/usr/local/share")); - dirs.append(QString::fromLatin1("/usr/share")); - } else - dirs = xdgConfigDirs.split(QLatin1Char(':')); + } + break; + case GenericDataLocation: + dirs = xdgDataDirs(); + break; + case ApplicationsLocation: + dirs = xdgDataDirs(); + for (int i = 0; i < dirs.count(); ++i) + dirs[i].append(QLatin1String("/applications")); + break; + case DataLocation: + dirs = xdgDataDirs(); + for (int i = 0; i < dirs.count(); ++i) + appendOrganizationAndApp(dirs[i]); + break; + default: + break; } const QString localDir = writableLocation(type); dirs.prepend(localDir); return dirs; } -QString QStandardPaths::displayName(StandardLocation type) -{ - Q_UNUSED(type); - return QString(); -} - QT_END_NAMESPACE #endif // QT_NO_STANDARDPATHS diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index 848dd448eb..8bd32eb1d4 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -206,12 +206,6 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) return dirs; } -QString QStandardPaths::displayName(StandardLocation type) -{ - Q_UNUSED(type); - return QString(); -} - QT_END_NAMESPACE #endif // QT_NO_STANDARDPATHS diff --git a/src/corelib/json/qjson.cpp b/src/corelib/json/qjson.cpp index 4f7372a6c0..26f26b211e 100644 --- a/src/corelib/json/qjson.cpp +++ b/src/corelib/json/qjson.cpp @@ -241,14 +241,6 @@ bool Entry::operator ==(const QString &key) const return (shallowKey() == key); } -bool Entry::operator >=(const QString &key) const -{ - if (value.latinKey) - return (shallowLatin1Key() >= key); - else - return (shallowKey() >= key); -} - bool Entry::operator ==(const Entry &other) const { if (value.latinKey) { diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h index 0742ced39b..f8f41c2e25 100644 --- a/src/corelib/json/qjson_p.h +++ b/src/corelib/json/qjson_p.h @@ -620,15 +620,24 @@ public: bool operator ==(const QString &key) const; inline bool operator !=(const QString &key) const { return !operator ==(key); } - bool operator >=(const QString &key) const; + inline bool operator >=(const QString &key) const; bool operator ==(const Entry &other) const; bool operator >=(const Entry &other) const; }; +inline bool Entry::operator >=(const QString &key) const +{ + if (value.latinKey) + return (shallowLatin1Key() >= key); + else + return (shallowKey() >= key); +} + inline bool operator <(const QString &key, const Entry &e) { return e >= key; } + class Header { public: qle_uint tag; // 'qbjs' @@ -735,7 +744,15 @@ public: Data *clone(Base *b, int reserve = 0) { - int size = sizeof(Header) + b->size + reserve; + int size = sizeof(Header) + b->size; + if (ref.load() == 1 && alloc >= size + reserve) + return this; + + if (reserve) { + if (reserve < 128) + reserve = 128; + size = qMax(size + reserve, size *2); + } char *raw = (char *)malloc(size); Q_CHECK_PTR(raw); memcpy(raw + sizeof(Header), b, b->size); diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index a207849604..50ab500d13 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -75,6 +75,7 @@ public: KeyRelease = 7, // key released FocusIn = 8, // keyboard focus received FocusOut = 9, // keyboard focus lost + FocusAboutToChange = 23, // keyboard focus is about to be lost Enter = 10, // mouse enters widget Leave = 11, // mouse leaves widget Paint = 12, // paint widget diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index ae4449e559..e41a7cf92e 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4091,6 +4091,8 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa { if (!sender || !signal || !slotObj || !senderMetaObject) { qWarning("QObject::connect: invalid null parametter"); + if (slotObj && !slotObj->ref.deref()) + delete slotObj; return QMetaObject::Connection(); } int signal_index = -1; @@ -4098,6 +4100,8 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args); if (signal_index < 0 || signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount) { qWarning("QObject::connect: signal not found in %s", senderMetaObject->className()); + if (!slotObj->ref.deref()) + delete slotObj; return QMetaObject::Connection(0); } int signalOffset, methodOffset; @@ -4117,8 +4121,11 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa (*connectionLists)[signal_index].first; while (c2) { - if (c2->receiver == receiver && c2->isSlotObject && c2->slotObj->compare(slot)) + if (c2->receiver == receiver && c2->isSlotObject && c2->slotObj->compare(slot)) { + if (!slotObj->ref.deref()) + delete slotObj; return QMetaObject::Connection(); + } c2 = c2->nextConnectionList; } } diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index 18ce5e5000..ea10cbe70a 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -282,7 +282,8 @@ QString QMimeType::comment() const QStringList languageList; languageList << QLocale::system().name(); languageList << QLocale::system().uiLanguages(); - Q_FOREACH (const QString &lang, languageList) { + Q_FOREACH (const QString &language, languageList) { + const QString lang = language == QLatin1String("C") ? QLatin1String("en_US") : language; const QString comm = d->localeComments.value(lang); if (!comm.isEmpty()) return comm; diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 086ca7bd38..e40917c5d8 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -46,13 +46,6 @@ #include "qglobal.h" -#ifndef QT_NO_SYSTEMLOCALE -QT_BEGIN_NAMESPACE -class QSystemLocale; -static QSystemLocale *QSystemLocale_globalSystemLocale(); -QT_END_NAMESPACE -#endif - #include "qplatformdefs.h" #include "qdatastream.h" @@ -78,7 +71,13 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_SYSTEMLOCALE static QSystemLocale *_systemLocale = 0; -Q_GLOBAL_STATIC_WITH_ARGS(QSystemLocale, QSystemLocale_globalSystemLocale, (true)) +class QSystemLocaleSingleton: public QSystemLocale +{ +public: + QSystemLocaleSingleton() : QSystemLocale(true) {} +}; + +Q_GLOBAL_STATIC(QSystemLocaleSingleton, QSystemLocale_globalSystemLocale) static QLocalePrivate *system_lp = 0; Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate) #endif diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index ad7c9706c4..377a60881f 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -122,7 +122,7 @@ public: private: QSystemLocale(bool); - friend QSystemLocale *QSystemLocale_globalSystemLocale(); + friend class QSystemLocaleSingleton; }; #endif diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp index f2876912b4..e88c511ae9 100644 --- a/src/corelib/tools/qlocale_unix.cpp +++ b/src/corelib/tools/qlocale_unix.cpp @@ -45,6 +45,7 @@ #include "qdatetime.h" #include "qstringlist.h" #include "qvariant.h" +#include "qreadwritelock.h" QT_BEGIN_NAMESPACE @@ -57,29 +58,13 @@ struct QSystemLocaleData ,lc_monetary(QLocale::C) ,lc_messages(QLocale::C) { - QByteArray all = qgetenv("LC_ALL"); - QByteArray numeric = all.isEmpty() ? qgetenv("LC_NUMERIC") : all; - QByteArray time = all.isEmpty() ? qgetenv("LC_TIME") : all; - QByteArray monetary = all.isEmpty() ? qgetenv("LC_MONETARY") : all; - lc_messages_var = all.isEmpty() ? qgetenv("LC_MESSAGES") : all; - lc_measurement_var = all.isEmpty() ? qgetenv("LC_MEASUREMENT") : all; - QByteArray lang = qgetenv("LANG"); - if (lang.isEmpty()) - lang = QByteArray("C"); - if (numeric.isEmpty()) - numeric = lang; - if (monetary.isEmpty()) - monetary = lang; - if (lc_messages_var.isEmpty()) - lc_messages_var = lang; - if (lc_measurement_var.isEmpty()) - lc_measurement_var = lang; - lc_numeric = QLocale(QString::fromLatin1(numeric)); - lc_time = QLocale(QString::fromLatin1(time)); - lc_monetary = QLocale(QString::fromLatin1(monetary)); - lc_messages = QLocale(QString::fromLatin1(lc_messages_var)); + readEnvironment(); } + void readEnvironment(); + + QReadWriteLock lock; + QLocale lc_numeric; QLocale lc_time; QLocale lc_monetary; @@ -87,10 +72,43 @@ struct QSystemLocaleData QByteArray lc_messages_var; QByteArray lc_measurement_var; }; + +void QSystemLocaleData::readEnvironment() +{ + QWriteLocker locker(&lock); + + QByteArray all = qgetenv("LC_ALL"); + QByteArray numeric = all.isEmpty() ? qgetenv("LC_NUMERIC") : all; + QByteArray time = all.isEmpty() ? qgetenv("LC_TIME") : all; + QByteArray monetary = all.isEmpty() ? qgetenv("LC_MONETARY") : all; + lc_messages_var = all.isEmpty() ? qgetenv("LC_MESSAGES") : all; + lc_measurement_var = all.isEmpty() ? qgetenv("LC_MEASUREMENT") : all; + QByteArray lang = qgetenv("LANG"); + if (lang.isEmpty()) + lang = QByteArray("C"); + if (numeric.isEmpty()) + numeric = lang; + if (time.isEmpty()) + time = lang; + if (monetary.isEmpty()) + monetary = lang; + if (lc_messages_var.isEmpty()) + lc_messages_var = lang; + if (lc_measurement_var.isEmpty()) + lc_measurement_var = lang; + lc_numeric = QLocale(QString::fromLatin1(numeric)); + lc_time = QLocale(QString::fromLatin1(time)); + lc_monetary = QLocale(QString::fromLatin1(monetary)); + lc_messages = QLocale(QString::fromLatin1(lc_messages_var)); +} + + Q_GLOBAL_STATIC(QSystemLocaleData, qSystemLocaleData) + #endif #ifndef QT_NO_SYSTEMLOCALE + QLocale QSystemLocale::fallbackLocale() const { QByteArray lang = qgetenv("LC_ALL"); @@ -104,6 +122,14 @@ QLocale QSystemLocale::fallbackLocale() const QVariant QSystemLocale::query(QueryType type, QVariant in) const { QSystemLocaleData *d = qSystemLocaleData(); + + if (type == LocaleChanged) { + d->readEnvironment(); + return QVariant(); + } + + QReadLocker locker(&d->lock); + const QLocale &lc_numeric = d->lc_numeric; const QLocale &lc_time = d->lc_time; const QLocale &lc_monetary = d->lc_monetary; @@ -216,6 +242,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const return lc_messages.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation); case ListToSeparatedString: return lc_messages.createSeparatedList(in.value<QStringList>()); + case LocaleChanged: + Q_ASSERT(false); default: break; } diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 6c07480f99..a74a140582 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -320,12 +320,6 @@ static inline uint detectProcessorFeatures() return features; } -#elif defined(__ia64__) -static inline uint detectProcessorFeatures() -{ - return MMX|SSE|SSE2; -} - #else static inline uint detectProcessorFeatures() { diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index cf09e2b5dc..bb66fdbdec 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -122,11 +122,11 @@ static inline int qt_find_latin1_string(const QChar *hay, int size, const QLatin static inline bool qt_starts_with(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs); static inline bool qt_starts_with(const QChar *haystack, int haystackLen, - const QLatin1String &needle, Qt::CaseSensitivity cs); + QLatin1String needle, Qt::CaseSensitivity cs); static inline bool qt_ends_with(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs); static inline bool qt_ends_with(const QChar *haystack, int haystackLen, - const QLatin1String &needle, Qt::CaseSensitivity cs); + QLatin1String needle, Qt::CaseSensitivity cs); // Unicode case-insensitive comparison static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be) @@ -2753,7 +2753,7 @@ int QString::lastIndexOf(const QLatin1String &str, int from, Qt::CaseSensitivity int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { return qt_last_index_of(unicode(), size(), ch, from, cs); - } +} /*! \since 4.8 @@ -8988,7 +8988,7 @@ static inline bool qt_starts_with(const QChar *haystack, int haystackLen, } static inline bool qt_starts_with(const QChar *haystack, int haystackLen, - const QLatin1String &needle, Qt::CaseSensitivity cs) + QLatin1String needle, Qt::CaseSensitivity cs) { if (!haystack) return !needle.latin1(); @@ -9039,7 +9039,7 @@ static inline bool qt_ends_with(const QChar *haystack, int haystackLen, static inline bool qt_ends_with(const QChar *haystack, int haystackLen, - const QLatin1String &needle, Qt::CaseSensitivity cs) + QLatin1String needle, Qt::CaseSensitivity cs) { if (!haystack) return !needle.latin1(); diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index ac347404fd..ec02454c67 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -29,6 +29,7 @@ HEADERS += \ tools/qmargins.h \ tools/qcontiguouscache.h \ tools/qpodlist_p.h \ + tools/qpair.h \ tools/qpoint.h \ tools/qqueue.h \ tools/qrect.h \ |