summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-02 15:57:44 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-02 15:57:44 +0100
commitd3e6e732c70ebc2340d6376d727b3c623be23810 (patch)
tree18d469f02ac36edd04b87a9bfa4886ceef0490f0 /src/corelib
parentfdfd63053ae6b10af06553be3c1b15de274bebf7 (diff)
parentba8d3430029d8c4342e9a47c110ee8c9879818f4 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: config.tests/unix/compile.test src/plugins/platforms/cocoa/qcocoahelpers.mm src/tools/qlalr/cppgenerator.cpp Change-Id: I0103ca076a9aca7118b2fd99f0fdaf81055998c3
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qlibraryinfo.cpp2
-rw-r--r--src/corelib/io/io.pri6
-rw-r--r--src/corelib/io/qfile.cpp2
-rw-r--r--src/corelib/io/qprocess_wince.cpp3
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp258
-rw-r--r--src/corelib/json/qjsonobject.cpp14
-rw-r--r--src/corelib/json/qjsonobject.h4
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm148
-rw-r--r--src/corelib/kernel/qcore_mac_p.h5
-rw-r--r--src/corelib/kernel/qmetatype.cpp5
-rw-r--r--src/corelib/kernel/qtcore_eval.cpp4
-rw-r--r--src/corelib/statemachine/qfinalstate.cpp26
-rw-r--r--src/corelib/statemachine/qfinalstate.h4
-rw-r--r--src/corelib/statemachine/qfinalstate_p.h68
-rw-r--r--src/corelib/statemachine/qstate.cpp3
-rw-r--r--src/corelib/statemachine/qstate_p.h7
-rw-r--r--src/corelib/statemachine/statemachine.pri1
-rw-r--r--src/corelib/thread/qfutureinterface.cpp3
-rw-r--r--src/corelib/thread/qfutureinterface_p.h10
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp37
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h2
-rw-r--r--src/corelib/tools/qstringbuilder.h6
22 files changed, 441 insertions, 177 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index ce838622bc..7d558cbf81 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -653,7 +653,7 @@ extern "C" void qt_core_boilerplate();
void qt_core_boilerplate()
{
printf("This is the QtCore library version " QT_BUILD_STR "\n"
- "Copyright (C) 2015 The Qt Company Ltd.\n"
+ "Copyright (C) 2016 The Qt Company Ltd.\n"
"Contact: http://www.qt.io/licensing/\n"
"\n"
"Installation prefix: %s\n"
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 218fb5b078..1ae0485840 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -107,8 +107,6 @@ win32 {
!winrt {
SOURCES += io/qsettings_win.cpp
- HEADERS += io/qwindowspipewriter_p.h
- SOURCES += io/qwindowspipewriter.cpp
SOURCES += io/qstandardpaths_win.cpp
wince* {
@@ -117,11 +115,13 @@ win32 {
} else {
HEADERS += \
io/qwinoverlappedionotifier_p.h \
- io/qwindowspipereader_p.h
+ io/qwindowspipereader_p.h \
+ io/qwindowspipewriter_p.h
SOURCES += \
io/qprocess_win.cpp \
io/qwinoverlappedionotifier.cpp \
io/qwindowspipereader.cpp \
+ io/qwindowspipewriter.cpp \
io/qstorageinfo_win.cpp
LIBS += -lmpr
}
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 6ddabc2351..ccacb6ed20 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -753,7 +753,7 @@ QFile::copy(const QString &newName)
qWarning("QFile::copy: Empty or null file name");
return false;
}
- if (QFile(newName).exists()) {
+ if (QFile::exists(newName)) {
// ### Race condition. If a file is moved in after this, it /will/ be
// overwritten. On Unix, the proper solution is to use hardlinks:
// return ::link(old, new) && ::remove(old); See also rename().
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
index aef043fcaa..c859a740d5 100644
--- a/src/corelib/io/qprocess_wince.cpp
+++ b/src/corelib/io/qprocess_wince.cpp
@@ -39,7 +39,6 @@
#include "qprocess.h"
#include "qprocess_p.h"
-#include "qwindowspipewriter_p.h"
#include <qdir.h>
#include <qfileinfo.h>
@@ -162,7 +161,7 @@ void QProcessPrivate::startProcess()
}
// give the process a chance to start ...
- Sleep(SLEEPMIN * 2);
+ Sleep(20);
_q_startupNotification();
}
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 3961d56b63..9e3cb9ab4d 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -47,9 +47,7 @@
#include <qcoreapplication.h>
#endif
-#if !defined(Q_OS_WINCE)
const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b } };
-#endif
#include <qt_windows.h>
#include <shlobj.h>
@@ -70,113 +68,152 @@ const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x6
QT_BEGIN_NAMESPACE
-#if !defined(Q_OS_WINCE)
-typedef HRESULT (WINAPI *GetKnownFolderPath)(const GUID&, DWORD, HANDLE, LPWSTR*);
-#endif
-
static QString convertCharArray(const wchar_t *path)
{
return QDir::fromNativeSeparators(QString::fromWCharArray(path));
}
-static inline int clsidForAppDataLocation(QStandardPaths::StandardLocation type)
+static inline bool isGenericConfigLocation(QStandardPaths::StandardLocation type)
{
-#ifndef Q_OS_WINCE
- return type == QStandardPaths::AppDataLocation ?
- CSIDL_APPDATA : // "Roaming" path
- CSIDL_LOCAL_APPDATA; // Local path
-#else
- Q_UNUSED(type)
- return CSIDL_APPDATA;
-#endif
+ return type == QStandardPaths::GenericConfigLocation || type == QStandardPaths::GenericDataLocation;
}
-QString QStandardPaths::writableLocation(StandardLocation type)
+static inline bool isConfigLocation(QStandardPaths::StandardLocation type)
{
- QString result;
+ return type == QStandardPaths::ConfigLocation || type == QStandardPaths::AppConfigLocation
+ || type == QStandardPaths::AppDataLocation || type == QStandardPaths::AppLocalDataLocation
+ || isGenericConfigLocation(type);
+}
-#if !defined(Q_OS_WINCE)
- static GetKnownFolderPath SHGetKnownFolderPath = (GetKnownFolderPath)QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath");
+static void appendOrganizationAndApp(QString &path) // Courtesy qstandardpaths_unix.cpp
+{
+#ifndef QT_BOOTSTRAPPED
+ const QString &org = QCoreApplication::organizationName();
+ if (!org.isEmpty())
+ path += QLatin1Char('/') + org;
+ const QString &appName = QCoreApplication::applicationName();
+ if (!appName.isEmpty())
+ path += QLatin1Char('/') + appName;
+#else // !QT_BOOTSTRAPPED
+ Q_UNUSED(path)
#endif
+}
- wchar_t path[MAX_PATH];
-
- switch (type) {
- case ConfigLocation: // same as AppLocalDataLocation, on Windows
- case GenericConfigLocation: // same as GenericDataLocation on Windows
- case AppConfigLocation:
- case AppDataLocation:
- case AppLocalDataLocation:
- case GenericDataLocation:
- if (SHGetSpecialFolderPath(0, path, clsidForAppDataLocation(type), FALSE))
- result = convertCharArray(path);
- if (isTestModeEnabled())
- result += QLatin1String("/qttest");
+static inline QString displayName(QStandardPaths::StandardLocation type)
+{
#ifndef QT_BOOTSTRAPPED
- if (type != GenericDataLocation && type != GenericConfigLocation) {
- if (!QCoreApplication::organizationName().isEmpty())
- result += QLatin1Char('/') + QCoreApplication::organizationName();
- if (!QCoreApplication::applicationName().isEmpty())
- result += QLatin1Char('/') + QCoreApplication::applicationName();
- }
+ return QStandardPaths::displayName(type);
+#else
+ return QString::number(type);
#endif
- break;
+}
- case DesktopLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_DESKTOPDIRECTORY, FALSE))
- result = convertCharArray(path);
- break;
+static inline void appendTestMode(QString &path)
+{
+ if (QStandardPaths::isTestModeEnabled())
+ path += QLatin1String("/qttest");
+}
- case DownloadLocation:
-#if !defined(Q_OS_WINCE)
- if (SHGetKnownFolderPath) {
- LPWSTR path;
- if (SHGetKnownFolderPath(qCLSID_FOLDERID_Downloads, 0, 0, &path) == S_OK) {
- result = convertCharArray(path);
- CoTaskMemFree(path);
- }
- break;
+// Map QStandardPaths::StandardLocation to CLSID of SHGetSpecialFolderPath()
+static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
+{
+ static const int clsids[] = {
+ CSIDL_DESKTOPDIRECTORY, // DesktopLocation
+ CSIDL_PERSONAL, // DocumentsLocation
+ CSIDL_FONTS, // FontsLocation
+ CSIDL_PROGRAMS, // ApplicationsLocation
+ CSIDL_MYMUSIC, // MusicLocation
+ CSIDL_MYVIDEO, // MoviesLocation
+ CSIDL_MYPICTURES, // PicturesLocation
+ -1, -1, // TempLocation/HomeLocation
+ CSIDL_LOCAL_APPDATA, // AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation
+ -1, // CacheLocation
+ CSIDL_LOCAL_APPDATA, // GenericDataLocation ("Local" path)
+ -1, // RuntimeLocation
+ CSIDL_LOCAL_APPDATA, // ConfigLocation ("Local" path)
+ -1, -1, // DownloadLocation/GenericCacheLocation
+ CSIDL_LOCAL_APPDATA, // GenericConfigLocation ("Local" path)
+ CSIDL_APPDATA, // AppDataLocation ("Roaming" path)
+ CSIDL_LOCAL_APPDATA, // AppConfigLocation ("Local" path)
+ };
+
+ Q_STATIC_ASSERT(sizeof(clsids) / sizeof(clsids[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
+ return size_t(type) < sizeof(clsids) / sizeof(clsids[0]) ? clsids[type] : -1;
+};
+
+// Convenience for SHGetSpecialFolderPath().
+static QString sHGetSpecialFolderPath(int clsid, QStandardPaths::StandardLocation type, bool warn = false)
+{
+ QString result;
+ wchar_t path[MAX_PATH];
+ if (Q_LIKELY(clsid >= 0 && SHGetSpecialFolderPath(0, path, clsid, FALSE))) {
+ result = convertCharArray(path);
+ } else {
+ if (warn) {
+ qErrnoWarning("SHGetSpecialFolderPath() failed for standard location \"%s\", clsid=0x%x.",
+ qPrintable(displayName(type)), clsid);
}
-#endif
- // fall through
- case DocumentsLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, FALSE))
- result = convertCharArray(path);
- break;
-
- case FontsLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_FONTS, FALSE))
- result = convertCharArray(path);
- break;
-
- case ApplicationsLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_PROGRAMS, FALSE))
- result = convertCharArray(path);
- break;
-
- case MusicLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_MYMUSIC, FALSE))
- result = convertCharArray(path);
- break;
+ }
+ return result;
+}
- case MoviesLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_MYVIDEO, FALSE))
- result = convertCharArray(path);
- break;
+// Convenience for SHGetKnownFolderPath().
+static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardLocation type, bool warn = false)
+{
+ QString result;
+#ifndef Q_OS_WINCE
+ typedef HRESULT (WINAPI *GetKnownFolderPath)(const GUID&, DWORD, HANDLE, LPWSTR*);
+
+ static const GetKnownFolderPath sHGetKnownFolderPath = // Vista onwards.
+ reinterpret_cast<GetKnownFolderPath>(QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath"));
+
+ LPWSTR path;
+ if (Q_LIKELY(sHGetKnownFolderPath && SUCCEEDED(sHGetKnownFolderPath(clsid, 0, 0, &path)))) {
+ result = convertCharArray(path);
+ CoTaskMemFree(path);
+ } else {
+ if (warn) {
+ qErrnoWarning("SHGetKnownFolderPath() failed for standard location \"%s\".",
+ qPrintable(displayName(type)));
+ }
+ }
+#else // !Q_OS_WINCE
+ Q_UNUSED(clsid)
+ Q_UNUSED(type)
+ Q_UNUSED(warn)
+#endif
+ return result;
+}
- case PicturesLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_MYPICTURES, FALSE))
- result = convertCharArray(path);
+QString QStandardPaths::writableLocation(StandardLocation type)
+{
+ QString result;
+ switch (type) {
+ case DownloadLocation:
+ result = sHGetKnownFolderPath(qCLSID_FOLDERID_Downloads, type);
+ if (result.isEmpty())
+ result = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
break;
case CacheLocation:
// Although Microsoft has a Cache key it is a pointer to IE's cache, not a cache
// location for everyone. Most applications seem to be using a
// cache directory located in their AppData directory
- return writableLocation(AppLocalDataLocation) + QLatin1String("/cache");
+ result = sHGetSpecialFolderPath(writableSpecialFolderClsid(AppLocalDataLocation), type, /* warn */ true);
+ if (!result.isEmpty()) {
+ appendTestMode(result);
+ appendOrganizationAndApp(result);
+ result += QLatin1String("/cache");
+ }
+ break;
case GenericCacheLocation:
- return writableLocation(GenericDataLocation) + QLatin1String("/cache");
+ result = sHGetSpecialFolderPath(writableSpecialFolderClsid(GenericDataLocation), type, /* warn */ true);
+ if (!result.isEmpty()) {
+ appendTestMode(result);
+ result += QLatin1String("/cache");
+ }
+ break;
case RuntimeLocation:
case HomeLocation:
@@ -186,6 +223,15 @@ QString QStandardPaths::writableLocation(StandardLocation type)
case TempLocation:
result = QDir::tempPath();
break;
+
+ default:
+ result = sHGetSpecialFolderPath(writableSpecialFolderClsid(type), type, /* warn */ isConfigLocation(type));
+ if (!result.isEmpty() && isConfigLocation(type)) {
+ appendTestMode(result);
+ if (!isGenericConfigLocation(type))
+ appendOrganizationAndApp(result);
+ }
+ break;
}
return result;
}
@@ -193,44 +239,26 @@ QString QStandardPaths::writableLocation(StandardLocation type)
QStringList QStandardPaths::standardLocations(StandardLocation type)
{
QStringList dirs;
+ const QString localDir = writableLocation(type);
+ if (!localDir.isEmpty())
+ dirs.append(localDir);
// type-specific handling goes here
-
#ifndef Q_OS_WINCE
- {
- wchar_t path[MAX_PATH];
- switch (type) {
- case ConfigLocation: // same as AppLocalDataLocation, on Windows (oversight, but too late to fix it)
- case GenericConfigLocation: // same as GenericDataLocation, on Windows
- case AppConfigLocation: // same as AppLocalDataLocation, that one on purpose
- case AppDataLocation:
- case AppLocalDataLocation:
- case GenericDataLocation:
- if (SHGetSpecialFolderPath(0, path, CSIDL_COMMON_APPDATA, FALSE)) {
- QString result = convertCharArray(path);
- if (type != GenericDataLocation && type != GenericConfigLocation) {
-#ifndef QT_BOOTSTRAPPED
- if (!QCoreApplication::organizationName().isEmpty())
- result += QLatin1Char('/') + QCoreApplication::organizationName();
- if (!QCoreApplication::applicationName().isEmpty())
- result += QLatin1Char('/') + QCoreApplication::applicationName();
-#endif
- }
- dirs.append(result);
-#ifndef QT_BOOTSTRAPPED
- dirs.append(QCoreApplication::applicationDirPath());
- dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data"));
-#endif
- }
- break;
- default:
- break;
+ if (isConfigLocation(type)) {
+ QString programData = sHGetSpecialFolderPath(CSIDL_COMMON_APPDATA, type);
+ if (!programData.isEmpty()) {
+ if (!isGenericConfigLocation(type))
+ appendOrganizationAndApp(programData);
+ dirs.append(programData);
}
- }
-#endif
+# ifndef QT_BOOTSTRAPPED
+ dirs.append(QCoreApplication::applicationDirPath());
+ dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data"));
+# endif // !QT_BOOTSTRAPPED
+ } // isConfigLocation()
+#endif // !Q_OS_WINCE
- const QString localDir = writableLocation(type);
- dirs.prepend(localDir);
return dirs;
}
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index 3b9a2113fd..a3ce13a99f 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -685,8 +685,11 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
/*! \typedef QJsonObject::iterator::iterator_category
- A synonym for \e {std::bidirectional_iterator_tag} indicating
- this iterator is a bidirectional iterator.
+ A synonym for \e {std::random_access_iterator_tag} indicating
+ this iterator is a random-access iterator.
+
+ \note In Qt versions before 5.6, this was set by mistake to
+ \e {std::bidirectional_iterator_tag}.
*/
/*! \typedef QJsonObject::iterator::reference
@@ -892,8 +895,11 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
/*! \typedef QJsonObject::const_iterator::iterator_category
- A synonym for \e {std::bidirectional_iterator_tag} indicating
- this iterator is a bidirectional iterator.
+ A synonym for \e {std::random_access_iterator_tag} indicating
+ this iterator is a random-access iterator.
+
+ \note In Qt versions before 5.6, this was set by mistake to
+ \e {std::bidirectional_iterator_tag}.
*/
/*! \typedef QJsonObject::const_iterator::reference
diff --git a/src/corelib/json/qjsonobject.h b/src/corelib/json/qjsonobject.h
index bc4c8f46e3..5617eee04f 100644
--- a/src/corelib/json/qjsonobject.h
+++ b/src/corelib/json/qjsonobject.h
@@ -106,7 +106,7 @@ public:
int i;
public:
- typedef std::bidirectional_iterator_tag iterator_category;
+ typedef std::random_access_iterator_tag iterator_category;
typedef int difference_type;
typedef QJsonValue value_type;
typedef QJsonValueRef reference;
@@ -149,7 +149,7 @@ public:
int i;
public:
- typedef std::bidirectional_iterator_tag iterator_category;
+ typedef std::random_access_iterator_tag iterator_category;
typedef int difference_type;
typedef QJsonValue value_type;
typedef QJsonValue reference;
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index 9dc8656c50..4d5b0f156c 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -40,6 +40,11 @@
#include <private/qcore_mac_p.h>
+#ifdef Q_OS_OSX
+#include <AppKit/NSText.h>
+#include <Carbon/Carbon.h>
+#endif
+
#include <qdebug.h>
#ifdef Q_OS_IOS
@@ -154,5 +159,148 @@ QMacAutoReleasePool::~QMacAutoReleasePool()
// -------------------------------------------------------------------------
+#ifdef Q_OS_OSX
+
+// Use this method to keep all the information in the TextSegment. As long as it is ordered
+// we are in OK shape, and we can influence that ourselves.
+struct KeyPair
+{
+ QChar cocoaKey;
+ Qt::Key qtKey;
+};
+
+bool operator==(const KeyPair &entry, QChar qchar)
+{
+ return entry.cocoaKey == qchar;
+}
+
+bool operator<(const KeyPair &entry, QChar qchar)
+{
+ return entry.cocoaKey < qchar;
+}
+
+bool operator<(QChar qchar, const KeyPair &entry)
+{
+ return qchar < entry.cocoaKey;
+}
+
+bool operator<(const Qt::Key &key, const KeyPair &entry)
+{
+ return key < entry.qtKey;
+}
+
+bool operator<(const KeyPair &entry, const Qt::Key &key)
+{
+ return entry.qtKey < key;
+}
+
+struct qtKey2CocoaKeySortLessThan
+{
+ typedef bool result_type;
+ Q_DECL_CONSTEXPR result_type operator()(const KeyPair &entry1, const KeyPair &entry2) const Q_DECL_NOTHROW
+ {
+ return entry1.qtKey < entry2.qtKey;
+ }
+};
+
+static const int NumEntries = 59;
+static const KeyPair entries[NumEntries] = {
+ { NSEnterCharacter, Qt::Key_Enter },
+ { NSBackspaceCharacter, Qt::Key_Backspace },
+ { NSTabCharacter, Qt::Key_Tab },
+ { NSNewlineCharacter, Qt::Key_Return },
+ { NSCarriageReturnCharacter, Qt::Key_Return },
+ { NSBackTabCharacter, Qt::Key_Backtab },
+ { kEscapeCharCode, Qt::Key_Escape },
+ // Cocoa sends us delete when pressing backspace!
+ // (NB when we reverse this list in qtKey2CocoaKey, there
+ // will be two indices of Qt::Key_Backspace. But is seems to work
+ // ok for menu shortcuts (which uses that function):
+ { NSDeleteCharacter, Qt::Key_Backspace },
+ { NSUpArrowFunctionKey, Qt::Key_Up },
+ { NSDownArrowFunctionKey, Qt::Key_Down },
+ { NSLeftArrowFunctionKey, Qt::Key_Left },
+ { NSRightArrowFunctionKey, Qt::Key_Right },
+ { NSF1FunctionKey, Qt::Key_F1 },
+ { NSF2FunctionKey, Qt::Key_F2 },
+ { NSF3FunctionKey, Qt::Key_F3 },
+ { NSF4FunctionKey, Qt::Key_F4 },
+ { NSF5FunctionKey, Qt::Key_F5 },
+ { NSF6FunctionKey, Qt::Key_F6 },
+ { NSF7FunctionKey, Qt::Key_F7 },
+ { NSF8FunctionKey, Qt::Key_F8 },
+ { NSF9FunctionKey, Qt::Key_F9 },
+ { NSF10FunctionKey, Qt::Key_F10 },
+ { NSF11FunctionKey, Qt::Key_F11 },
+ { NSF12FunctionKey, Qt::Key_F12 },
+ { NSF13FunctionKey, Qt::Key_F13 },
+ { NSF14FunctionKey, Qt::Key_F14 },
+ { NSF15FunctionKey, Qt::Key_F15 },
+ { NSF16FunctionKey, Qt::Key_F16 },
+ { NSF17FunctionKey, Qt::Key_F17 },
+ { NSF18FunctionKey, Qt::Key_F18 },
+ { NSF19FunctionKey, Qt::Key_F19 },
+ { NSF20FunctionKey, Qt::Key_F20 },
+ { NSF21FunctionKey, Qt::Key_F21 },
+ { NSF22FunctionKey, Qt::Key_F22 },
+ { NSF23FunctionKey, Qt::Key_F23 },
+ { NSF24FunctionKey, Qt::Key_F24 },
+ { NSF25FunctionKey, Qt::Key_F25 },
+ { NSF26FunctionKey, Qt::Key_F26 },
+ { NSF27FunctionKey, Qt::Key_F27 },
+ { NSF28FunctionKey, Qt::Key_F28 },
+ { NSF29FunctionKey, Qt::Key_F29 },
+ { NSF30FunctionKey, Qt::Key_F30 },
+ { NSF31FunctionKey, Qt::Key_F31 },
+ { NSF32FunctionKey, Qt::Key_F32 },
+ { NSF33FunctionKey, Qt::Key_F33 },
+ { NSF34FunctionKey, Qt::Key_F34 },
+ { NSF35FunctionKey, Qt::Key_F35 },
+ { NSInsertFunctionKey, Qt::Key_Insert },
+ { NSDeleteFunctionKey, Qt::Key_Delete },
+ { NSHomeFunctionKey, Qt::Key_Home },
+ { NSEndFunctionKey, Qt::Key_End },
+ { NSPageUpFunctionKey, Qt::Key_PageUp },
+ { NSPageDownFunctionKey, Qt::Key_PageDown },
+ { NSPrintScreenFunctionKey, Qt::Key_Print },
+ { NSScrollLockFunctionKey, Qt::Key_ScrollLock },
+ { NSPauseFunctionKey, Qt::Key_Pause },
+ { NSSysReqFunctionKey, Qt::Key_SysReq },
+ { NSMenuFunctionKey, Qt::Key_Menu },
+ { NSHelpFunctionKey, Qt::Key_Help },
+};
+static const KeyPair * const end = entries + NumEntries;
+
+QChar qt_mac_qtKey2CocoaKey(Qt::Key key)
+{
+ // The first time this function is called, create a reverse
+ // lookup table sorted on Qt Key rather than Cocoa key:
+ static QVector<KeyPair> rev_entries(NumEntries);
+ static bool mustInit = true;
+ if (mustInit){
+ mustInit = false;
+ for (int i=0; i<NumEntries; ++i)
+ rev_entries[i] = entries[i];
+ std::sort(rev_entries.begin(), rev_entries.end(), qtKey2CocoaKeySortLessThan());
+ }
+ const QVector<KeyPair>::iterator i
+ = std::lower_bound(rev_entries.begin(), rev_entries.end(), key);
+ if ((i == rev_entries.end()) || (key < *i))
+ return QChar();
+ return i->cocoaKey;
+}
+
+Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode)
+{
+ const KeyPair *i = std::lower_bound(entries, end, keyCode);
+ if ((i == end) || (keyCode < *i))
+ return Qt::Key(keyCode.toUpper().unicode());
+ return i->qtKey;
+}
+
+#endif // Q_OS_OSX
+
+// -------------------------------------------------------------------------
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 5403014611..b94aac1093 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -143,6 +143,11 @@ typedef struct {
QAppleOperatingSystemVersion qt_apple_os_version();
+#ifdef Q_OS_OSX
+Q_CORE_EXPORT QChar qt_mac_qtKey2CocoaKey(Qt::Key key);
+Q_CORE_EXPORT Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode);
+#endif
+
QT_END_NAMESPACE
#endif // QCORE_MAC_P_H
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 96f9203d4a..3ac1f28638 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1704,8 +1704,9 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
void *QMetaType::create(int type, const void *copy)
{
QMetaType info(type);
- int size = info.sizeOf();
- return info.construct(operator new(size), copy);
+ if (int size = info.sizeOf())
+ return info.construct(operator new(size), copy);
+ return 0;
}
/*!
diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp
index ee0c34a7a8..787db8a8a6 100644
--- a/src/corelib/kernel/qtcore_eval.cpp
+++ b/src/corelib/kernel/qtcore_eval.cpp
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
static const char boilerplate_supported_but_time_limited[] =
"\nQt %1 Evaluation License\n"
- "Copyright (C) 2015 The Qt Company Ltd.\n"
+ "Copyright (C) 2016 The Qt Company Ltd.\n"
"This trial version may only be used for evaluation purposes\n"
"and will shut down after 120 minutes.\n"
"Registered to:\n"
@@ -63,7 +63,7 @@ static const char boilerplate_supported_but_time_limited[] =
static const char boilerplate_supported[] =
"\nQt %1 Evaluation License\n"
- "Copyright (C) 2015 The Qt Company Ltd.\n"
+ "Copyright (C) 2016 The Qt Company Ltd.\n"
"This trial version may only be used for evaluation purposes\n"
"Registered to:\n"
" Licensee: %2\n\n"
diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp
index 61eca2c74d..efcb364794 100644
--- a/src/corelib/statemachine/qfinalstate.cpp
+++ b/src/corelib/statemachine/qfinalstate.cpp
@@ -37,12 +37,10 @@
**
****************************************************************************/
-#include "qfinalstate.h"
+#include "qfinalstate_p.h"
#ifndef QT_NO_STATEMACHINE
-#include "qabstractstate_p.h"
-
QT_BEGIN_NAMESPACE
/*!
@@ -82,19 +80,16 @@ QT_BEGIN_NAMESPACE
\sa QState::finished()
*/
-class QFinalStatePrivate : public QAbstractStatePrivate
-{
- Q_DECLARE_PUBLIC(QFinalState)
-
-public:
- QFinalStatePrivate();
-};
-
QFinalStatePrivate::QFinalStatePrivate()
: QAbstractStatePrivate(FinalState)
{
}
+QFinalStatePrivate::~QFinalStatePrivate()
+{
+ // to prevent vtables being generated in every file that includes the private header
+}
+
/*!
Constructs a new QFinalState object with the given \a parent state.
*/
@@ -104,6 +99,15 @@ QFinalState::QFinalState(QState *parent)
}
/*!
+ \internal
+ */
+QFinalState::QFinalState(QFinalStatePrivate &dd, QState *parent)
+ : QAbstractState(dd, parent)
+{
+}
+
+
+/*!
Destroys this final state.
*/
QFinalState::~QFinalState()
diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h
index f9b32ef128..9b6b193231 100644
--- a/src/corelib/statemachine/qfinalstate.h
+++ b/src/corelib/statemachine/qfinalstate.h
@@ -44,7 +44,6 @@
QT_BEGIN_NAMESPACE
-
#ifndef QT_NO_STATEMACHINE
class QFinalStatePrivate;
@@ -61,6 +60,9 @@ protected:
bool event(QEvent *e) Q_DECL_OVERRIDE;
+protected:
+ explicit QFinalState(QFinalStatePrivate &dd, QState *parent);
+
private:
Q_DISABLE_COPY(QFinalState)
Q_DECLARE_PRIVATE(QFinalState)
diff --git a/src/corelib/statemachine/qfinalstate_p.h b/src/corelib/statemachine/qfinalstate_p.h
new file mode 100644
index 0000000000..74640289f1
--- /dev/null
+++ b/src/corelib/statemachine/qfinalstate_p.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFINALSTATE_P_H
+#define QFINALSTATE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qfinalstate.h"
+#include "private/qabstractstate_p.h"
+
+#ifndef QT_NO_STATEMACHINE
+
+QT_BEGIN_NAMESPACE
+
+class Q_CORE_EXPORT QFinalStatePrivate : public QAbstractStatePrivate
+{
+ Q_DECLARE_PUBLIC(QFinalState)
+
+public:
+ QFinalStatePrivate();
+ ~QFinalStatePrivate();
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_STATEMACHINE
+
+#endif // QFINALSTATE_P_H
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index bcfff1e462..cae6474c32 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -37,11 +37,10 @@
**
****************************************************************************/
-#include "qstate.h"
+#include "qstate_p.h"
#ifndef QT_NO_STATEMACHINE
-#include "qstate_p.h"
#include "qhistorystate.h"
#include "qhistorystate_p.h"
#include "qabstracttransition.h"
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 438de427f5..913657e53b 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include "qstate.h"
#include "private/qabstractstate_p.h"
#include <QtCore/qlist.h>
@@ -58,6 +59,8 @@
#include <QtCore/qpointer.h>
#include <QtCore/qvariant.h>
+#ifndef QT_NO_STATEMACHINE
+
QT_BEGIN_NAMESPACE
#ifndef QT_NO_PROPERTIES
@@ -89,7 +92,7 @@ class QAbstractTransition;
class QHistoryState;
class QState;
-class Q_AUTOTEST_EXPORT QStatePrivate : public QAbstractStatePrivate
+class Q_CORE_EXPORT QStatePrivate : public QAbstractStatePrivate
{
Q_DECLARE_PUBLIC(QState)
public:
@@ -121,4 +124,6 @@ public:
QT_END_NAMESPACE
+#endif // QT_NO_STATEMACHINE
+
#endif
diff --git a/src/corelib/statemachine/statemachine.pri b/src/corelib/statemachine/statemachine.pri
index 910cf5e9b3..c5396a2ef8 100644
--- a/src/corelib/statemachine/statemachine.pri
+++ b/src/corelib/statemachine/statemachine.pri
@@ -6,6 +6,7 @@ HEADERS += $$PWD/qstatemachine.h \
$$PWD/qstate.h \
$$PWD/qstate_p.h \
$$PWD/qfinalstate.h \
+ $$PWD/qfinalstate_p.h \
$$PWD/qhistorystate.h \
$$PWD/qhistorystate_p.h \
$$PWD/qabstracttransition.h \
diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp
index 3146a6d6fa..6690f28556 100644
--- a/src/corelib/thread/qfutureinterface.cpp
+++ b/src/corelib/thread/qfutureinterface.cpp
@@ -199,16 +199,19 @@ void QFutureInterfaceBase::waitForResume()
int QFutureInterfaceBase::progressValue() const
{
+ const QMutexLocker lock(&d->m_mutex);
return d->m_progressValue;
}
int QFutureInterfaceBase::progressMinimum() const
{
+ const QMutexLocker lock(&d->m_mutex);
return d->m_progressMinimum;
}
int QFutureInterfaceBase::progressMaximum() const
{
+ const QMutexLocker lock(&d->m_mutex);
return d->m_progressMaximum;
}
diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h
index 92e2cdc7af..f5f0e7047f 100644
--- a/src/corelib/thread/qfutureinterface_p.h
+++ b/src/corelib/thread/qfutureinterface_p.h
@@ -152,18 +152,20 @@ public:
QAtomicInt m_refCountT;
};
+ // T: accessed from executing thread
+ // Q: accessed from the waiting/querying thread
RefCount refCount;
mutable QMutex m_mutex;
QWaitCondition waitCondition;
QList<QFutureCallOutInterface *> outputConnections;
- int m_progressValue;
- int m_progressMinimum;
- int m_progressMaximum;
+ int m_progressValue; // TQ
+ int m_progressMinimum; // TQ
+ int m_progressMaximum; // TQ
QFutureInterfaceBase::State state;
QElapsedTimer progressTime;
QWaitCondition pausedWaitCondition;
QtPrivate::ResultStoreBase m_results;
- bool manualProgress;
+ bool manualProgress; // only accessed from executing thread
int m_expectedResultCount;
QtPrivate::ExceptionStore m_exceptionStore;
QString m_progressText;
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index ace663ae30..853903619f 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -131,14 +131,13 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
}
const SectionNode &node = sectionNodes.at(index);
- int year, month, day, hour, minute, second, msec;
- year = v.date().year();
- month = v.date().month();
- day = v.date().day();
- hour = v.time().hour();
- minute = v.time().minute();
- second = v.time().second();
- msec = v.time().msec();
+ int year = v.date().year();
+ int month = v.date().month();
+ int day = v.date().day();
+ int hour = v.time().hour();
+ int minute = v.time().minute();
+ int second = v.time().second();
+ int msec = v.time().msec();
switch (node.type) {
case Hour24Section: case Hour12Section: hour = newVal; break;
@@ -676,15 +675,7 @@ QString QDateTimeParser::sectionText(const QString &text, int sectionIndex, int
QString QDateTimeParser::sectionText(int sectionIndex) const
{
const SectionNode &sn = sectionNode(sectionIndex);
- switch (sn.type) {
- case NoSectionIndex:
- case FirstSectionIndex:
- case LastSectionIndex:
- return QString();
- default: break;
- }
-
- return displayText().mid(sn.pos, sectionSize(sectionIndex));
+ return sectionText(displayText(), sectionIndex, sn.pos);
}
@@ -1012,8 +1003,10 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
const QDate date(year, month, day);
const int diff = dayofweek - date.dayOfWeek();
- if (diff != 0 && state == Acceptable && isSet & (DayOfWeekSectionShort|DayOfWeekSectionLong)) {
- conflicts = isSet & DaySection;
+ if (diff != 0 && state == Acceptable
+ && isSet & (DayOfWeekSectionShort | DayOfWeekSectionLong)) {
+ if (isSet & DaySection)
+ conflicts = true;
const SectionNode &sn = sectionNode(currentSectionIndex);
if (sn.type & (DayOfWeekSectionShort|DayOfWeekSectionLong) || currentSectionIndex == -1) {
// dayofweek should be preferred
@@ -1377,9 +1370,9 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
*/
-int QDateTimeParser::findAmPm(QString &str, int index, int *used) const
+int QDateTimeParser::findAmPm(QString &str, int sectionIndex, int *used) const
{
- const SectionNode &s = sectionNode(index);
+ const SectionNode &s = sectionNode(sectionIndex);
if (s.type != AmPmSection) {
qWarning("QDateTimeParser::findAmPm Internal error");
return -1;
@@ -1390,7 +1383,7 @@ int QDateTimeParser::findAmPm(QString &str, int index, int *used) const
return PossibleBoth;
}
const QLatin1Char space(' ');
- int size = sectionMaxSize(index);
+ int size = sectionMaxSize(sectionIndex);
enum {
amindex = 0,
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index 2c1c14f05a..64e73346f2 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -93,7 +93,7 @@ public:
first.pos = -1;
first.count = -1;
first.zeroesAdded = 0;
- last.type = FirstSection;
+ last.type = LastSection;
last.pos = -1;
last.count = -1;
last.zeroesAdded = 0;
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 524c9a14ae..faf9eb4b4d 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -242,9 +242,9 @@ template <> struct QConcatenable<QLatin1String> : private QAbstractConcatenable
}
static inline void appendTo(const QLatin1String a, char *&out)
{
- if (a.data()) {
- for (const char *s = a.data(); *s; )
- *out++ = *s++;
+ if (const char *data = a.data()) {
+ memcpy(out, data, a.size());
+ out += a.size();
}
}
};