summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-01-08 12:30:57 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-01-08 12:35:24 +0100
commitad16478a76815f8f61d454bf7760aaf9ffbb4b51 (patch)
treeeefdd9219cc9d59b62e042f49fc7555b980cb7a4 /src/corelib
parent80a741f3616290897ba0d9f1cbd3c9c5ee62da37 (diff)
parent09c92863001790a0304a5ef389901ee2b5b6cdc2 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Based on merge done by Liang Qi Change-Id: Id566e5b9f284d29bff2199f13f9417c660f5b26f
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in23
-rw-r--r--src/corelib/Qt5CoreMacros.cmake11
-rw-r--r--src/corelib/global/qglobal.cpp54
-rw-r--r--src/corelib/global/qglobal.h1
-rw-r--r--src/corelib/global/qnamespace.qdoc4
-rw-r--r--src/corelib/global/qprocessordetection.h50
-rw-r--r--src/corelib/io/qprocess_wince.cpp18
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp30
-rw-r--r--src/corelib/io/qurl.cpp6
-rw-r--r--src/corelib/io/qwinoverlappedionotifier.cpp27
-rw-r--r--src/corelib/io/qwinoverlappedionotifier_p.h2
-rw-r--r--src/corelib/json/qjsonvalue.cpp12
-rw-r--r--src/corelib/kernel/qfunctions_fake_env_p.h51
-rw-r--r--src/corelib/kernel/qfunctions_winrt.h29
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp3
-rw-r--r--src/corelib/thread/qthreadpool.cpp10
-rw-r--r--src/corelib/thread/qthreadpool_p.h2
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp10
-rw-r--r--src/corelib/tools/qstring.cpp19
19 files changed, 197 insertions, 165 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 8242682a89..a5ed8b2ea3 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -70,7 +70,14 @@ set(_qt5_corelib_extra_includes)
# Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module
# macro to add it.
set(Qt5_POSITION_INDEPENDENT_CODE True)
-set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIC\")
+
+# On x86 and x86-64 systems with ELF binaries (especially Linux), due to
+# a new optimization in GCC 5.x in combination with a recent version of
+# GNU binutils, compiling Qt applications with -fPIE is no longer
+# enough.
+# Applications now need to be compiled with the -fPIC option if the Qt option
+# \"reduce relocations\" is active. For backward compatibility only, Qt accepts
+# the use of -fPIE for GCC 4.x versions.
if (CMAKE_VERSION VERSION_LESS 2.8.12
AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
@@ -79,6 +86,20 @@ else()
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP)
endif()
+# Applications using qmake or cmake >= 2.8.12 as their build system will
+# adapt automatically. Applications using an older release of cmake in
+# combination with GCC 5.x need to change their CMakeLists.txt to add
+# Qt5Core_EXECUTABLE_COMPILE_FLAGS to CMAKE_CXX_FLAGS. In particular,
+# applications using cmake >= 2.8.9 and < 2.8.11 will continue to build
+# with the -fPIE option and invoke the special compatibility mode if using
+# GCC 4.x.
+set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"\")
+if (CMAKE_VERSION VERSION_LESS 2.8.12
+ AND (CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
+ AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
+ set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIC\")
+endif()
+
!!IF !isEmpty(QT_NAMESPACE)
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index c0a8c62b04..0c33335ae9 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -94,7 +94,7 @@ endmacro()
# helper macro to set up a moc rule
-function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
+function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target moc_depends)
# Pass the parameters in a file. Set the working directory to
# be that containing the parameters file and reference it by
# just the file name. This is necessary because the moc tool on
@@ -131,7 +131,7 @@ function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
set(_moc_extra_parameters_file @${_moc_parameters_file})
add_custom_command(OUTPUT ${outfile}
COMMAND ${Qt5Core_MOC_EXECUTABLE} ${_moc_extra_parameters_file}
- DEPENDS ${infile}
+ DEPENDS ${infile} ${moc_depends}
${_moc_working_dir}
VERBATIM)
endfunction()
@@ -151,7 +151,7 @@ function(QT5_GENERATE_MOC infile outfile )
endif()
set(moc_target ${ARGV3})
endif()
- qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}")
+ qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
endfunction()
@@ -164,13 +164,14 @@ function(QT5_WRAP_CPP outfiles )
set(options)
set(oneValueArgs TARGET)
- set(multiValueArgs OPTIONS)
+ set(multiValueArgs OPTIONS DEPENDS)
cmake_parse_arguments(_WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(moc_files ${_WRAP_CPP_UNPARSED_ARGUMENTS})
set(moc_options ${_WRAP_CPP_OPTIONS})
set(moc_target ${_WRAP_CPP_TARGET})
+ set(moc_depends ${_WRAP_CPP_DEPENDS})
if (moc_target AND CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "The TARGET parameter to qt5_wrap_cpp is only available when using CMake 2.8.12 or later.")
@@ -178,7 +179,7 @@ function(QT5_WRAP_CPP outfiles )
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
qt5_make_output_file(${it} moc_ cpp outfile)
- qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}")
+ qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
list(APPEND ${outfiles} ${outfile})
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index a8385d3174..606a60db5a 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -66,18 +66,8 @@
#endif
#ifdef Q_OS_WINRT
-#include <wrl.h>
-#include <windows.networking.h>
-#include <windows.networking.sockets.h>
-#include <windows.networking.connectivity.h>
-using namespace Microsoft::WRL;
-using namespace Microsoft::WRL::Wrappers;
-using namespace ABI::Windows::Foundation;
-using namespace ABI::Windows::Foundation::Collections;
-using namespace ABI::Windows::Networking;
-using namespace ABI::Windows::Networking::Connectivity;
-using namespace ABI::Windows::Networking::Sockets;
-#endif
+#include <Ws2tcpip.h>
+#endif // Q_OS_WINRT
#if defined(Q_OS_VXWORKS) && defined(_WRS_KERNEL)
# include <envLib.h>
@@ -1881,8 +1871,6 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include "qt_windows.h"
QT_END_INCLUDE_NAMESPACE
-#ifndef Q_OS_WINRT
-
# ifndef QT_BOOTSTRAPPED
class QWindowsSockInit
{
@@ -1913,8 +1901,6 @@ QWindowsSockInit::~QWindowsSockInit()
Q_GLOBAL_STATIC(QWindowsSockInit, winsockInit)
# endif // QT_BOOTSTRAPPED
-#endif // !Q_OS_WINRT
-
#ifdef Q_OS_WINRT
static inline HMODULE moduleHandleForFunction(LPCVOID address)
{
@@ -2807,42 +2793,6 @@ QString QSysInfo::machineHostName()
struct utsname u;
if (uname(&u) == 0)
return QString::fromLocal8Bit(u.nodename);
-#elif defined(Q_OS_WINRT)
- ComPtr<INetworkInformationStatics> statics;
- GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Connectivity_NetworkInformation).Get(), &statics);
-
- ComPtr<IVectorView<HostName *>> hostNames;
- statics->GetHostNames(&hostNames);
- if (!hostNames)
- return QString();
-
- unsigned int size;
- hostNames->get_Size(&size);
- if (size == 0)
- return QString();
-
- for (unsigned int i = 0; i < size; ++i) {
- ComPtr<IHostName> hostName;
- hostNames->GetAt(i, &hostName);
- HostNameType type;
- hostName->get_Type(&type);
- if (type != HostNameType_DomainName)
- continue;
-
- HString name;
- hostName->get_CanonicalName(name.GetAddressOf());
- UINT32 length;
- PCWSTR rawString = name.GetRawBuffer(&length);
- return QString::fromWCharArray(rawString, length);
- }
- ComPtr<IHostName> firstHost;
- hostNames->GetAt(0, &firstHost);
-
- HString name;
- firstHost->get_CanonicalName(name.GetAddressOf());
- UINT32 length;
- PCWSTR rawString = name.GetRawBuffer(&length);
- return QString::fromWCharArray(rawString, length);
#else
# ifdef Q_OS_WIN
// Important: QtNetwork depends on machineHostName() initializing ws2_32.dll
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index c84a6b5577..232c52b8fe 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -611,7 +611,6 @@ class QDataStream;
#if defined(Q_OS_WINRT)
# define QT_NO_FILESYSTEMWATCHER
-# define QT_NO_GETADDRINFO
# define QT_NO_NETWORKPROXY
# define QT_NO_PROCESS
# define QT_NO_SOCKETNOTIFIER
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 7fd76be3ca..60d6d4b929 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1719,8 +1719,8 @@
\value Key_unknown
\value Key_Call A key to answer or initiate a call (see Qt::Key_ToggleCallHangup for a key to toggle current call state)
- \value Key_Camera A key to activate the camera shutter
- \value Key_CameraFocus A key to focus the camera
+ \value Key_Camera A key to activate the camera shutter. On Windows Runtime, the environment variable QT_QPA_ENABLE_CAMERA_KEYS must be set to receive the event.
+ \value Key_CameraFocus A key to focus the camera. On Windows Runtime, the environment variable QT_QPA_ENABLE_CAMERA_KEYS must be set to receive the event.
\value Key_Context1
\value Key_Context2
\value Key_Context3
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index f8c168e074..b490e4a6b0 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -88,47 +88,51 @@
auto-detection implemented below.
*/
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(__aarch64__)
-# define Q_PROCESSOR_ARM
# if defined(__aarch64__)
# define Q_PROCESSOR_ARM_64
# define Q_PROCESSOR_WORDSIZE 8
# else
# define Q_PROCESSOR_ARM_32
# endif
-# if defined(__ARM64_ARCH_8__) \
- || defined(__ARM_ARCH_8A) \
- || (defined(__ARM_ARCH) && __ARM_ARCH == 8)
-# define Q_PROCESSOR_ARM_V8
-# define Q_PROCESSOR_ARM_V7
-# define Q_PROCESSOR_ARM_V6
-# define Q_PROCESSOR_ARM_V5
+# if defined(__ARM_ARCH) && __ARM_ARCH > 1
+# define Q_PROCESSOR_ARM __ARM_ARCH
+# elif defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM > 1
+# define Q_PROCESSOR_ARM __TARGET_ARCH_ARM
+# elif defined(_M_ARM) && _M_ARM > 1
+# define Q_PROCESSOR_ARM _M_ARM
+# elif defined(__ARM64_ARCH_8__)
+# define Q_PROCESSOR_ARM 8
# elif defined(__ARM_ARCH_7__) \
|| defined(__ARM_ARCH_7A__) \
|| defined(__ARM_ARCH_7R__) \
|| defined(__ARM_ARCH_7M__) \
|| defined(__ARM_ARCH_7S__) \
- || defined(_ARM_ARCH_7) \
- || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) \
- || (defined(_M_ARM) && _M_ARM-0 >= 7) \
- || (defined(__ARMv7__))
-# define Q_PROCESSOR_ARM_V7
-# define Q_PROCESSOR_ARM_V6
-# define Q_PROCESSOR_ARM_V5
+ || defined(_ARM_ARCH_7)
+# define Q_PROCESSOR_ARM 7
# elif defined(__ARM_ARCH_6__) \
|| defined(__ARM_ARCH_6J__) \
|| defined(__ARM_ARCH_6T2__) \
|| defined(__ARM_ARCH_6Z__) \
|| defined(__ARM_ARCH_6K__) \
|| defined(__ARM_ARCH_6ZK__) \
- || defined(__ARM_ARCH_6M__) \
- || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) \
- || (defined(_M_ARM) && _M_ARM-0 >= 6)
-# define Q_PROCESSOR_ARM_V6
-# define Q_PROCESSOR_ARM_V5
+ || defined(__ARM_ARCH_6M__)
+# define Q_PROCESSOR_ARM 6
# elif defined(__ARM_ARCH_5TEJ__) \
- || defined(__ARM_ARCH_5TE__) \
- || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) \
- || (defined(_M_ARM) && _M_ARM-0 >= 5)
+ || defined(__ARM_ARCH_5TE__)
+# define Q_PROCESSOR_ARM 5
+# else
+# define Q_PROCESSOR_ARM 0
+# endif
+# if Q_PROCESSOR_ARM >= 8
+# define Q_PROCESSOR_ARM_V8
+# endif
+# if Q_PROCESSOR_ARM >= 7
+# define Q_PROCESSOR_ARM_V7
+# endif
+# if Q_PROCESSOR_ARM >= 6
+# define Q_PROCESSOR_ARM_V6
+# endif
+# if Q_PROCESSOR_ARM >= 5
# define Q_PROCESSOR_ARM_V5
# endif
# if defined(__ARMEL__)
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
index 9b63ece15c..acacdb8540 100644
--- a/src/corelib/io/qprocess_wince.cpp
+++ b/src/corelib/io/qprocess_wince.cpp
@@ -235,20 +235,14 @@ bool QProcessPrivate::waitForFinished(int msecs)
qDebug("QProcessPrivate::waitForFinished(%d)", msecs);
#endif
- QIncrementalSleepTimer timer(msecs);
-
- forever {
- if (!pid)
- return true;
-
- if (WaitForSingleObject(pid->hProcess, timer.nextSleepTime()) == WAIT_OBJECT_0) {
- _q_processDied();
- return true;
- }
+ if (!pid)
+ return true;
- if (timer.hasTimedOut())
- break;
+ if (WaitForSingleObject(pid->hProcess, msecs == -1 ? INFINITE : msecs) == WAIT_OBJECT_0) {
+ _q_processDied();
+ return true;
}
+
setError(QProcess::Timedout);
return false;
}
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index ed2faa742a..78f75482ea 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -113,21 +113,33 @@ QString QStandardPaths::writableLocation(StandardLocation type)
{
const uid_t myUid = geteuid();
// http://standards.freedesktop.org/basedir-spec/latest/
+ QFileInfo fileInfo;
QString xdgRuntimeDir = QFile::decodeName(qgetenv("XDG_RUNTIME_DIR"));
if (xdgRuntimeDir.isEmpty()) {
const QString userName = QFileSystemEngine::resolveUserName(myUid);
xdgRuntimeDir = QDir::tempPath() + QLatin1String("/runtime-") + userName;
- QDir dir(xdgRuntimeDir);
- if (!dir.exists()) {
+ fileInfo.setFile(xdgRuntimeDir);
+ if (!fileInfo.isDir()) {
if (!QDir().mkdir(xdgRuntimeDir)) {
qWarning("QStandardPaths: error creating runtime directory %s: %s", qPrintable(xdgRuntimeDir), qPrintable(qt_error_string(errno)));
return QString();
}
}
qWarning("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '%s'", qPrintable(xdgRuntimeDir));
+ } else {
+ fileInfo.setFile(xdgRuntimeDir);
+ if (!fileInfo.exists()) {
+ qWarning("QStandardPaths: XDG_RUNTIME_DIR points to non-existing path '%s', "
+ "please create it with 0700 permissions.", qPrintable(xdgRuntimeDir));
+ return QString();
+ }
+ if (!fileInfo.isDir()) {
+ qWarning("QStandardPaths: XDG_RUNTIME_DIR points to '%s' which is not a directory",
+ qPrintable(xdgRuntimeDir));
+ return QString();
+ }
}
// "The directory MUST be owned by the user"
- QFileInfo fileInfo(xdgRuntimeDir);
if (fileInfo.ownerId() != myUid) {
qWarning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d", qPrintable(xdgRuntimeDir),
fileInfo.ownerId(), myUid);
@@ -135,13 +147,15 @@ QString QStandardPaths::writableLocation(StandardLocation type)
}
// "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700."
// since the current user is the owner, set both xxxUser and xxxOwner
- QFile file(xdgRuntimeDir);
const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser
| QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
- if (file.permissions() != wantedPerms && !file.setPermissions(wantedPerms)) {
- qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s",
- qPrintable(xdgRuntimeDir), qPrintable(file.errorString()));
- return QString();
+ if (fileInfo.permissions() != wantedPerms) {
+ QFile file(xdgRuntimeDir);
+ if (!file.setPermissions(wantedPerms)) {
+ qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s",
+ qPrintable(xdgRuntimeDir), qPrintable(file.errorString()));
+ return QString();
+ }
}
return xdgRuntimeDir;
}
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index e5c31763f4..8e82f00f74 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -2470,8 +2470,10 @@ void QUrl::setPath(const QString &path, ParsingMode mode)
mode = TolerantMode;
}
- data = qt_normalizePathSegments(data, false);
- d->setPath(data, 0, data.length());
+ int from = 0;
+ while (from < data.length() - 2 && data.midRef(from, 2) == QLatin1String("//"))
+ ++from;
+ d->setPath(data, from, data.length());
// optimized out, since there is no path delimiter
// if (path.isNull())
diff --git a/src/corelib/io/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp
index c6ce15c2c9..c9de6671f7 100644
--- a/src/corelib/io/qwinoverlappedionotifier.cpp
+++ b/src/corelib/io/qwinoverlappedionotifier.cpp
@@ -102,7 +102,8 @@ public:
OVERLAPPED *waitForAnyNotified(int msecs);
void notify(DWORD numberOfBytes, DWORD errorCode, OVERLAPPED *overlapped);
- OVERLAPPED *_q_notified();
+ void _q_notified();
+ OVERLAPPED *dispatchNextIoResult();
static QWinIoCompletionPort *iocp;
static HANDLE iocpInstanceLock;
@@ -302,8 +303,7 @@ OVERLAPPED *QWinOverlappedIoNotifierPrivate::waitForAnyNotified(int msecs)
const DWORD wfso = WaitForSingleObject(hSemaphore, msecs == -1 ? INFINITE : DWORD(msecs));
switch (wfso) {
case WAIT_OBJECT_0:
- ReleaseSemaphore(hSemaphore, 1, NULL);
- return _q_notified();
+ return dispatchNextIoResult();
case WAIT_TIMEOUT:
return 0;
default:
@@ -385,17 +385,20 @@ void QWinOverlappedIoNotifierPrivate::notify(DWORD numberOfBytes, DWORD errorCod
emit q->_q_notify();
}
-OVERLAPPED *QWinOverlappedIoNotifierPrivate::_q_notified()
+void QWinOverlappedIoNotifierPrivate::_q_notified()
+{
+ if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0)
+ dispatchNextIoResult();
+}
+
+OVERLAPPED *QWinOverlappedIoNotifierPrivate::dispatchNextIoResult()
{
Q_Q(QWinOverlappedIoNotifier);
- if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0) {
- WaitForSingleObject(hResultsMutex, INFINITE);
- IOResult ioresult = results.dequeue();
- ReleaseMutex(hResultsMutex);
- emit q->notified(ioresult.numberOfBytes, ioresult.errorCode, ioresult.overlapped);
- return ioresult.overlapped;
- }
- return 0;
+ WaitForSingleObject(hResultsMutex, INFINITE);
+ IOResult ioresult = results.dequeue();
+ ReleaseMutex(hResultsMutex);
+ emit q->notified(ioresult.numberOfBytes, ioresult.errorCode, ioresult.overlapped);
+ return ioresult.overlapped;
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qwinoverlappedionotifier_p.h b/src/corelib/io/qwinoverlappedionotifier_p.h
index 863f87353e..41945d6556 100644
--- a/src/corelib/io/qwinoverlappedionotifier_p.h
+++ b/src/corelib/io/qwinoverlappedionotifier_p.h
@@ -58,7 +58,7 @@ class Q_CORE_EXPORT QWinOverlappedIoNotifier : public QObject
Q_OBJECT
Q_DISABLE_COPY(QWinOverlappedIoNotifier)
Q_DECLARE_PRIVATE(QWinOverlappedIoNotifier)
- Q_PRIVATE_SLOT(d_func(), OVERLAPPED *_q_notified())
+ Q_PRIVATE_SLOT(d_func(), void _q_notified())
friend class QWinIoCompletionPort;
public:
QWinOverlappedIoNotifier(QObject *parent = 0);
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index 328e07d18e..76e5ae562f 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -420,6 +420,18 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant)
return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
case QVariant::Hash:
return QJsonValue(QJsonObject::fromVariantHash(variant.toHash()));
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QJsonValue:
+ return variant.toJsonValue();
+ case QMetaType::QJsonObject:
+ return variant.toJsonObject();
+ case QMetaType::QJsonArray:
+ return variant.toJsonArray();
+ case QMetaType::QJsonDocument: {
+ QJsonDocument doc = variant.toJsonDocument();
+ return doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object());
+ }
+#endif
default:
break;
}
diff --git a/src/corelib/kernel/qfunctions_fake_env_p.h b/src/corelib/kernel/qfunctions_fake_env_p.h
index 8b1ab44696..b4c5ffb079 100644
--- a/src/corelib/kernel/qfunctions_fake_env_p.h
+++ b/src/corelib/kernel/qfunctions_fake_env_p.h
@@ -46,51 +46,72 @@
//
#include "qbytearray.h"
-#include "qhash.h"
+#include "qvector.h"
QT_BEGIN_NAMESPACE
// Environment ------------------------------------------------------
-Q_CORE_EXPORT QHash<QByteArray, QByteArray> &qt_app_environment()
-{
- static QHash<QByteArray, QByteArray> internalEnvironment;
- return internalEnvironment;
-}
+struct Variable {
+ Variable() { }
+
+ Variable(const QByteArray &name, const QByteArray &value)
+ : name(name), value(value) { }
+
+ QByteArray name;
+ QByteArray value;
+};
+
+Q_DECLARE_TYPEINFO(Variable, Q_MOVABLE_TYPE);
+
+struct NameEquals {
+ typedef bool result_type;
+ const char *name;
+ explicit NameEquals(const char *name) Q_DECL_NOTHROW : name(name) {}
+ result_type operator()(const Variable &other) const Q_DECL_NOTHROW
+ { return qstrcmp(other.name, name) == 0; }
+};
+
+Q_GLOBAL_STATIC(QVector<Variable>, qt_app_environment)
errno_t qt_fake_getenv_s(size_t *sizeNeeded, char *buffer, size_t bufferSize, const char *varName)
{
if (!sizeNeeded)
return EINVAL;
- QHash<QByteArray, QByteArray>::const_iterator iterator = qt_app_environment().constFind(varName);
- if (iterator == qt_app_environment().constEnd()) {
+ QVector<Variable>::const_iterator end = qt_app_environment->constEnd();
+ QVector<Variable>::const_iterator iterator = std::find_if(qt_app_environment->constBegin(),
+ end,
+ NameEquals(varName));
+ if (iterator == end) {
if (buffer)
buffer[0] = '\0';
return ENOENT;
}
- const int size = iterator->size() + 1;
+ const int size = iterator->value.size() + 1;
if (bufferSize < size_t(size)) {
*sizeNeeded = size;
return ERANGE;
}
- qstrcpy(buffer, iterator->constData());
+ qstrcpy(buffer, iterator->value.constData());
return 0;
}
errno_t qt_fake__putenv_s(const char *varName, const char *value)
{
- QHash<QByteArray, QByteArray>::iterator iterator = qt_app_environment().find(varName);
- QHash<QByteArray, QByteArray>::iterator end = qt_app_environment().end();
+ QVector<Variable>::iterator end = qt_app_environment->end();
+ QVector<Variable>::iterator iterator = std::find_if(qt_app_environment->begin(),
+ end,
+ NameEquals(varName));
if (!value || !*value) {
if (iterator != end)
- qt_app_environment().erase(iterator);
+ qt_app_environment->erase(iterator);
} else {
if (iterator == end)
- qt_app_environment()[varName] = QByteArray(value);
+ qt_app_environment->append(Variable(varName, value));
else
- (*iterator) = value;
+ iterator->value = value;
}
return 0;
diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h
index ee4e050793..dc1cbe0ade 100644
--- a/src/corelib/kernel/qfunctions_winrt.h
+++ b/src/corelib/kernel/qfunctions_winrt.h
@@ -40,6 +40,7 @@
#include <QtCore/QThread>
#include <QtCore/QAbstractEventDispatcher>
+#include <QtCore/QElapsedTimer>
#include <QtCore/qt_windows.h>
// Convenience macros for handling HRESULT values
@@ -160,7 +161,7 @@ enum AwaitStyle
};
template <typename T>
-static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, AwaitStyle awaitStyle)
+static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, AwaitStyle awaitStyle, uint timeout)
{
Microsoft::WRL::ComPtr<IAsyncInfo> asyncInfo;
HRESULT hr = asyncOp.As(&asyncInfo);
@@ -168,22 +169,34 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, Awai
return hr;
AsyncStatus status;
+ QElapsedTimer t;
+ if (timeout)
+ t.start();
switch (awaitStyle) {
case ProcessMainThreadEvents:
- while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started)
+ while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started) {
QCoreApplication::processEvents();
+ if (timeout && t.hasExpired(timeout))
+ return ERROR_TIMEOUT;
+ }
break;
case ProcessThreadEvents:
if (QAbstractEventDispatcher *dispatcher = QThread::currentThread()->eventDispatcher()) {
- while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started)
+ while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started) {
dispatcher->processEvents(QEventLoop::AllEvents);
+ if (timeout && t.hasExpired(timeout))
+ return ERROR_TIMEOUT;
+ }
break;
}
// fall through
default:
case YieldThread:
- while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started)
+ while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started) {
QThread::yieldCurrentThread();
+ if (timeout && t.hasExpired(timeout))
+ return ERROR_TIMEOUT;
+ }
break;
}
@@ -199,9 +212,9 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, Awai
}
template <typename T>
-static inline HRESULT await(const Microsoft::WRL::ComPtr<T> &asyncOp, AwaitStyle awaitStyle = YieldThread)
+static inline HRESULT await(const Microsoft::WRL::ComPtr<T> &asyncOp, AwaitStyle awaitStyle = YieldThread, uint timeout = 0)
{
- HRESULT hr = _await_impl(asyncOp, awaitStyle);
+ HRESULT hr = _await_impl(asyncOp, awaitStyle, timeout);
if (FAILED(hr))
return hr;
@@ -209,9 +222,9 @@ static inline HRESULT await(const Microsoft::WRL::ComPtr<T> &asyncOp, AwaitStyle
}
template <typename T, typename U>
-static inline HRESULT await(const Microsoft::WRL::ComPtr<T> &asyncOp, U *results, AwaitStyle awaitStyle = YieldThread)
+static inline HRESULT await(const Microsoft::WRL::ComPtr<T> &asyncOp, U *results, AwaitStyle awaitStyle = YieldThread, uint timeout = 0)
{
- HRESULT hr = _await_impl(asyncOp, awaitStyle);
+ HRESULT hr = _await_impl(asyncOp, awaitStyle, timeout);
if (FAILED(hr))
return hr;
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index 764ac55563..012bc72b6e 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -355,9 +355,10 @@ QMimeType QMimeDatabase::mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mo
#ifdef Q_OS_UNIX
// Cannot access statBuf.st_mode from the filesystem engine, so we have to stat again.
+ // In addition we want to follow symlinks.
const QByteArray nativeFilePath = QFile::encodeName(file.fileName());
QT_STATBUF statBuffer;
- if (QT_LSTAT(nativeFilePath.constData(), &statBuffer) == 0) {
+ if (QT_STAT(nativeFilePath.constData(), &statBuffer) == 0) {
if (S_ISCHR(statBuffer.st_mode))
return d->mimeTypeForName(QLatin1String("inode/chardevice"));
if (S_ISBLK(statBuffer.st_mode))
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index c23e7ace15..69f7572b34 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -204,8 +204,8 @@ void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority)
++runnable->ref;
// put it on the queue
- QList<QPair<QRunnable *, int> >::const_iterator begin = queue.constBegin();
- QList<QPair<QRunnable *, int> >::const_iterator it = queue.constEnd();
+ QVector<QPair<QRunnable *, int> >::const_iterator begin = queue.constBegin();
+ QVector<QPair<QRunnable *, int> >::const_iterator it = queue.constEnd();
if (it != begin && priority > (*(it - 1)).second)
it = std::upper_bound(begin, --it, priority);
queue.insert(it - begin, qMakePair(runnable, priority));
@@ -299,7 +299,7 @@ bool QThreadPoolPrivate::waitForDone(int msecs)
void QThreadPoolPrivate::clear()
{
QMutexLocker locker(&mutex);
- for (QList<QPair<QRunnable *, int> >::const_iterator it = queue.constBegin();
+ for (QVector<QPair<QRunnable *, int> >::const_iterator it = queue.constBegin();
it != queue.constEnd(); ++it) {
QRunnable* r = it->first;
if (r->autoDelete() && !--r->ref)
@@ -319,8 +319,8 @@ bool QThreadPoolPrivate::stealRunnable(QRunnable *runnable)
return false;
{
QMutexLocker locker(&mutex);
- QList<QPair<QRunnable *, int> >::iterator it = queue.begin();
- QList<QPair<QRunnable *, int> >::iterator end = queue.end();
+ QVector<QPair<QRunnable *, int> >::iterator it = queue.begin();
+ QVector<QPair<QRunnable *, int> >::iterator end = queue.end();
while (it != end) {
if (it->first == runnable) {
diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h
index 34728ed3e2..b03eefcc94 100644
--- a/src/corelib/thread/qthreadpool_p.h
+++ b/src/corelib/thread/qthreadpool_p.h
@@ -83,7 +83,7 @@ public:
QSet<QThreadPoolThread *> allThreads;
QQueue<QThreadPoolThread *> waitingThreads;
QQueue<QThreadPoolThread *> expiredThreads;
- QList<QPair<QRunnable *, int> > queue;
+ QVector<QPair<QRunnable *, int> > queue;
QWaitCondition noActiveThreads;
bool isExiting;
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 317ace57e4..1b260dd122 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -540,7 +540,13 @@ static inline bool displayMessageBox()
static void showParserMessage(const QString &message, MessageType type)
{
-#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
+ if (type == UsageMessage)
+ qInfo(qPrintable(message));
+ else
+ qCritical(qPrintable(message));
+ return;
+#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE)
if (displayMessageBox()) {
const UINT flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND
| (type == UsageMessage ? MB_ICONINFORMATION : MB_ICONERROR);
@@ -553,7 +559,7 @@ static void showParserMessage(const QString &message, MessageType type)
reinterpret_cast<const wchar_t *>(title.utf16()), flags);
return;
}
-#endif // Q_OS_WIN && !QT_BOOTSTRAPPED && !Q_OS_WIN && !Q_OS_WINRT
+#endif // Q_OS_WIN && !QT_BOOTSTRAPPED && !Q_OS_WINCE
fputs(qPrintable(message), type == UsageMessage ? stdout : stderr);
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index d4a589424e..55289fa0e7 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1675,20 +1675,11 @@ void QString::resize(int size)
return;
}
- if (size == 0 && !d->capacityReserved) {
- Data *x = Data::allocate(0);
- if (!d->ref.deref())
- Data::deallocate(d);
- d = x;
- } else {
- if (d->ref.isShared() || uint(size) + 1u > d->alloc
- || (!d->capacityReserved && size < d->size
- && uint(size) + 1u < uint(d->alloc >> 1)))
- reallocData(uint(size) + 1u, true);
- if (d->alloc) {
- d->size = size;
- d->data()[size] = '\0';
- }
+ if (d->ref.isShared() || uint(size) + 1u > d->alloc)
+ reallocData(uint(size) + 1u, true);
+ if (d->alloc) {
+ d->size = size;
+ d->data()[size] = '\0';
}
}