summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp2
-rw-r--r--src/corelib/doc/snippets/hellotrmain.cpp7
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp13
-rw-r--r--src/corelib/global/qcompilerdetection.h11
-rw-r--r--src/corelib/global/qglobal.cpp60
-rw-r--r--src/corelib/global/qsysinfo.h6
-rw-r--r--src/corelib/global/qsystemdetection.h12
-rw-r--r--src/corelib/io/qdir.cpp2
-rw-r--r--src/corelib/io/qfileselector.cpp6
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp12
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp6
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp2
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp3
-rw-r--r--src/corelib/io/qlockfile_unix.cpp14
-rw-r--r--src/corelib/io/qprocess.cpp2
-rw-r--r--src/corelib/io/qprocess_unix.cpp3
-rw-r--r--src/corelib/io/qstorageinfo.cpp6
-rw-r--r--src/corelib/io/qstorageinfo_p.h2
-rw-r--r--src/corelib/io/qtextstream.cpp6
-rw-r--r--src/corelib/io/qtextstream.h2
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp7
-rw-r--r--src/corelib/kernel/kernel.pri2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp23
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp23
-rw-r--r--src/corelib/kernel/qmetatype.cpp20
-rw-r--r--src/corelib/kernel/qobject.cpp10
-rw-r--r--src/corelib/kernel/qobjectdefs.h3
-rw-r--r--src/corelib/statemachine/qabstracttransition.h2
-rw-r--r--src/corelib/thread/qthread_p.h9
-rw-r--r--src/corelib/thread/qthread_win.cpp59
-rw-r--r--src/corelib/thread/qthread_winrt.cpp450
-rw-r--r--src/corelib/thread/thread.pri5
-rw-r--r--src/corelib/tools/qdatetime.h4
-rw-r--r--src/corelib/tools/qlocale.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp19
35 files changed, 246 insertions, 569 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp
index c76a0f1f3b..ab91a00f5f 100644
--- a/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp
@@ -51,7 +51,7 @@ if (data.open(QFile::WriteOnly | QFile::Truncate)) {
//! [1]
QTextStream stream(stdin);
QString line;
-while (stream.readLine(&line)) {
+while (stream.readLineInto(&line)) {
...
}
//! [1]
diff --git a/src/corelib/doc/snippets/hellotrmain.cpp b/src/corelib/doc/snippets/hellotrmain.cpp
index 201202b7b3..dcf5805a8a 100644
--- a/src/corelib/doc/snippets/hellotrmain.cpp
+++ b/src/corelib/doc/snippets/hellotrmain.cpp
@@ -44,10 +44,11 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
QTranslator translator;
- translator.load("hellotr_la");
- app.installTranslator(&translator);
+ // look up e.g. :/translations/myapp_de.qm
+ if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/translations")))
+ app.installTranslator(&translator);
- QPushButton hello(QPushButton::tr("Hello world!"));
+ QPushButton hello(QCoreApplication::translate("main", "Hello world!"));
hello.resize(100, 30);
hello.show();
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index 4687d52e54..e03e705a0b 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -261,6 +261,19 @@ void Widget::argFunction()
str.arg("%1f").arg("Hello"); // returns "Hellof %2"
//! [13]
+ //! [97]
+ str = "%1%3%2";
+ str.arg("Hello").arg(20).arg(50); // returns "Hello500"
+
+ str = "%1%2%3";
+ str.arg("Hello").arg(50).arg(20); // returns "Hello5020"
+ //! [97]
+
+ //! [98]
+ str = "%1%2%3";
+ str.arg("Hello", QString::number(20), QString::number(50)); // returns "Hello5020"
+ //! [98]
+
//! [14]
str = QString("Decimal 63 is %1 in hexadecimal")
.arg(63, 0, 16);
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index f8a8a436be..060af29b03 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -155,7 +155,9 @@
/* Clang also masquerades as GCC */
# if defined(__apple_build_version__)
# /* http://en.wikipedia.org/wiki/Xcode#Toolchain_Versions */
-# if __apple_build_version__ >= 6000051
+# if __apple_build_version__ >= 7000053
+# define Q_CC_CLANG 306
+# elif __apple_build_version__ >= 6000051
# define Q_CC_CLANG 305
# elif __apple_build_version__ >= 5030038
# define Q_CC_CLANG 304
@@ -556,7 +558,10 @@
# define Q_COMPILER_ALIGNAS
# define Q_COMPILER_ALIGNOF
# define Q_COMPILER_INHERITING_CONSTRUCTORS
-# define Q_COMPILER_THREAD_LOCAL
+# ifndef Q_OS_OSX
+// C++11 thread_local is broken on OS X (Clang doesn't support it either)
+# define Q_COMPILER_THREAD_LOCAL
+# endif
# define Q_COMPILER_UDL
# endif
# endif
@@ -613,7 +618,7 @@
# if __has_feature(cxx_strong_enums)
# define Q_COMPILER_CLASS_ENUM
# endif
-# if __has_feature(cxx_constexpr)
+# if __has_feature(cxx_constexpr) && Q_CC_CLANG > 302 /* CLANG 3.2 has bad/partial support */
# define Q_COMPILER_CONSTEXPR
# endif
# if __has_feature(cxx_decltype) /* && __has_feature(cxx_decltype_incomplete_return_types) */
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 91e8699472..85d97c7b06 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1125,10 +1125,11 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value MV_10_4 Mac OS X 10.4 (unsupported)
\value MV_10_5 Mac OS X 10.5 (unsupported)
\value MV_10_6 Mac OS X 10.6
- \value MV_10_7 OS X 10.7
+ \value MV_10_7 Mac OS X 10.7
\value MV_10_8 OS X 10.8
\value MV_10_9 OS X 10.9
\value MV_10_10 OS X 10.10
+ \value MV_10_11 OS X 10.11
\value MV_Unknown An unknown and currently unsupported platform
\value MV_CHEETAH Apple codename for MV_10_0
@@ -1142,6 +1143,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value MV_MOUNTAINLION Apple codename for MV_10_8
\value MV_MAVERICKS Apple codename for MV_10_9
\value MV_YOSEMITE Apple codename for MV_10_10
+ \value MV_ELCAPITAN Apple codename for MV_10_11
\value MV_IOS iOS (any)
\value MV_IOS_4_3 iOS 4.3
@@ -1155,6 +1157,8 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value MV_IOS_8_1 iOS 8.1
\value MV_IOS_8_2 iOS 8.2
\value MV_IOS_8_3 iOS 8.3
+ \value MV_IOS_8_4 iOS 8.4
+ \value MV_IOS_9_0 iOS 9.0
\value MV_None Not a Darwin operating system
@@ -2050,32 +2054,27 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
#ifdef QT_DEBUG
{
- QByteArray override = qgetenv("QT_WINVER_OVERRIDE");
- if (override.isEmpty())
- return winver;
-
- if (override == "Me")
- winver = QSysInfo::WV_Me;
- if (override == "95")
- winver = QSysInfo::WV_95;
- else if (override == "98")
- winver = QSysInfo::WV_98;
- else if (override == "NT")
- winver = QSysInfo::WV_NT;
- else if (override == "2000")
- winver = QSysInfo::WV_2000;
- else if (override == "2003")
- winver = QSysInfo::WV_2003;
- else if (override == "XP")
- winver = QSysInfo::WV_XP;
- else if (override == "VISTA")
- winver = QSysInfo::WV_VISTA;
- else if (override == "WINDOWS7")
- winver = QSysInfo::WV_WINDOWS7;
- else if (override == "WINDOWS8")
- winver = QSysInfo::WV_WINDOWS8;
- else if (override == "WINDOWS8_1")
- winver = QSysInfo::WV_WINDOWS8_1;
+ if (Q_UNLIKELY(qEnvironmentVariableIsSet("QT_WINVER_OVERRIDE"))) {
+ const QByteArray winVerOverride = qgetenv("QT_WINVER_OVERRIDE");
+ if (winVerOverride == "NT")
+ winver = QSysInfo::WV_NT;
+ else if (winVerOverride == "2000")
+ winver = QSysInfo::WV_2000;
+ else if (winVerOverride == "2003")
+ winver = QSysInfo::WV_2003;
+ else if (winVerOverride == "XP")
+ winver = QSysInfo::WV_XP;
+ else if (winVerOverride == "VISTA")
+ winver = QSysInfo::WV_VISTA;
+ else if (winVerOverride == "WINDOWS7")
+ winver = QSysInfo::WV_WINDOWS7;
+ else if (winVerOverride == "WINDOWS8")
+ winver = QSysInfo::WV_WINDOWS8;
+ else if (winVerOverride == "WINDOWS8_1")
+ winver = QSysInfo::WV_WINDOWS8_1;
+ else if (winVerOverride == "WINDOWS10")
+ winver = QSysInfo::WV_WINDOWS10;
+ }
}
#endif
#endif // !Q_OS_WINRT
@@ -2102,6 +2101,8 @@ static const char *winVer_helper()
return "8";
case QSysInfo::WV_WINDOWS8_1:
return "8.1";
+ case QSysInfo::WV_WINDOWS10:
+ return "10";
case QSysInfo::WV_CE:
return "CE";
@@ -2731,7 +2732,7 @@ QString QSysInfo::prettyProductName()
basename = "Mac OS X Snow Leopard (";
break;
case MV_LION:
- basename = "Mac OS X Lion (";
+ basename = "OS X Lion (";
break;
case MV_MOUNTAINLION:
basename = "OS X Mountain Lion (";
@@ -2742,6 +2743,9 @@ QString QSysInfo::prettyProductName()
case MV_YOSEMITE:
basename = "OS X Yosemite (";
break;
+ case MV_ELCAPITAN:
+ basename = "OS X El Capitan (";
+ break;
}
if (basename)
return QLatin1String(basename) + productVersion() + QLatin1Char(')');
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index 72acdd8c70..d40e6659c7 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -137,6 +137,7 @@ public:
MV_10_8 = Q_MV_OSX(10, 8),
MV_10_9 = Q_MV_OSX(10, 9),
MV_10_10 = Q_MV_OSX(10, 10),
+ MV_10_11 = Q_MV_OSX(10, 11),
/* codenames */
MV_CHEETAH = MV_10_0,
@@ -150,6 +151,7 @@ public:
MV_MOUNTAINLION = MV_10_8,
MV_MAVERICKS = MV_10_9,
MV_YOSEMITE = MV_10_10,
+ MV_ELCAPITAN = MV_10_11,
/* iOS */
MV_IOS = 1 << 8,
@@ -163,7 +165,9 @@ public:
MV_IOS_8_0 = Q_MV_IOS(8, 0),
MV_IOS_8_1 = Q_MV_IOS(8, 1),
MV_IOS_8_2 = Q_MV_IOS(8, 2),
- MV_IOS_8_3 = Q_MV_IOS(8, 3)
+ MV_IOS_8_3 = Q_MV_IOS(8, 3),
+ MV_IOS_8_4 = Q_MV_IOS(8, 4),
+ MV_IOS_9_0 = Q_MV_IOS(9, 0)
};
#if defined(Q_OS_MAC)
static const MacVersion MacintoshVersion;
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index cb662c7db1..562427e4b9 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -233,6 +233,9 @@
# if !defined(__MAC_10_10)
# define __MAC_10_10 101000
# endif
+# if !defined(__MAC_10_11)
+# define __MAC_10_11 101100
+# endif
# if !defined(MAC_OS_X_VERSION_10_7)
# define MAC_OS_X_VERSION_10_7 1070
# endif
@@ -245,6 +248,9 @@
# if !defined(MAC_OS_X_VERSION_10_10)
# define MAC_OS_X_VERSION_10_10 101000
# endif
+# if !defined(MAC_OS_X_VERSION_10_11)
+# define MAC_OS_X_VERSION_10_11 101100
+# endif
#
# if !defined(__IPHONE_4_3)
# define __IPHONE_4_3 40300
@@ -279,6 +285,12 @@
# if !defined(__IPHONE_8_3)
# define __IPHONE_8_3 80300
# endif
+# if !defined(__IPHONE_8_4)
+# define __IPHONE_8_4 80400
+# endif
+# if !defined(__IPHONE_9_0)
+# define __IPHONE_9_0 90000
+# endif
#endif
#ifdef __LSB_VERSION__
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 8b3dd5d82f..2ae865a534 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -777,6 +777,8 @@ QString QDir::relativeFilePath(const QString &fileName) const
result += QLatin1Char('/');
}
+ if (result.isEmpty())
+ return QLatin1String(".");
return result;
}
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index cddd70f908..85d9b0bfcb 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -80,7 +80,7 @@ QFileSelectorPrivate::QFileSelectorPrivate()
QString defaultsBasePath = "data/";
QString defaultsPath = defaultsBasePath + "defaults.conf";
QString localizedPath = defaultsBasePath
- + QString("%1/defaults.conf").arg(QLocale::system().name());
+ + QString("%1/defaults.conf").arg(QLocale().name());
if (QFile::exists(localizedPath))
defaultsPath = localizedPath;
QFile defaults(defaultsPath);
@@ -148,7 +148,7 @@ QFileSelectorPrivate::QFileSelectorPrivate()
on (list not exhaustive): android, blackberry, ios, osx, darwin, mac, linux, wince, unix,
windows. On Linux, if it can be determined, the name of the distribution too, like debian,
fedora or opensuse.
- \li locale, same as QLocale::system().name().
+ \li locale, same as QLocale().name().
\endlist
Further selectors will be added from the \c QT_FILE_SELECTORS environment variable, which
@@ -347,7 +347,7 @@ void QFileSelectorPrivate::updateSelectors()
sharedData->staticSelectors << sharedData->preloadedStatics; //Potential for static selectors from other modules
// TODO: Update on locale changed?
- sharedData->staticSelectors << QLocale::system().name();
+ sharedData->staticSelectors << QLocale().name();
sharedData->staticSelectors << platformSelectors();
}
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index c4fb709ddf..2c9fed530b 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -662,17 +662,11 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &
bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
{
mode_t mode = 0;
- if (permissions & QFile::ReadOwner)
+ if (permissions & (QFile::ReadOwner | QFile::ReadUser))
mode |= S_IRUSR;
- if (permissions & QFile::WriteOwner)
+ if (permissions & (QFile::WriteOwner | QFile::WriteUser))
mode |= S_IWUSR;
- if (permissions & QFile::ExeOwner)
- mode |= S_IXUSR;
- if (permissions & QFile::ReadUser)
- mode |= S_IRUSR;
- if (permissions & QFile::WriteUser)
- mode |= S_IWUSR;
- if (permissions & QFile::ExeUser)
+ if (permissions & (QFile::ExeOwner | QFile::ExeUser))
mode |= S_IXUSR;
if (permissions & QFile::ReadGroup)
mode |= S_IRGRP;
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 5cca3c323e..d62c120d7e 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -1437,11 +1437,9 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per
Q_UNUSED(data);
int mode = 0;
- if (permissions & QFile::ReadOwner || permissions & QFile::ReadUser
- || permissions & QFile::ReadGroup || permissions & QFile::ReadOther)
+ if (permissions & (QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther))
mode |= _S_IREAD;
- if (permissions & QFile::WriteOwner || permissions & QFile::WriteUser
- || permissions & QFile::WriteGroup || permissions & QFile::WriteOther)
+ if (permissions & (QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther))
mode |= _S_IWRITE;
if (mode == 0) // not supported
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 3a8f7bd0a9..7fc3049f46 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -185,7 +185,7 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re
the file system monitor. Also note that your process may have
other file descriptors open in addition to the ones for files
being monitored, and these other open descriptors also count in
- the total. OS X 10.5 and up use a different backend and do not
+ the total. Mac OS X 10.5 and up use a different backend and do not
suffer from this issue.
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index 039992adba..4907a20a5f 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -248,6 +248,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path
// ###
files->removeAll(path);
directories->removeAll(path);
+ it.remove();
if (h.isEmpty()) {
DEBUG() << "Closing handle" << handle.handle;
@@ -260,8 +261,6 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path
thread->handleForDir.remove(QFileSystemWatcherPathKey(absolutePath));
// h is now invalid
- it.remove();
-
if (thread->handleForDir.isEmpty()) {
DEBUG() << "Stopping thread " << thread;
locker.unlock();
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index d6ea2f1f2d..815c0f025b 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -56,6 +56,7 @@
# include <cstdio>
#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
# include <sys/user.h>
+# include <libutil.h>
#endif
QT_BEGIN_NAMESPACE
@@ -218,24 +219,25 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
#if defined(Q_OS_OSX)
char name[1024];
proc_name(pid, name, sizeof(name) / sizeof(char));
- return QString::fromUtf8(name);
+ return QFile::decodeName(name);
#elif defined(Q_OS_LINUX)
if (!QFile::exists(QStringLiteral("/proc/version")))
return QString();
char exePath[64];
- char buf[PATH_MAX];
- memset(buf, 0, sizeof(buf));
+ char buf[PATH_MAX + 1];
sprintf(exePath, "/proc/%lld/exe", pid);
- if (readlink(exePath, buf, sizeof(buf)) < 0) {
+ size_t len = (size_t)readlink(exePath, buf, sizeof(buf));
+ if (len >= sizeof(buf)) {
// The pid is gone. Return some invalid process name to fail the test.
return QStringLiteral("/ERROR/");
}
- return QFileInfo(QString::fromUtf8(buf)).fileName();
+ buf[len] = 0;
+ return QFileInfo(QFile::decodeName(buf)).fileName();
#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
kinfo_proc *proc = kinfo_getproc(pid);
if (!proc)
return QString();
- QString name = QString::fromUtf8(proc->ki_comm);
+ QString name = QFile::decodeName(proc->ki_comm);
free(proc);
return name;
#else
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 093cb85bfb..218e8b959c 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -2086,7 +2086,7 @@ QByteArray QProcess::readAllStandardError()
printed at the console, and the existing process will continue running
unaffected.
- \sa pid(), started(), waitForStarted(), setNativeArguments()
+ \sa processId(), started(), waitForStarted(), setNativeArguments()
*/
void QProcess::start(const QString &program, const QStringList &arguments, OpenMode mode)
{
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 47611d4b00..0d6ef9e60f 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -1085,6 +1085,9 @@ bool QProcessPrivate::waitForDeadChild()
exitCode = info.si_status;
crashed = info.si_code != CLD_EXITED;
+ delete deathNotifier;
+ deathNotifier = 0;
+
qt_safe_close(forkfd);
forkfd = -1; // Child is dead, don't try to kill it anymore
diff --git a/src/corelib/io/qstorageinfo.cpp b/src/corelib/io/qstorageinfo.cpp
index d63b6a2a21..337a9c7cef 100644
--- a/src/corelib/io/qstorageinfo.cpp
+++ b/src/corelib/io/qstorageinfo.cpp
@@ -186,6 +186,8 @@ QString QStorageInfo::rootPath() const
This size can be less than or equal to the free size returned by
bytesFree() function.
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesTotal(), bytesFree()
*/
qint64 QStorageInfo::bytesAvailable() const
@@ -198,6 +200,8 @@ qint64 QStorageInfo::bytesAvailable() const
quotas on the filesystem, this value can be larger than the value
returned by bytesAvailable().
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesTotal(), bytesAvailable()
*/
qint64 QStorageInfo::bytesFree() const
@@ -208,6 +212,8 @@ qint64 QStorageInfo::bytesFree() const
/*!
Returns the total volume size in bytes.
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesFree(), bytesAvailable()
*/
qint64 QStorageInfo::bytesTotal() const
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index 9e152df1ad..564321bedd 100644
--- a/src/corelib/io/qstorageinfo_p.h
+++ b/src/corelib/io/qstorageinfo_p.h
@@ -53,7 +53,7 @@ class QStorageInfoPrivate : public QSharedData
{
public:
inline QStorageInfoPrivate() : QSharedData(),
- bytesTotal(0), bytesFree(0), bytesAvailable(0),
+ bytesTotal(-1), bytesFree(-1), bytesAvailable(-1),
readOnly(false), ready(false), valid(false)
{}
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 47b96d708f..8ad1c2852c 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -1591,7 +1591,7 @@ QString QTextStream::readLine(qint64 maxlen)
{
QString line;
- readLine(&line, maxlen);
+ readLineInto(&line, maxlen);
return line;
}
@@ -1612,7 +1612,7 @@ QString QTextStream::readLine(qint64 maxlen)
If \a line has sufficient capacity for the data that is about to be
read, this function may not need to allocate new memory. Because of
- this, it can be faster than the other readLine() overload.
+ this, it can be faster than readLine().
Returns \c false if the stream has read to the end of the file or
an error has occurred; otherwise returns \c true. The contents in
@@ -1620,7 +1620,7 @@ QString QTextStream::readLine(qint64 maxlen)
\sa readAll(), QIODevice::readLine()
*/
-bool QTextStream::readLine(QString *line, qint64 maxlen)
+bool QTextStream::readLineInto(QString *line, qint64 maxlen)
{
Q_D(QTextStream);
// keep in sync with CHECK_VALID_STREAM
diff --git a/src/corelib/io/qtextstream.h b/src/corelib/io/qtextstream.h
index 125502e68d..e5f429ae4d 100644
--- a/src/corelib/io/qtextstream.h
+++ b/src/corelib/io/qtextstream.h
@@ -124,7 +124,7 @@ public:
void skipWhiteSpace();
QString readLine(qint64 maxlen = 0);
- bool readLine(QString *line, qint64 maxlen = 0);
+ bool readLineInto(QString *line, qint64 maxlen = 0);
QString readAll();
QString read(qint64 maxlen);
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index 9692ffb675..4ee37defae 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -2646,9 +2646,12 @@ bool QSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QMode
Q_D(const QSortFilterProxyModel);
QVariant l = (source_left.model() ? source_left.model()->data(source_left, d->sort_role) : QVariant());
QVariant r = (source_right.model() ? source_right.model()->data(source_right, d->sort_role) : QVariant());
+ // Duplicated in QStandardItem::operator<()
+ if (l.userType() == QVariant::Invalid)
+ return false;
+ if (r.userType() == QVariant::Invalid)
+ return true;
switch (l.userType()) {
- case QVariant::Invalid:
- return (r.type() != QVariant::Invalid);
case QVariant::Int:
return l.toInt() < r.toInt();
case QVariant::UInt:
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index dabbb2dbbe..65dc44def2 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -84,7 +84,7 @@ win32 {
}
}
-wince*: {
+wince {
SOURCES += \
kernel/qfunctions_wince.cpp
HEADERS += \
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 524bfd26cc..66481d4c87 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1004,6 +1004,17 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event)
do not change the focus widget.
\endlist
+ \b{Future direction:} This function will not be called for objects that live
+ outside the main thread in Qt 6. Applications that need that functionality
+ should find other solutions for their event inspection needs in the meantime.
+ The change may be extended to the main thread, causing this function to be
+ deprecated.
+
+ \warning If you override this function, you must ensure all threads that
+ process events stop doing so before your application object begins
+ destruction. This includes threads started by other libraries that you may be
+ using, but does not apply to Qt's own threads.
+
\sa QObject::event(), installNativeEventFilter()
*/
@@ -2053,11 +2064,13 @@ QString QCoreApplication::applicationFilePath()
QCoreApplicationPrivate *d = self->d_func();
- static char *procName = d->argv[0];
- if (qstrcmp(procName, d->argv[0]) != 0) {
- // clear the cache if the procname changes, so we reprocess it.
- QCoreApplicationPrivate::clearApplicationFilePath();
- procName = d->argv[0];
+ if (d->argc) {
+ static const char *procName = d->argv[0];
+ if (qstrcmp(procName, d->argv[0]) != 0) {
+ // clear the cache if the procname changes, so we reprocess it.
+ QCoreApplicationPrivate::clearApplicationFilePath();
+ procName = d->argv[0];
+ }
}
if (QCoreApplicationPrivate::cachedApplicationFilePath)
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index 1509996199..eceba8d002 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -144,7 +144,10 @@ private:
IID_PPV_ARGS(&application));
RETURN_VOID_IF_FAILED("Failed to get the application factory");
- ComPtr<ICoreApplicationView> view;
+ static ComPtr<ICoreApplicationView> view;
+ if (view)
+ return;
+
hr = application->get_MainView(&view);
RETURN_VOID_IF_FAILED("Failed to get the main view");
@@ -166,13 +169,6 @@ QEventDispatcherWinRT::QEventDispatcherWinRT(QObject *parent)
{
Q_D(QEventDispatcherWinRT);
- // Special treatment for the WinMain thread, as it is created before the UI
- static bool firstThread = true;
- if (firstThread) {
- firstThread = false;
- return;
- }
-
d->fetchCoreDispatcher();
}
@@ -212,6 +208,7 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
DWORD waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, 1, TRUE);
if (waitResult >= WAIT_OBJECT_0 && waitResult < WAIT_OBJECT_0 + timerHandles.count()) {
const HANDLE handle = timerHandles.value(waitResult - WAIT_OBJECT_0);
+ ResetEvent(handle);
const int timerId = d->timerHandleToId.value(handle);
if (timerId == INTERRUPT_HANDLE)
break;
@@ -288,8 +285,8 @@ void QEventDispatcherWinRT::registerTimer(int timerId, int interval, Qt::TimerTy
TimeSpan period;
period.Duration = interval ? (interval * 10000) : 1; // TimeSpan is based on 100-nanosecond units
IThreadPoolTimer *timer;
- const HANDLE handle = CreateEventEx(NULL, NULL, NULL, SYNCHRONIZE|EVENT_MODIFY_STATE);
- const HANDLE cancelHandle = CreateEventEx(NULL, NULL, NULL, SYNCHRONIZE|EVENT_MODIFY_STATE);
+ const HANDLE handle = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE | EVENT_MODIFY_STATE);
+ const HANDLE cancelHandle = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE|EVENT_MODIFY_STATE);
HRESULT hr = d->timerFactory->CreatePeriodicTimerWithCompletion(
Callback<ITimerElapsedHandler>([handle, cancelHandle](IThreadPoolTimer *timer) {
DWORD cancelResult = WaitForSingleObjectEx(cancelHandle, 0, TRUE);
@@ -376,7 +373,7 @@ QList<QAbstractEventDispatcher::TimerInfo> QEventDispatcherWinRT::registeredTime
Q_D(const QEventDispatcherWinRT);
QList<TimerInfo> timerInfos;
foreach (const WinRTTimerInfo &info, d->timerInfos) {
- if (info.object == object)
+ if (info.object == object && info.timerId != INVALID_TIMER_ID)
timerInfos.append(info);
}
return timerInfos;
@@ -486,7 +483,9 @@ bool QEventDispatcherWinRT::event(QEvent *e)
QEventDispatcherWinRTPrivate::QEventDispatcherWinRTPrivate()
{
- CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ const bool isGuiThread = QCoreApplication::instance() &&
+ QThread::currentThread() == QCoreApplication::instance()->thread();
+ CoInitializeEx(NULL, isGuiThread ? COINIT_APARTMENTTHREADED : COINIT_MULTITHREADED);
HRESULT hr;
hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(), &timerFactory);
Q_ASSERT_SUCCEEDED(hr);
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 3b70ef92ed..58912e3fb7 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -303,7 +303,7 @@ struct DefinedTypesFilter {
\omitvalue WeakPointerToQObject
\omitvalue TrackingPointerToQObject
\omitvalue WasDeclaredAsMetaType
- \value IsGadget This type is a Q_GADGET and it's corresponding QMetaObject can be accessed with QMetaType::metaObject Since 5.5.
+ \omitvalue IsGadget This type is a Q_GADGET and it's corresponding QMetaObject can be accessed with QMetaType::metaObject Since 5.5.
*/
/*!
@@ -1046,6 +1046,16 @@ int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName,
if (idx >= User) {
previousSize = ct->at(idx - User).size;
previousFlags = ct->at(idx - User).flags;
+
+ // Set new/additional flags in case of old library/app.
+ // Ensures that older code works in conjunction with new Qt releases
+ // requiring the new flags.
+ if (flags != previousFlags) {
+ QCustomTypeInfo &inf = ct->data()[idx - User];
+ inf.flags |= flags;
+ if (metaObject)
+ inf.metaObject = metaObject;
+ }
}
}
@@ -1061,11 +1071,11 @@ int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName,
normalizedTypeName.constData(), idx, previousSize, size);
}
+ // Do not compare types higher than 0x100:
// Ignore WasDeclaredAsMetaType inconsitency, to many users were hitting the problem
- previousFlags |= WasDeclaredAsMetaType;
- flags |= WasDeclaredAsMetaType;
-
- if (previousFlags != flags) {
+ // Ignore IsGadget as it was added in Qt 5.5
+ // Ignore all the future flags as well
+ if ((previousFlags ^ flags) & 0xff) {
const int maskForTypeInfo = NeedsConstruction | NeedsDestruction | MovableType;
const char *msg = "QMetaType::registerType: Binary compatibility break. "
"\nType flags for type '%s' [%i] don't match. Previously "
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 3ca9c890e8..c63dd79f02 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4922,6 +4922,16 @@ QMetaObject::Connection::~Connection()
static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
}
+/*! \internal Returns true if the object is still connected */
+bool QMetaObject::Connection::isConnected_helper() const
+{
+ Q_ASSERT(d_ptr); // we're only called from operator RestrictedBool() const
+ QObjectPrivate::Connection *c = static_cast<QObjectPrivate::Connection *>(d_ptr);
+
+ return c->receiver;
+}
+
+
/*!
\fn QMetaObject::Connection::operator bool() const
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 837c5e4a1e..b1ed971eba 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -476,6 +476,7 @@ class Q_CORE_EXPORT QMetaObject::Connection {
friend class QObject;
friend class QObjectPrivate;
friend struct QMetaObject;
+ bool isConnected_helper() const;
public:
~Connection();
Connection();
@@ -485,7 +486,7 @@ public:
operator bool() const;
#else
typedef void *Connection::*RestrictedBool;
- operator RestrictedBool() const { return d_ptr ? &Connection::d_ptr : Q_NULLPTR; }
+ operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : Q_NULLPTR; }
#endif
#ifdef Q_COMPILER_RVALUE_REFS
diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h
index 0d61ae3f5c..4398c41ca2 100644
--- a/src/corelib/statemachine/qabstracttransition.h
+++ b/src/corelib/statemachine/qabstracttransition.h
@@ -59,7 +59,7 @@ class Q_CORE_EXPORT QAbstractTransition : public QObject
Q_PROPERTY(QState* sourceState READ sourceState)
Q_PROPERTY(QAbstractState* targetState READ targetState WRITE setTargetState NOTIFY targetStateChanged)
Q_PROPERTY(QList<QAbstractState*> targetStates READ targetStates WRITE setTargetStates NOTIFY targetStatesChanged)
- Q_PROPERTY(TransitionType transitionType READ transitionType WRITE setTransitionType)
+ Q_PROPERTY(TransitionType transitionType READ transitionType WRITE setTransitionType REVISION 1)
public:
enum TransitionType {
ExternalTransition,
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 2008f76621..1ecd682ad1 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -171,19 +171,10 @@ public:
#endif // Q_OS_UNIX
#ifdef Q_OS_WIN
-# ifndef Q_OS_WINRT
static unsigned int __stdcall start(void *);
static void finish(void *, bool lockAnyway=true);
-# else
- HRESULT start(ABI::Windows::Foundation::IAsyncAction *);
- void finish(bool lockAnyway = true);
-# endif
-# ifndef Q_OS_WINRT
Qt::HANDLE handle;
-# else
- ABI::Windows::Foundation::IAsyncAction *handle;
-# endif
unsigned int id;
int waiters;
bool terminationEnabled, terminatePending;
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index feb189bf45..c16a2e958c 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -32,7 +32,7 @@
****************************************************************************/
//#define WINVER 0x0500
-#if (_WIN32_WINNT < 0x0400)
+#if !defined Q_OS_WINRT && (_WIN32_WINNT < 0x0400)
#define _WIN32_WINNT 0x0400
#endif
@@ -46,18 +46,25 @@
#include <qpointer.h>
#include <private/qcoreapplication_p.h>
+#ifndef Q_OS_WINRT
#include <private/qeventdispatcher_win_p.h>
+#else
+#include <private/qeventdispatcher_winrt_p.h>
+#endif
#include <qt_windows.h>
+#ifndef Q_OS_WINRT
#ifndef Q_OS_WINCE
#ifndef _MT
#define _MT
-#endif
+#endif // _MT
#include <process.h>
-#else
+#else // !Q_OS_WINCE
#include "qfunctions_wince.h"
-#endif
+#endif // Q_OS_WINCE
+#else // !Q_OS_WINRT
+#endif // Q_OS_WINRT
#ifndef QT_NO_THREAD
QT_BEGIN_NAMESPACE
@@ -171,7 +178,11 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
// Start watcher thread if it is not already running.
if (qt_adopted_thread_watcher_id == 0) {
if (qt_adopted_thread_wakeup == 0) {
+#ifndef Q_OS_WINRT
qt_adopted_thread_wakeup = CreateEvent(0, false, false, 0);
+#else
+ qt_adopted_thread_wakeup = CreateEventEx(0, NULL, 0, EVENT_ALL_ACCESS);
+#endif
qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup);
}
@@ -210,13 +221,21 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
// no need to loop, no timeout
offset = 0;
count = handlesCopy.count();
+#ifndef Q_OS_WINRT
ret = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, INFINITE);
+#else
+ ret = WaitForMultipleObjectsEx(handlesCopy.count(), handlesCopy.constData(), false, INFINITE, false);
+#endif
} else {
int loop = 0;
do {
offset = loop * MAXIMUM_WAIT_OBJECTS;
count = qMin(handlesCopy.count() - offset, MAXIMUM_WAIT_OBJECTS);
+#ifndef Q_OS_WINRT
ret = WaitForMultipleObjects(count, handlesCopy.constData() + offset, false, 100);
+#else
+ ret = WaitForMultipleObjectsEx(count, handlesCopy.constData() + offset, false, 100, false);
+#endif
loop = (loop + 1) % loops;
} while (ret == WAIT_TIMEOUT);
}
@@ -263,7 +282,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
return 0;
}
-#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
#ifndef Q_OS_WIN64
# define ULONG_PTR DWORD
@@ -293,7 +312,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
{
}
}
-#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINCE
+#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINCE && !Q_OS_WINRT
/**************************************************************************
** QThreadPrivate
@@ -303,7 +322,11 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
void QThreadPrivate::createEventDispatcher(QThreadData *data)
{
+#ifndef Q_OS_WINRT
QEventDispatcherWin32 *theEventDispatcher = new QEventDispatcherWin32;
+#else
+ QEventDispatcherWinRT *theEventDispatcher = new QEventDispatcherWinRT;
+#endif
data->eventDispatcher.storeRelease(theEventDispatcher);
theEventDispatcher->startingUp();
}
@@ -331,7 +354,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
else
createEventDispatcher(data);
-#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
// sets the name of the current thread.
QByteArray objectName = thr->objectName().toLocal8Bit();
qt_set_thread_name((HANDLE)-1,
@@ -396,13 +419,17 @@ Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW
int QThread::idealThreadCount() Q_DECL_NOTHROW
{
SYSTEM_INFO sysinfo;
+#ifndef Q_OS_WINRT
GetSystemInfo(&sysinfo);
+#else
+ GetNativeSystemInfo(&sysinfo);
+#endif
return sysinfo.dwNumberOfProcessors;
}
void QThread::yieldCurrentThread()
{
-#ifndef Q_OS_WINCE
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
SwitchToThread();
#else
::Sleep(0);
@@ -444,6 +471,7 @@ void QThread::start(Priority priority)
d->returnCode = 0;
d->interruptionRequested = false;
+#ifndef Q_OS_WINRT
/*
NOTE: we create the thread in the suspended state, set the
priority and then resume the thread.
@@ -456,6 +484,10 @@ void QThread::start(Priority priority)
*/
d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start,
this, CREATE_SUSPENDED, &(d->id));
+#else // !Q_OS_WINRT
+ d->handle = (Qt::HANDLE) CreateThread(NULL, d->stackSize, (LPTHREAD_START_ROUTINE)QThreadPrivate::start,
+ this, CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&d->id));
+#endif // Q_OS_WINRT
if (!d->handle) {
qErrnoWarning(errno, "QThread::start: Failed to create thread");
@@ -521,7 +553,10 @@ void QThread::terminate()
return;
}
+ // Calling ExitThread() in setTerminationEnabled is all we can do on WinRT
+#ifndef Q_OS_WINRT
TerminateThread(d->handle, 0);
+#endif
QThreadPrivate::finish(this, false);
}
@@ -541,7 +576,11 @@ bool QThread::wait(unsigned long time)
locker.mutex()->unlock();
bool ret = false;
+#ifndef Q_OS_WINRT
switch (WaitForSingleObject(d->handle, time)) {
+#else
+ switch (WaitForSingleObjectEx(d->handle, time, false)) {
+#endif
case WAIT_OBJECT_0:
ret = true;
break;
@@ -582,7 +621,11 @@ void QThread::setTerminationEnabled(bool enabled)
if (enabled && d->terminatePending) {
QThreadPrivate::finish(thr, false);
locker.unlock(); // don't leave the mutex locked!
+#ifndef Q_OS_WINRT
_endthreadex(0);
+#else
+ ExitThread(0);
+#endif
}
}
diff --git a/src/corelib/thread/qthread_winrt.cpp b/src/corelib/thread/qthread_winrt.cpp
deleted file mode 100644
index f4a7a662cb..0000000000
--- a/src/corelib/thread/qthread_winrt.cpp
+++ /dev/null
@@ -1,450 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 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$
-**
-****************************************************************************/
-
-#include "qthread.h"
-#include "qthread_p.h"
-#include "qthreadstorage.h"
-
-#include <QtCore/QElapsedTimer>
-#include <QtCore/QUuid>
-#include <QtCore/qt_windows.h>
-#include <QtCore/qfunctions_winrt.h>
-#include <QtCore/private/qcoreapplication_p.h>
-#include <QtCore/private/qeventdispatcher_winrt_p.h>
-
-#include <wrl.h>
-#include <windows.system.threading.h>
-#include <windows.system.threading.core.h>
-using namespace Microsoft::WRL;
-using namespace Microsoft::WRL::Wrappers;
-using namespace ABI::Windows::Foundation;
-using namespace ABI::Windows::System::Threading;
-using namespace ABI::Windows::System::Threading::Core;
-
-#ifndef QT_NO_THREAD
-QT_BEGIN_NAMESPACE
-
-static WorkItemPriority nativePriority(QThread::Priority priority)
-{
- switch (priority) {
- default:
- case QThread::NormalPriority:
- return WorkItemPriority_Normal;
- case QThread::IdlePriority:
- case QThread::LowestPriority:
- case QThread::LowPriority:
- return WorkItemPriority_Low;
- case QThread::HighPriority:
- case QThread::HighestPriority:
- case QThread::TimeCriticalPriority:
- return WorkItemPriority_High;
- }
-}
-
-class QWinRTThreadGlobal
-{
-public:
- QWinRTThreadGlobal()
- {
- HRESULT hr;
-
- hr = RoGetActivationFactory(
- HString::MakeReference(RuntimeClass_Windows_System_Threading_Core_PreallocatedWorkItem).Get(),
- IID_PPV_ARGS(&workItemFactory));
- Q_ASSERT_SUCCEEDED(hr);
-
- hr = RoGetActivationFactory(
- HString::MakeReference(RuntimeClass_Windows_System_Threading_Core_SignalNotifier).Get(),
- IID_PPV_ARGS(&notifierFactory));
- Q_ASSERT_SUCCEEDED(hr);
-
- QString eventName = QUuid::createUuid().toString();
- dispatchEvent = CreateEventEx(NULL, reinterpret_cast<LPCWSTR>(eventName.utf16()), 0, EVENT_ALL_ACCESS);
-
- hr = notifierFactory->AttachToEvent(
- HStringReference(reinterpret_cast<LPCWSTR>(eventName.utf16())).Get(),
- Callback<ISignalHandler>(this, &QWinRTThreadGlobal::dispatch).Get(), &notifier);
- Q_ASSERT_SUCCEEDED(hr);
- hr = notifier->Enable();
- Q_ASSERT_SUCCEEDED(hr);
- }
-
- ~QWinRTThreadGlobal()
- {
- CloseHandle(dispatchEvent);
- }
-
- void dispatch()
- {
- SetEvent(dispatchEvent);
- }
-
- void push(QThreadPrivate *d)
- {
- threads.append(d);
- }
-
-private:
- HRESULT dispatch(ISignalNotifier *notifier, boolean timedOut)
- {
- Q_UNUSED(timedOut);
- notifier->Enable();
- if (threads.isEmpty())
- return S_OK;
-
- QThreadPrivate *thread = threads.takeFirst();
- ComPtr<IPreallocatedWorkItem> workItem;
- HRESULT hr = workItemFactory->CreateWorkItemWithPriority(
- Callback<IWorkItemHandler>(thread, &QThreadPrivate::start).Get(),
- nativePriority(thread->priority), &workItem);
- if (FAILED(hr)) {
- qErrnoWarning(hr, "Failed to create thread work item");
- thread->finish();
- return hr;
- }
-
- hr = workItem->RunAsync(&thread->handle);
- if (FAILED(hr)) {
- qErrnoWarning(hr, "Failed to run work item");
- thread->finish();
- return hr;
- }
-
- return S_OK;
- }
-
- HANDLE dispatchEvent;
- ComPtr<ISignalNotifier> notifier;
- ComPtr<ISignalNotifierStatics> notifierFactory;
- ComPtr<IPreallocatedWorkItemFactory> workItemFactory;
-
- QList<QThreadPrivate *> threads;
-};
-Q_GLOBAL_STATIC(QWinRTThreadGlobal, g)
-
-/**************************************************************************
- ** QThreadData
- *************************************************************************/
-
-__declspec(thread) static QThreadData *qt_current_thread_data = 0;
-
-void QThreadData::clearCurrentThreadData()
-{
- qt_current_thread_data = 0;
-}
-
-QThreadData *QThreadData::current(bool createIfNecessary)
-{
- static bool winmainThread = true;
- QThreadData *threadData = qt_current_thread_data;
- if (!threadData && createIfNecessary) {
- threadData = new QThreadData;
- // This needs to be called prior to new AdoptedThread() to
- // avoid recursion.
- qt_current_thread_data = threadData;
- QT_TRY {
- threadData->thread = new QAdoptedThread(threadData);
- } QT_CATCH(...) {
- qt_current_thread_data = 0;
- threadData->deref();
- threadData = 0;
- QT_RETHROW;
- }
- threadData->deref();
- threadData->isAdopted = true;
- threadData->threadId = reinterpret_cast<Qt::HANDLE>(GetCurrentThreadId());
-
- if (!QCoreApplicationPrivate::theMainThread && !winmainThread)
- QCoreApplicationPrivate::theMainThread = threadData->thread;
-
- if (winmainThread) {
- g->dispatch();
- threadData->thread->d_func()->createEventDispatcher(threadData);
- winmainThread = false;
- }
- }
-
- return threadData;
-}
-
-void QAdoptedThread::init()
-{
- Q_D(QThread);
-
- d->handle = Q_NULLPTR;
- d->id = 0;
-}
-
-/**************************************************************************
- ** QThreadPrivate
- *************************************************************************/
-
-#endif // QT_NO_THREAD
-
-void QThreadPrivate::createEventDispatcher(QThreadData *data)
-{
- QEventDispatcherWinRT *eventDispatcher = new QEventDispatcherWinRT;
- data->eventDispatcher.storeRelease(eventDispatcher);
- eventDispatcher->startingUp();
-}
-
-#ifndef QT_NO_THREAD
-
-HRESULT QThreadPrivate::start(IAsyncAction *)
-{
- Q_Q(QThread);
-
- qt_current_thread_data = data;
- id = GetCurrentThreadId();
- data->threadId = reinterpret_cast<Qt::HANDLE>(id);
- QThread::setTerminationEnabled(false);
-
- {
- QMutexLocker locker(&mutex);
- data->quitNow = exited;
- }
-
- if (data->eventDispatcher.load())
- data->eventDispatcher.load()->startingUp();
- else
- createEventDispatcher(data);
-
- running = true;
- emit q->started(QThread::QPrivateSignal());
-
- QThread::setTerminationEnabled(true);
-
- q->run();
-
- finish();
-
- return S_OK;
-}
-
-void QThreadPrivate::finish(bool lockAnyway)
-{
- Q_Q(QThread);
-
- QMutexLocker locker(lockAnyway ? &mutex : 0);
- isInFinish = true;
- priority = QThread::InheritPriority;
- void **tls_data = reinterpret_cast<void **>(&data->tls);
- locker.unlock();
- emit q->finished(QThread::QPrivateSignal());
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QThreadStorageData::finish(tls_data);
- locker.relock();
-
- QAbstractEventDispatcher *eventDispatcher = data->eventDispatcher.load();
- if (eventDispatcher) {
- data->eventDispatcher = 0;
- locker.unlock();
- eventDispatcher->closingDown();
- delete eventDispatcher;
- locker.relock();
- }
-
- running = false;
- finished = true;
- isInFinish = false;
- interruptionRequested = false;
-
- if (!waiters) {
- if (handle)
- handle->Release();
- handle = Q_NULLPTR;
- }
-
- id = 0;
-}
-
-/**************************************************************************
- ** QThread
- *************************************************************************/
-
-Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW
-{
- return reinterpret_cast<Qt::HANDLE>(GetCurrentThreadId());
-}
-
-int QThread::idealThreadCount() Q_DECL_NOTHROW
-{
- SYSTEM_INFO sysinfo;
- GetNativeSystemInfo(&sysinfo);
- return sysinfo.dwNumberOfProcessors;
-}
-
-void QThread::yieldCurrentThread()
-{
- msleep(1);
-}
-
-void QThread::sleep(unsigned long secs)
-{
- msleep(secs * 1000);
-}
-
-void QThread::msleep(unsigned long msecs)
-{
- WaitForSingleObjectEx(GetCurrentThread(), msecs, FALSE);
-}
-
-void QThread::usleep(unsigned long usecs)
-{
- msleep((usecs / 1000) + 1);
-}
-
-void QThread::start(Priority priority)
-{
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
-
- if (d->isInFinish) {
- locker.unlock();
- wait();
- locker.relock();
- }
-
- if (d->running)
- return;
-
- d->finished = false;
- d->exited = false;
- d->returnCode = 0;
- d->interruptionRequested = false;
- d->priority = priority == QThread::InheritPriority ? currentThread()->priority() : priority;
- g->push(d);
- g->dispatch();
-
- locker.unlock();
- while (!d->running && !d->finished) {
- QAbstractEventDispatcher *eventDispatcher = QThread::currentThread()->eventDispatcher();
- if (eventDispatcher)
- eventDispatcher->processEvents(QEventLoop::AllEvents);
- else
- yieldCurrentThread();
- }
-}
-
-void QThread::terminate()
-{
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
- if (!d->running)
- return;
- if (!d->terminationEnabled) {
- d->terminatePending = true;
- return;
- }
-
- if (d->handle) {
- ComPtr<IAsyncInfo> info;
- HRESULT hr = d->handle->QueryInterface(IID_PPV_ARGS(&info));
- Q_ASSERT_SUCCEEDED(hr);
- hr = info->Cancel();
- if (FAILED(hr))
- qErrnoWarning(hr, "Failed to cancel thread action");
- }
-
- d->finish(false);
-}
-
-bool QThread::wait(unsigned long time)
-{
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
-
- if (d->id == GetCurrentThreadId()) {
- qWarning("QThread::wait: Thread tried to wait on itself");
- return false;
- }
- if (d->finished || !d->running)
- return true;
-
- ++d->waiters;
- locker.mutex()->unlock();
-
- // Alternatively, we could check the handle
- bool ret = false;
- if (!d->finished) {
- QElapsedTimer timer;
- timer.start();
- while (timer.elapsed() < time && !d->finished)
- yieldCurrentThread();
-
- ret = d->finished;
- }
-
- locker.mutex()->lock();
- --d->waiters;
-
- if (ret && !d->finished) {
- // thread was terminated by someone else
-
- d->finish(false);
- }
-
- if (d->finished && !d->waiters) {
- if (d->handle)
- d->handle->Release();
- d->handle = Q_NULLPTR;
- }
-
- return ret;
-}
-
-void QThread::setTerminationEnabled(bool enabled)
-{
- QThread *thr = currentThread();
- Q_ASSERT_X(thr != 0, "QThread::setTerminationEnabled()",
- "Current thread was not started with QThread.");
- QThreadPrivate *d = thr->d_func();
- QMutexLocker locker(&d->mutex);
- d->terminationEnabled = enabled;
- if (enabled && d->terminatePending) {
- d->finish(false);
- locker.unlock(); // don't leave the mutex locked!
- }
-}
-
-// Caller must hold the mutex
-void QThreadPrivate::setPriority(QThread::Priority threadPriority)
-{
- if (running)
- qWarning("WinRT threads can't change priority while running.");
-
- priority = threadPriority;
-}
-
-QT_END_NAMESPACE
-#endif // QT_NO_THREAD
diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri
index 2e027c8e21..3c1ddd984a 100644
--- a/src/corelib/thread/thread.pri
+++ b/src/corelib/thread/thread.pri
@@ -50,11 +50,6 @@ win32:SOURCES += thread/qmutex_win.cpp \
thread/qthread_win.cpp \
thread/qwaitcondition_win.cpp
-winrt {
- SOURCES -= thread/qthread_win.cpp
- SOURCES += thread/qthread_winrt.cpp
-}
-
integrity:SOURCES += thread/qmutex_unix.cpp \
thread/qthread_unix.cpp \
thread/qwaitcondition_unix.cpp
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index a8372c1d57..c44f7f8fee 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -59,7 +59,7 @@ public:
StandaloneFormat
};
private:
- Q_DECL_CONSTEXPR QDate(qint64 julianDay) : jd(julianDay) {}
+ explicit Q_DECL_CONSTEXPR QDate(qint64 julianDay) : jd(julianDay) {}
public:
Q_DECL_CONSTEXPR QDate() : jd(nullJd()) {}
QDate(int y, int m, int d);
@@ -138,7 +138,7 @@ Q_DECLARE_TYPEINFO(QDate, Q_MOVABLE_TYPE);
class Q_CORE_EXPORT QTime
{
- Q_DECL_CONSTEXPR QTime(int ms) : mds(ms)
+ explicit Q_DECL_CONSTEXPR QTime(int ms) : mds(ms)
#if defined(Q_OS_WINCE)
, startTick(NullTime)
#endif
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index e598e95bb6..703341cc36 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -3522,7 +3522,7 @@ QString QLocale::toCurrencyString(double value, const QString &symbol) const
\since 4.8
Returns an ordered list of locale names for translation purposes in
- preference order (like "en", "en-US", "en-Latn-US").
+ preference order (like "en-Latn-US", "en-US", "en").
The return value represents locale names that the user expects to see the
UI translation in.
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 0bd2e6b23d..07ca62145b 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -7264,6 +7264,25 @@ QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const
difference if \a a1 contains e.g. \c{%1}:
\snippet qstring/main.cpp 13
+
+ A similar problem occurs when the numbered place markers are not
+ white space separated:
+
+ \snippet qstring/main.cpp 12
+ \snippet qstring/main.cpp 97
+
+ Let's look at the substitutions:
+ \list
+ \li First, \c Hello replaces \c {%1} so the string becomes \c {"Hello%3%2"}.
+ \li Then, \c 20 replaces \c {%2} so the string becomes \c {"Hello%320"}.
+ \li Since the maximum numbered place marker value is 99, \c 50 replaces \c {%32}.
+ \endlist
+ Thus the string finally becomes \c {"Hello500"}.
+
+ In such cases, the following yields the expected results:
+
+ \snippet qstring/main.cpp 12
+ \snippet qstring/main.cpp 98
*/
/*!