From 265d309cb0a423b5dd6b43a8b7354b96a0f341a1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 27 Oct 2016 15:10:09 +0200 Subject: configure: fix usage of pkg-config from qmakespec the spec (possibly) provides QMAKE_PKG_CONFIG. PKG_CONFIG is dynamically determined on use. Change-Id: I45b7f4eddeff5d28539021472ef9036dd397d61e Reviewed-by: Lars Knoll --- configure.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.pri b/configure.pri index b69dbf3709..cdc13ff87c 100644 --- a/configure.pri +++ b/configure.pri @@ -124,7 +124,7 @@ defineTest(qtConfTest_detectPkgConfig) { !isEmpty(pkgConfig): { qtLog("Found pkg-config from environment variable: $$pkgConfig") } else { - pkgConfig = $$PKG_CONFIG + pkgConfig = $$QMAKE_PKG_CONFIG !isEmpty(pkgConfig) { qtLog("Found pkg-config from mkspec: $$pkgConfig") -- cgit v1.2.3 From 0239b4f21705af3c47ebfda34fa354ecc865c52d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 27 Oct 2016 15:43:08 +0200 Subject: decouple packageExists() and PKGCONFIG from qt configuration users may want to use pkg-config regardless of whether qt itself was built with it. that's particularly relevant when using binary packages on macos while trying to use 3rd party dependencies from homebrew. Task-number: QTBUG-36256 Change-Id: I15e6d0bf5cdaff4274e2d7c07917e97f29157a5c Reviewed-by: Massimo Callegari Reviewed-by: Lars Knoll --- mkspecs/features/qt_functions.prf | 62 +++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 708815d9f9..999cd18154 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -235,17 +235,58 @@ defineTest(qtAddTargetEnv) { defineReplace(pkgConfigExecutable) { isEmpty(PKG_CONFIG) { - !isEmpty(QMAKE_PKG_CONFIG): \ + !isEmpty(QMAKE_PKG_CONFIG) { + # Assumed to be properly sysrootified. PKG_CONFIG = $$QMAKE_PKG_CONFIG - else: \ + export(PKG_CONFIG) + } else { PKG_CONFIG = pkg-config + !cross_compile { + export(PKG_CONFIG) + } else { + # Cross compiling, ensure that pkg-config is set up sanely. + sysroot = $$[QT_SYSROOT] + + pkgConfigLibdir = $$(PKG_CONFIG_LIBDIR) + isEmpty(pkgConfigLibdir) { + isEmpty(sysroot) { + warning("Cross compiling without sysroot. Disabling pkg-config.") + return() + } + !exists("$$sysroot/usr/lib/pkgconfig") { + warning("Disabling pkg-config since PKG_CONFIG_LIBDIR is not set and the") + warning("host's .pc files would be used (even if you set PKG_CONFIG_PATH).") + warning("Set this variable to the directory that contains target .pc files") + warning("for pkg-config to function correctly when cross-compiling.") + return() + } + + pkgConfigLibdir = $$system_path($$sysroot/usr/lib/pkgconfig)$$QMAKE_DIRLIST_SEP$$system_path($$sysroot/usr/share/pkgconfig) + !isEmpty(GCC_MACHINE_DUMP): \ + pkgConfigLibdir = "$$pkgConfigLibdir$$QMAKE_DIRLIST_SEP$$system_path($$sysroot/usr/lib/$$GCC_MACHINE_DUMP/pkgconfig)" + message("PKG_CONFIG_LIBDIR automatically set to $$pkgConfigLibdir") + } + pkgConfigSysrootDir = $$(PKG_CONFIG_SYSROOT_DIR) + isEmpty(pkgConfigSysrootDir) { + isEmpty(sysroot) { + warning("Disabling pkg-config since PKG_CONFIG_SYSROOT_DIR is not set.") + warning("Set this variable to your sysroot for pkg-config to function") + warning("correctly when cross-compiling.") + return() + } - sysroot.name = PKG_CONFIG_SYSROOT_DIR - sysroot.value = $$PKG_CONFIG_SYSROOT_DIR - libdir.name = PKG_CONFIG_LIBDIR - libdir.value = $$PKG_CONFIG_LIBDIR - QT_TOOL_NAME = pkg-config - qtAddToolEnv(PKG_CONFIG, sysroot libdir, SYS) + pkgConfigSysrootDir = $$sysroot + message("PKG_CONFIG_SYSROOT_DIR automatically set to $$pkgConfigSysrootDir") + } + + sysroot.name = PKG_CONFIG_SYSROOT_DIR + sysroot.value = $$pkgConfigSysrootDir + libdir.name = PKG_CONFIG_LIBDIR + libdir.value = $$pkgConfigLibdir + QT_TOOL_NAME = pkg-config + qtAddToolEnv(PKG_CONFIG, sysroot libdir, SYS) + } + } } equals(QMAKE_HOST.os, Windows): \ @@ -257,11 +298,6 @@ defineReplace(pkgConfigExecutable) { } defineTest(packagesExist) { - !qtConfig(pkg-config) { - warning("pkg-config disabled, can't check package existence") - return(false) - } - # this can't be done in global scope here because qt_functions is loaded # before the .pro is parsed, so if the .pro set PKG_CONFIG, we wouldn't know it # yet. oops. -- cgit v1.2.3 From 147b7d9da2656c23d7ca7ed38e408a61ed605c6d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 1 Nov 2016 11:21:20 +0100 Subject: remove bogus freetype dependency stuff fixes rebase FAIL in f9a80e06a. the ft dependency itself is pulled in via the basic font database, which is included if ft is used. Change-Id: I4e9c0c44bd0360b702953e51cde4c5d526eff499 Reviewed-by: Friedemann Kleint --- src/platformsupport/fontdatabases/windows/windows.pri | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/platformsupport/fontdatabases/windows/windows.pri b/src/platformsupport/fontdatabases/windows/windows.pri index 419c4dc6d9..4fc4e7b8ec 100644 --- a/src/platformsupport/fontdatabases/windows/windows.pri +++ b/src/platformsupport/fontdatabases/windows/windows.pri @@ -13,11 +13,6 @@ HEADERS += \ qtConfig(freetype) { SOURCES += $$PWD/qwindowsfontdatabase_ft.cpp HEADERS += $$PWD/qwindowsfontdatabase_ft_p.h - qtConfig(system-freetype) { - include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri) - } else { - include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri) - } } qtConfig(directwrite) { -- cgit v1.2.3 From c12f42e91b146109cc9ee5d050928672776ca1ee Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 26 Oct 2016 20:53:23 +0300 Subject: QString: optimize replace(QChar, QChar, Qt::CaseSensitivity) Only detach() if the string does contain the character to be replaced. Save memory allocations. Change-Id: I69c070d3f0b99f505fb6c209f657cdce31a35461 Reviewed-by: Edward Welbourne --- src/corelib/tools/qstring.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 8db865cfa6..27d8c14583 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2633,21 +2633,28 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs */ QString& QString::replace(QChar before, QChar after, Qt::CaseSensitivity cs) { - ushort a = after.unicode(); - ushort b = before.unicode(); if (d->size) { - detach(); - ushort *i = d->data(); - const ushort *e = i + d->size; - if (cs == Qt::CaseSensitive) { - for (; i != e; ++i) - if (*i == b) - *i = a; - } else { - b = foldCase(b); - for (; i != e; ++i) - if (foldCase(*i) == b) - *i = a; + const int idx = indexOf(before, 0, cs); + if (idx != -1) { + detach(); + const ushort a = after.unicode(); + ushort *i = d->data(); + const ushort *e = i + d->size; + i += idx; + *i = a; + if (cs == Qt::CaseSensitive) { + const ushort b = before.unicode(); + while (++i != e) { + if (*i == b) + *i = a; + } + } else { + const ushort b = foldCase(before.unicode()); + while (++i != e) { + if (foldCase(*i) == b) + *i = a; + } + } } } return *this; -- cgit v1.2.3 From 71166288cb71b58eb7a84b70e92a10396cdf9ee4 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 21 Oct 2016 11:46:49 +0200 Subject: Add QNetworkProxy::usesSystemConfiguration() accessor Allow to check programmatically whether using the system proxy settings is enabled. To implement this the QSystemConfigurationProxyFactory is replaced by an explicit boolean in QGlobalNetworkProxy. Change-Id: I52231b4ffc890b085bcd1739acf93c97bdb18eb5 Reviewed-by: Timur Pocheptsov --- src/network/kernel/kernel.pri | 1 - src/network/kernel/qnetworkproxy.cpp | 72 +++++++++++++++++++++++-------- src/network/kernel/qnetworkproxy.h | 1 + src/network/kernel/qnetworkproxy_p.h | 84 ------------------------------------ 4 files changed, 55 insertions(+), 103 deletions(-) delete mode 100644 src/network/kernel/qnetworkproxy_p.h diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index 8f37e28669..005f000c25 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -18,7 +18,6 @@ HEADERS += kernel/qtnetworkglobal.h \ kernel/qnetworkinterface.h \ kernel/qnetworkinterface_p.h \ kernel/qnetworkproxy.h \ - kernel/qnetworkproxy_p.h \ kernel/qurlinfo_p.h SOURCES += kernel/qauthenticator.cpp \ diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index bb1a7d0d8b..94719e9c2d 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -224,7 +224,6 @@ #ifndef QT_NO_NETWORKPROXY -#include "private/qnetworkproxy_p.h" #include "private/qnetworkrequest_p.h" #include "private/qsocks5socketengine_p.h" #include "private/qhttpsocketengine_p.h" @@ -256,10 +255,12 @@ public: #ifndef QT_NO_HTTP , httpSocketEngineHandler(0) #endif - { #ifdef QT_USE_SYSTEM_PROXIES - setApplicationProxyFactory(new QSystemConfigurationProxyFactory); + , useSystemProxies(true) +#else + , useSystemProxies(false) #endif + { #ifndef QT_NO_SOCKS5 socks5SocketEngineHandler = new QSocks5SocketEngineHandler(); #endif @@ -280,6 +281,24 @@ public: #endif } + bool usesSystemConfiguration() const + { + return useSystemProxies; + } + + void setUseSystemConfiguration(bool enable) + { + QMutexLocker lock(&mutex); + useSystemProxies = enable; + + if (useSystemProxies) { + if (applicationLevelProxy) + *applicationLevelProxy = QNetworkProxy(); + delete applicationLevelProxyFactory; + applicationLevelProxyFactory = nullptr; + } + } + void setApplicationProxy(const QNetworkProxy &proxy) { QMutexLocker lock(&mutex); @@ -288,6 +307,7 @@ public: *applicationLevelProxy = proxy; delete applicationLevelProxyFactory; applicationLevelProxyFactory = 0; + useSystemProxies = false; } void setApplicationProxyFactory(QNetworkProxyFactory *factory) @@ -299,6 +319,7 @@ public: *applicationLevelProxy = QNetworkProxy(); delete applicationLevelProxyFactory; applicationLevelProxyFactory = factory; + useSystemProxies = false; } QNetworkProxy applicationProxy() @@ -318,6 +339,7 @@ private: #ifndef QT_NO_HTTP QHttpSocketEngineHandler *httpSocketEngineHandler; #endif + bool useSystemProxies; }; QList QGlobalNetworkProxy::proxyForQuery(const QNetworkProxyQuery &query) @@ -339,10 +361,19 @@ QList QGlobalNetworkProxy::proxyForQuery(const QNetworkProxyQuery if (!applicationLevelProxyFactory) { if (applicationLevelProxy - && applicationLevelProxy->type() != QNetworkProxy::DefaultProxy) + && applicationLevelProxy->type() != QNetworkProxy::DefaultProxy) { result << *applicationLevelProxy; - else + } else if (useSystemProxies) { + result = QNetworkProxyFactory::systemProxyForQuery(query); + + // Make sure NoProxy is in the list, so that QTcpServer can work: + // it searches for the first proxy that can has the ListeningCapability capability + // if none have (as is the case with HTTP proxies), it fails to bind. + // NoProxy allows it to fallback to the 'no proxy' case and bind. + result << QNetworkProxy(QNetworkProxy::NoProxy); + } else { result << QNetworkProxy(QNetworkProxy::NoProxy); + } return result; } @@ -717,7 +748,8 @@ quint16 QNetworkProxy::port() const Setting a default proxy value with this function will override the application proxy factory set with - QNetworkProxyFactory::setApplicationProxyFactory. + QNetworkProxyFactory::setApplicationProxyFactory, and disable the + use of a system proxy. \sa QNetworkProxyFactory, applicationProxy(), QAbstractSocket::setProxy(), QTcpServer::setProxy() */ @@ -1465,6 +1497,17 @@ QNetworkProxyFactory::~QNetworkProxyFactory() { } +/*! + \since 5.8 + + Returns whether the use of platform-specific proxy settings are enabled. +*/ +bool QNetworkProxyFactory::usesSystemConfiguration() +{ + if (globalNetworkProxy()) + return globalNetworkProxy()->usesSystemConfiguration(); + return false; +} /*! \since 4.6 @@ -1472,23 +1515,16 @@ QNetworkProxyFactory::~QNetworkProxyFactory() Enables the use of the platform-specific proxy settings, and only those. See systemProxyForQuery() for more information. - Internally, this method (when called with \a enable set to true) - sets an application-wide proxy factory. For this reason, this method - is mutually exclusive with setApplicationProxyFactory(): calling - setApplicationProxyFactory() overrides the use of the system-wide proxy, - and calling setUseSystemConfiguration() overrides any - application proxy or proxy factory that was previously set. + Calling setUseSystemConfiguration(\c{true}) will reset any proxy or + QNetworkProxyFactory already set. \note See the systemProxyForQuery() documentation for a list of limitations related to the use of system proxies. */ void QNetworkProxyFactory::setUseSystemConfiguration(bool enable) { - if (enable) { - setApplicationProxyFactory(new QSystemConfigurationProxyFactory); - } else { - setApplicationProxyFactory(0); - } + if (globalNetworkProxy()) + globalNetworkProxy()->setUseSystemConfiguration(enable); } /*! @@ -1504,7 +1540,7 @@ void QNetworkProxyFactory::setUseSystemConfiguration(bool enable) If you set a proxy factory with this function, any application level proxies set with QNetworkProxy::setApplicationProxy will be - overridden. + overridden, and usesSystemConfiguration() will return \c{false}. \sa QNetworkProxy::setApplicationProxy(), QAbstractSocket::proxy(), QAbstractSocket::setProxy() diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h index fc919a24a6..8fcb7e33cf 100644 --- a/src/network/kernel/qnetworkproxy.h +++ b/src/network/kernel/qnetworkproxy.h @@ -213,6 +213,7 @@ public: virtual QList queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0; + static bool usesSystemConfiguration(); static void setUseSystemConfiguration(bool enable); static void setApplicationProxyFactory(QNetworkProxyFactory *factory); static QList proxyForQuery(const QNetworkProxyQuery &query); diff --git a/src/network/kernel/qnetworkproxy_p.h b/src/network/kernel/qnetworkproxy_p.h deleted file mode 100644 index 733d8436d0..0000000000 --- a/src/network/kernel/qnetworkproxy_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 David Faure -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QNETWORKPROXY_P_H -#define QNETWORKPROXY_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 - -#ifndef QT_NO_NETWORKPROXY - -QT_BEGIN_NAMESPACE - -class QSystemConfigurationProxyFactory : public QNetworkProxyFactory -{ -public: - QSystemConfigurationProxyFactory() : QNetworkProxyFactory() {} - - virtual QList queryProxy(const QNetworkProxyQuery& query) - { - QList proxies = QNetworkProxyFactory::systemProxyForQuery(query); - - // Make sure NoProxy is in the list, so that QTcpServer can work: - // it searches for the first proxy that can has the ListeningCapability capability - // if none have (as is the case with HTTP proxies), it fails to bind. - // NoProxy allows it to fallback to the 'no proxy' case and bind. - proxies.append(QNetworkProxy::NoProxy); - - return proxies; - } -}; - -QT_END_NAMESPACE - -#endif // QT_NO_NETWORKINTERFACE - -#endif - -- cgit v1.2.3 From e1f29814daf1ea81b05cc95cc5d187eea362af67 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 1 Nov 2016 14:48:16 +0100 Subject: winrt: Proper guarding by readMutex Commented its purpose and the guarded members for readMutex. Fixed places where guarded members were accessed without using the mutex. Use QMutexLocker instead of manually (un-)locking the mutex. Task-number: QTBUG-44357 Change-Id: I0d46f9592d5a9d1b52e73df961785a6f6c9e80be Reviewed-by: David Faure --- src/network/socket/qnativesocketengine_winrt.cpp | 12 +++++++----- src/network/socket/qnativesocketengine_winrt_p.h | 13 ++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index f8e92d3f50..f710f6b142 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -659,6 +659,7 @@ qint64 QNativeSocketEngine::read(char *data, qint64 maxlen) if (d->socketType != QAbstractSocket::TcpSocket) return -1; + QMutexLocker mutexLocker(&d->readMutex); // There will be a read notification when the socket was closed by the remote host. If that // happens and there isn't anything left in the buffer, we have to return -1 in order to signal // the closing of the socket. @@ -667,7 +668,6 @@ qint64 QNativeSocketEngine::read(char *data, qint64 maxlen) return -1; } - QMutexLocker mutexLocker(&d->readMutex); qint64 b = d->readBytes.read(data, maxlen); d->bytesAvailable = d->readBytes.size() - d->readBytes.pos(); return b; @@ -701,7 +701,7 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea { #ifndef QT_NO_UDPSOCKET Q_D(QNativeSocketEngine); - d->readMutex.lock(); + QMutexLocker locker(&d->readMutex); if (d->socketType != QAbstractSocket::UdpSocket || d->pendingDatagrams.isEmpty()) { if (header) header->clear(); @@ -721,7 +721,7 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea } else { readOrigin = datagram.data; } - d->readMutex.unlock(); + locker.unlock(); memcpy(data, readOrigin, qMin(maxlen, qint64(datagram.data.length()))); return readOrigin.length(); #else @@ -772,12 +772,14 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 len, const QI bool QNativeSocketEngine::hasPendingDatagrams() const { Q_D(const QNativeSocketEngine); + QMutexLocker locker(&d->readMutex); return d->pendingDatagrams.length() > 0; } qint64 QNativeSocketEngine::pendingDatagramSize() const { Q_D(const QNativeSocketEngine); + QMutexLocker locker(&d->readMutex); if (d->pendingDatagrams.isEmpty()) return -1; @@ -1465,7 +1467,7 @@ HRESULT QNativeSocketEnginePrivate::handleReadyRead(IAsyncBufferOperation *async hr = byteArrayAccess->Buffer(&data); Q_ASSERT_SUCCEEDED(hr); - readMutex.lock(); + QMutexLocker readLocker(&readMutex); if (readBytes.atEnd()) // Everything has been read; the buffer is safe to reset readBytes.close(); if (!readBytes.isOpen()) @@ -1476,7 +1478,7 @@ HRESULT QNativeSocketEnginePrivate::handleReadyRead(IAsyncBufferOperation *async readBytes.write(reinterpret_cast(data), qint64(bufferLength)); readBytes.seek(readPos); bytesAvailable = readBytes.size() - readBytes.pos(); - readMutex.unlock(); + readLocker.unlock(); if (notifyOnRead) emit q->readReady(); diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h index 79530d57f1..c9a67ca5f4 100644 --- a/src/network/socket/qnativesocketengine_winrt_p.h +++ b/src/network/socket/qnativesocketengine_winrt_p.h @@ -215,12 +215,23 @@ private: Microsoft::WRL::ComPtr tcpListener; Microsoft::WRL::ComPtr connectOp; QVector>> pendingReadOps; + + // Protected by readMutex. Written in handleReadyRead (native callback) QBuffer readBytes; - QMutex readMutex; + + // In case of TCP readMutex protects readBytes and bytesAvailable. In case of UDP it is + // pendingDatagrams. They are written inside native callbacks (handleReadyRead and + // handleNewDatagrams/putIntoPendingDatagramsList) + mutable QMutex readMutex; + bool emitOnNewDatagram; + + // Protected by readMutex. Written in handleReadyRead (native callback) QAtomicInteger bytesAvailable; + // Protected by readMutex. Written in handleNewDatagrams/putIntoPendingDatagramsList QList pendingDatagrams; + QList pendingConnections; QList currentConnections; QEventLoop eventLoop; -- cgit v1.2.3 From b787977ba0c266c157db9d0275e0fe9b7ae5d35f Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 1 Nov 2016 14:48:16 +0100 Subject: winrt: Guard pendingReadOps with mutex As the list is changed inside a native callback (handleReadyRead) which can be run inside another thread it has to be protected by a mutex. Change-Id: I145a866a36a12b7ea9bfa9f99ad9f7add872a021 Reviewed-by: Maurice Kalinowski Reviewed-by: David Faure --- src/network/socket/qnativesocketengine_winrt.cpp | 7 +++++++ src/network/socket/qnativesocketengine_winrt_p.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index f710f6b142..7ea4d135f4 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -329,6 +329,7 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, readOp.GetAddressOf()); RETURN_OK_IF_FAILED_WITH_ARGS("initialize(): Failed to read from the socket buffer (%s).", socketDescription(this).constData()); + QMutexLocker locker(&d->readOperationsMutex); d->pendingReadOps.append(readOp); d->socketState = socketState; hr = readOp->put_Completed(Callback(d, &QNativeSocketEnginePrivate::handleReadyRead).Get()); @@ -574,6 +575,7 @@ void QNativeSocketEngine::close() } #endif // _MSC_VER >= 1900 + QMutexLocker locker(&d->readOperationsMutex); for (ComPtr readOp : d->pendingReadOps) { ComPtr info; hr = readOp.As(&info); @@ -585,6 +587,7 @@ void QNativeSocketEngine::close() Q_ASSERT_SUCCEEDED(hr); } } + locker.unlock(); if (d->socketDescriptor != -1) { ComPtr socket; @@ -945,6 +948,7 @@ void QNativeSocketEngine::establishRead() ComPtr readOp; hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, readOp.GetAddressOf()); RETURN_HR_IF_FAILED("establishRead(): Failed to initiate socket read"); + QMutexLocker locker(&d->readOperationsMutex); d->pendingReadOps.append(readOp); hr = readOp->put_Completed(Callback(d, &QNativeSocketEnginePrivate::handleReadyRead).Get()); RETURN_HR_IF_FAILED("establishRead(): Failed to register read callback"); @@ -1421,12 +1425,14 @@ HRESULT QNativeSocketEnginePrivate::handleReadyRead(IAsyncBufferOperation *async } Q_Q(QNativeSocketEngine); + QMutexLocker locker(&readOperationsMutex); for (int i = 0; i < pendingReadOps.count(); ++i) { if (pendingReadOps.at(i).Get() == asyncInfo) { pendingReadOps.takeAt(i); break; } } + locker.unlock(); static QMutex mutex; mutex.lock(); @@ -1503,6 +1509,7 @@ HRESULT QNativeSocketEnginePrivate::handleReadyRead(IAsyncBufferOperation *async socketDescription(q).constData()); return S_OK; } + QMutexLocker locker(&readOperationsMutex); pendingReadOps.append(readOp); hr = readOp->put_Completed(Callback(this, &QNativeSocketEnginePrivate::handleReadyRead).Get()); if (FAILED(hr)) { diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h index c9a67ca5f4..e01d205896 100644 --- a/src/network/socket/qnativesocketengine_winrt_p.h +++ b/src/network/socket/qnativesocketengine_winrt_p.h @@ -214,6 +214,8 @@ private: { return reinterpret_cast(socketDescriptor); } Microsoft::WRL::ComPtr tcpListener; Microsoft::WRL::ComPtr connectOp; + + // Protected by readOperationsMutex. Written in handleReadyRead (native callback) QVector>> pendingReadOps; // Protected by readMutex. Written in handleReadyRead (native callback) @@ -224,6 +226,9 @@ private: // handleNewDatagrams/putIntoPendingDatagramsList) mutable QMutex readMutex; + // As pendingReadOps is changed inside handleReadyRead(native callback) it has to be protected + QMutex readOperationsMutex; + bool emitOnNewDatagram; // Protected by readMutex. Written in handleReadyRead (native callback) -- cgit v1.2.3 From 67c6d0f54ea6244ef9c1af737ab8cbe35815f694 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 1 Nov 2016 14:42:35 +0100 Subject: winrt: Remove static mutex that protected handleReadyRead At the point in time when the callback is called it is very unlikely that another thread sets the state or error of the socket engine. Other members (readBytes, bytesAvailable) are protected by readMutex. Change-Id: I76cf12fbc9019d1b42846c4b40e0cd1c06bbb220 Reviewed-by: David Faure --- src/network/socket/qnativesocketengine_winrt.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 7ea4d135f4..62bc8ca683 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -1434,8 +1434,6 @@ HRESULT QNativeSocketEnginePrivate::handleReadyRead(IAsyncBufferOperation *async } locker.unlock(); - static QMutex mutex; - mutex.lock(); // A read in UnconnectedState will close the socket and return -1 and thus tell the caller, // that the connection was closed. The socket cannot be closed here, as the subsequent read // might fail then. @@ -1488,7 +1486,6 @@ HRESULT QNativeSocketEnginePrivate::handleReadyRead(IAsyncBufferOperation *async if (notifyOnRead) emit q->readReady(); - mutex.unlock(); hr = QEventDispatcherWinRT::runOnXamlThread([buffer, q, this]() { UINT32 readBufferLength; -- cgit v1.2.3 From 181bb447f55d174654e742d24206068fb119ff72 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 1 Nov 2016 14:53:29 +0100 Subject: winrt: Removed unused member variable from socket engine Change-Id: I3255c1fb10e053f9a9a1753ad0a0b6969d8a8cfe Reviewed-by: David Faure --- src/network/socket/qnativesocketengine_winrt_p.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h index e01d205896..085704275c 100644 --- a/src/network/socket/qnativesocketengine_winrt_p.h +++ b/src/network/socket/qnativesocketengine_winrt_p.h @@ -229,8 +229,6 @@ private: // As pendingReadOps is changed inside handleReadyRead(native callback) it has to be protected QMutex readOperationsMutex; - bool emitOnNewDatagram; - // Protected by readMutex. Written in handleReadyRead (native callback) QAtomicInteger bytesAvailable; -- cgit v1.2.3 From 9930ea92c1301ae13760a8492f69f381a65ada68 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 27 Oct 2016 18:05:51 +0200 Subject: configure -libproxy: add a warning if not namespacing Qt Task-number: QTBUG-46058 Change-Id: I62978b7fe9a82f9facb16ba56d0b14b792e3de61 Reviewed-by: Oswald Buddenhagen --- src/network/configure.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/network/configure.json b/src/network/configure.json index 124fa1718f..30a1c39c0c 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -253,6 +253,19 @@ library names through OPENSSL_LIBS. For example: OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked" + }, + { + "type": "warning", + "condition": "features.libproxy && input.qt_namespace == ''", + "message": "Some of libproxy's plugins may use incompatible Qt versions. + + Some platforms and distributions ship libproxy with plugins, such + as config_kde4.so, that are linked against old versions of Qt; and + libproxy loads these plugins automatically when initialized. If Qt + is not in a namespace, that loading causes a crash. Even if the + systems on which you build and test have no such plugins, your + users' systems may have them. We therefore recommend that you + combine -libproxy with -qtnamespace when configuring Qt." } ], -- cgit v1.2.3 From 1ba0cfab308fff363973c3a15aa7f52908edf7af Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 2 Nov 2016 12:07:42 +0100 Subject: Windows: Fix high-dpi text rendering In change ce2ae6ebd8cfebf9edbb0b5653e80de029669548 we added support for hinted rendering to the DirectWrite engine. Previously, we would just use the DirectWrite engine for all text rendering in high-dpi and assume we would get only vertical hinting, but since the default changed, we ended up scaling hinted text and the resulting text layouts were a mess. Task-number: QTBUG-56841 Change-Id: I52101ea264878138de41878d1677c0ef8b522e78 Reviewed-by: Lars Knoll --- .../fontdatabases/windows/qwindowsfontenginedirectwrite.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index f266e85126..6130107cc8 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #if defined(QT_USE_DIRECTWRITE2) # include @@ -185,6 +186,9 @@ namespace { static DWRITE_RENDERING_MODE hintingPreferenceToRenderingMode(QFont::HintingPreference hintingPreference) { + if (QHighDpiScaling::isActive() && hintingPreference == QFont::PreferDefaultHinting) + hintingPreference = QFont::PreferVerticalHinting; + switch (hintingPreference) { case QFont::PreferNoHinting: return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; -- cgit v1.2.3 From da9ddb1e322ea798f67559d8db8b0eb76338d903 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Nov 2016 11:11:40 +0100 Subject: Direct2D QPA config test: Test for presence of IDXGISurface1 Partial Direct2D was added to recent versions of MinGW, which made the config test pass but is not sufficient to actually build the plugin. Check for IDXGISurface1 in addition. Change-Id: Ie108f5735ceb0a44934429b0fd2213612ed28848 Reviewed-by: Lars Knoll --- config.tests/qpa/direct2d/direct2d.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.tests/qpa/direct2d/direct2d.cpp b/config.tests/qpa/direct2d/direct2d.cpp index b751930bb9..87ce1d1dab 100644 --- a/config.tests/qpa/direct2d/direct2d.cpp +++ b/config.tests/qpa/direct2d/direct2d.cpp @@ -50,6 +50,8 @@ int main(int, char**) { ComPtr d2dFactory; D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, d2dFactory.ReleaseAndGetAddressOf()); + ComPtr surface; + (void)surface; // Q_UNUSED return 0; } -- cgit v1.2.3 From dd876ccb66df61b70049aa0ff8b96e64fe727f7d Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 2 Nov 2016 12:36:20 +0100 Subject: Add missing QBIG5CODEC_LICENSE.txt file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add file that was forgotten in eb9681397609eee38703f. Change-Id: Ib288bfc1f1f9cb4857e42f2fa3fe750e23b56aea Reviewed-by: Topi Reiniƶ --- src/corelib/codecs/QBIG5CODEC_LICENSE.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/corelib/codecs/QBIG5CODEC_LICENSE.txt diff --git a/src/corelib/codecs/QBIG5CODEC_LICENSE.txt b/src/corelib/codecs/QBIG5CODEC_LICENSE.txt new file mode 100644 index 0000000000..e9206a0031 --- /dev/null +++ b/src/corelib/codecs/QBIG5CODEC_LICENSE.txt @@ -0,0 +1,25 @@ +Copyright (C) 2000 Ming-Che Chuang +Copyright (C) 2001, 2002 James Su, Turbolinux Inc. +Copyright (C) 2002 WU Yi, HancomLinux Inc. +Copyright (C) 2001, 2002 Anthony Fok, ThizLinux Laboratory Ltd. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. -- cgit v1.2.3 From 6a4aaa3477f1184b3eda30d7c13c981ebc5dcd97 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 4 Nov 2016 12:34:23 +0100 Subject: iOS: remove wrong file include after upstream merge qiosfileenginefactory.h is now a part of the optional plugin. Amends d7e49801 Change-Id: Ia1854145f54e4278ab5c0020361915f476d48cc9 Reviewed-by: Liang Qi --- src/plugins/platforms/ios/kernel.pro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/platforms/ios/kernel.pro b/src/plugins/platforms/ios/kernel.pro index 5485ccc374..caafe89730 100644 --- a/src/plugins/platforms/ios/kernel.pro +++ b/src/plugins/platforms/ios/kernel.pro @@ -43,8 +43,7 @@ HEADERS = \ quiview.h \ quiaccessibilityelement.h \ qiosplatformaccessibility.h \ - qiostextresponder.h \ - qiosfileenginefactory.h + qiostextresponder.h !tvos { LIBS += -framework AssetsLibrary -- cgit v1.2.3 From 02167870c33783242b730d5d49ee47e48201811b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 1 Nov 2016 16:05:43 +0100 Subject: Use new "Files" property in testlib 3rdparty documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4ecef274f4afe0b1a25502fb64b2213a7bdb2853 Reviewed-by: hjk Reviewed-by: Topi Reiniƶ --- src/testlib/3rdparty/qt_attribution.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/testlib/3rdparty/qt_attribution.json b/src/testlib/3rdparty/qt_attribution.json index 23d230cb5c..d8b0ad1fc7 100644 --- a/src/testlib/3rdparty/qt_attribution.json +++ b/src/testlib/3rdparty/qt_attribution.json @@ -4,8 +4,9 @@ "Name": "Callgrind", "QDocModule": "qttestlib", "QtUsage": "Used on Linux ond MacOS in the Qt Test module.", + "Files": "valgrind_p.h callgrind_p.h", - "Description": "callgrind_p.h is part of Valgrind: an instrumentation framework for building dynamic analysis tools.", + "Description": "Part of Valgrind: an instrumentation framework for building dynamic analysis tools.", "Homepage": "http://valgrind.org/", "License": "BSD 4-clause \"Original\" or \"Old\" License", "LicenseId": "BSD-4-Clause", @@ -17,8 +18,9 @@ "Name": "Cycle", "QDocModule": "qttestlib", "QtUsage": "Used in the Qt Test module.", + "Files": "cycle_p.h", - "Description": "cycle_p.h allows to access the CPU's cycle counters.", + "Description": "Allows to access the CPU's cycle counters.", "License": "MIT License", "LicenseId": "MIT", "LicenseFile": "CYCLE_LICENSE.txt", @@ -30,8 +32,9 @@ Copyright (c) 2003, 2006 Massachusetts Institute of Technology" "Name": "Linux Performance Events", "QDocModule": "qttestlib", "QtUsage": "Used on Linux and Android in the Qt Test module.", + "Files": "linux_perf_event_p.h", - "Description": "linux_perf_event_p.h allows access to the LInux kernel's performance events.", + "Description": "Allows access to the Linux kernel's performance events.", "License": "GNU General Public License v2.0 only", "LicenseId": "GPL-2.0", "LicenseFile": "LINUX_LICENSE.txt", -- cgit v1.2.3 From ea9a8672a19588e89c0bda8e0c31424687c1e05f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 3 Nov 2016 12:14:56 -0700 Subject: Fix build with ICC on macOS: is properly supported I'm guess I introduced the regression in the commit 18ed6f20ad4327fa2ffbb687ac2f3ca7429c4348, which I wasn't sure about. Change-Id: Ic46ff326a6ba46bc877cfffd14839f84fdf796e7 Reviewed-by: Jake Petroules --- src/corelib/global/qcompilerdetection.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index dcdddeb04d..0b2345f8d4 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1060,13 +1060,6 @@ # undef Q_COMPILER_VARIADIC_TEMPLATES # endif # endif -# if defined(_LIBCPP_VERSION) -// libc++ uses __has_feature(cxx_atomic), so disable the feature if the compiler -// doesn't support it. That's required for the Intel compiler 14.x or earlier on OS X, for example. -# if !__has_feature(cxx_atomic) -# undef Q_COMPILER_ATOMICS -# endif -# endif # if defined(Q_COMPILER_THREADSAFE_STATICS) && defined(Q_OS_MAC) // Apple's low-level implementation of the C++ support library // (libc++abi.dylib, shared between libstdc++ and libc++) has deadlocks. The -- cgit v1.2.3 From a21ffd44b3a13a9ef64a56e67f6e267292f0a8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 3 Nov 2016 16:14:07 +0100 Subject: Use async delivery when flushing events from secondary threads Commit 33d748bb8 (Allow granular synchronous and asynchronous delivery of QPA events) replaced a postWindowSystemEvent() with a SynchronousDelivery, which was completely broken, as the delivery is already guarded by a mutex wait. Change-Id: I929fddc4e3403f943e8fe0677b5a46bf58419575 Reviewed-by: Maurice Kalinowski Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/kernel/qwindowsysteminterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 5dd525f315..667304859e 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -682,7 +682,7 @@ bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFl // deferredFlushWindowSystemEvents from the Gui thread. QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex); QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex); } else { sendWindowSystemEvents(flags); -- cgit v1.2.3