From c71fc3860b0947c3c793578117e9eb0a3eb3fb31 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 24 Nov 2016 11:58:19 +0100 Subject: [PATCH 001/304] add docs for QPlatformTheme::WheelScrollLines, MouseDoubleClickDistance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These theme hints were added in fac71528 and 4a2e297b respectively. Change-Id: Ic39f32dae4d0843b1b2398beb27081ad07d75772 Reviewed-by: Jan Arve Sæther (cherry picked from commit 847a152474550e0952d31f15069fb346565938df) Reviewed-by: Simo Fält --- src/gui/kernel/qplatformtheme.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 7f74959a60..2379b238f9 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -79,6 +79,10 @@ QT_BEGIN_NAMESPACE \value MouseDoubleClickInterval (int) Mouse double click interval in ms, overriding QPlatformIntegration::styleHint. + \value MouseDoubleClickDistance (int) The maximum distance in logical pixels which the mouse can travel + between clicks in order for the click sequence to be handled as a double click. + The default value is 5 logical pixels. + \value MousePressAndHoldInterval (int) Mouse press and hold interval in ms, overriding QPlatformIntegration::styleHint. @@ -88,6 +92,9 @@ QT_BEGIN_NAMESPACE \value StartDragTime (int) Start drag time in ms, overriding QPlatformIntegration::styleHint. + \value WheelScrollLines (int) The number of lines to scroll a widget, when the mouse wheel is rotated. + The default value is 3. \sa QApplication::wheelScrollLines() + \value KeyboardAutoRepeatRate (int) Keyboard auto repeat rate, overriding QPlatformIntegration::styleHint. From 8325808dcf0cc9061f05ec89b6c3e3afb8c1ab8f Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Wed, 28 Sep 2016 11:20:54 +0200 Subject: [PATCH 002/304] QTestLib: Add timestamp to mouse click events Timestamp is necessary for testing custom mouse event handlers e.g. what Qt WebEngine uses for handling triple and quadruple mouse clicks. Based on commit 181ee8f9ffacc51265ccc3a0005bf146f230cf85 Task-number: QTBUG-56223 Change-Id: I2bf840f326255333eec83ca8c42f087cb7deb1fb Reviewed-by: Kai Koehne --- src/testlib/qtestmouse.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 1143361323..166622e950 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -73,6 +73,11 @@ namespace QTest extern Q_TESTLIB_EXPORT Qt::MouseButton lastMouseButton; extern Q_TESTLIB_EXPORT int lastMouseTimestamp; + // This value is used to emulate timestamps to avoid creating double clicks by mistake. + // Use this constant instead of QStyleHints::mouseDoubleClickInterval property to avoid tests + // to depend on platform themes. + static const int mouseDoubleClickInterval = 500; + static void waitForEvents() { #ifdef Q_OS_MAC @@ -125,7 +130,7 @@ namespace QTest Q_FALLTHROUGH(); case MouseRelease: qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp); - lastMouseTimestamp += 500; // avoid double clicks being generated + lastMouseTimestamp += mouseDoubleClickInterval; // avoid double clicks being generated lastMouseButton = Qt::NoButton; break; case MouseMove: @@ -176,8 +181,10 @@ namespace QTest if (delay == -1 || delay < defaultMouseDelay()) delay = defaultMouseDelay(); - if (delay > 0) + if (delay > 0) { QTest::qWait(delay); + lastMouseTimestamp += delay; + } if (action == MouseClick) { mouseEvent(MousePress, widget, button, stateKey, pos); @@ -194,12 +201,16 @@ namespace QTest { case MousePress: me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey); + me.setTimestamp(++lastMouseTimestamp); break; case MouseRelease: me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, Qt::MouseButton(), stateKey); + me.setTimestamp(++lastMouseTimestamp); + lastMouseTimestamp += mouseDoubleClickInterval; // avoid double clicks being generated break; case MouseDClick: me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey); + me.setTimestamp(++lastMouseTimestamp); break; case MouseMove: QCursor::setPos(widget->mapToGlobal(pos)); From 7ca66b1e66e73a0cb35705df04507ef9f3440cab Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 9 Dec 2016 16:53:30 -0800 Subject: [PATCH 003/304] Fix race condition in QFactoryLoader: lock the mutex we already have The process of loading a plugin is examplified by the qLoadPlugin function (though not all users of QFactoryLoader use this function, they all do something similar): const int index = loader->indexOf(key); if (index != -1) { QObject *factoryObject = loader->instance(index); if (FactoryInterface *factory = qobject_cast(factoryObject)) if (PluginInterface *result = factory->create(key, std::forward(args)...)) return result; } QFactoryLoader::indexOf already locked the mutex, but not QFactoryLoader::instance. This commit fixes that. Note that calling the virtual create() in the plugin's factory is not protected by the mutex. Each plugin's factory must be thread-safe and also create an object that works on any thread too. It's also the responsibility of the caller of qLoadPlugin to ensure that it's called thread-safely. Task-number: QTBUG-42855 Change-Id: I63e21df51c7448bc8b5ffffd148ebee33d4c47de Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Marc Mutz --- src/corelib/plugin/qfactoryloader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index c09dc6c22b..b8e18cc9a8 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -282,6 +282,7 @@ QObject *QFactoryLoader::instance(int index) const return 0; #ifndef QT_NO_LIBRARY + QMutexLocker lock(&d->mutex); if (index < d->libraryList.size()) { QLibraryPrivate *library = d->libraryList.at(index); if (library->instance || library->loadPlugin()) { @@ -297,6 +298,7 @@ QObject *QFactoryLoader::instance(int index) const return 0; } index -= d->libraryList.size(); + lock.unlock(); #endif QVector staticPlugins = QPluginLoader::staticPlugins(); From c7b0f56fb1d33ebd8e0b96cee64a1bfb99abdbbd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Dec 2016 13:02:56 -0800 Subject: [PATCH 004/304] Fix build on Windows: winsock2.h requires WIN32_LEAN_AND_MEAN This is required for the next commit. Change-Id: I73fa1e59a4844c43a109fffd148c8c3e3a100c79 Reviewed-by: Oliver Wolff Reviewed-by: Friedemann Kleint --- src/plugins/bearer/generic/qgenericengine.cpp | 3 +++ src/plugins/bearer/platformdefs_win.h | 2 ++ src/plugins/bearer/qnetworksession_impl.cpp | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 02ea7abf88..059617b367 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -37,6 +37,9 @@ ** ****************************************************************************/ +// see comment in ../platformdefs_win.h. +#define WIN32_LEAN_AND_MEAN 1 + #include "qgenericengine.h" #include "../qnetworksession_impl.h" diff --git a/src/plugins/bearer/platformdefs_win.h b/src/plugins/bearer/platformdefs_win.h index 8fb2f1bcc5..5a8487d868 100644 --- a/src/plugins/bearer/platformdefs_win.h +++ b/src/plugins/bearer/platformdefs_win.h @@ -40,6 +40,8 @@ #ifndef QPLATFORMDEFS_WIN_H #define QPLATFORMDEFS_WIN_H +// Since we need to include winsock2.h, we need to define WIN32_LEAN_AND_MEAN +// somewhere above so windows.h won't include winsock.h. #include #include #undef interface diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp index 5ce51670f7..7756709e55 100644 --- a/src/plugins/bearer/qnetworksession_impl.cpp +++ b/src/plugins/bearer/qnetworksession_impl.cpp @@ -37,6 +37,9 @@ ** ****************************************************************************/ +// see comment in ../platformdefs_win.h. +#define WIN32_LEAN_AND_MEAN 1 + #include "qnetworksession_impl.h" #include "qbearerengine_impl.h" From 7c402ad3d15ff5e7c2b7319b1bea821f6f67e26c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 27 Sep 2016 16:52:55 -0700 Subject: [PATCH 005/304] Make the bearer QFactoryLoader a member variable, not a static Because it was a function-level static, the QFactoryLoader was getting destroyed out-of-sync with the bearer thread stopping. Under normal conditions, the thread stopped first (~QApplication / ~QCoreApplication via qAddPostRoutine), and the static got destroyed when the process exited. However, if QApplication leaked or if the destruction order is wonky (as seen in PyQt5), the thread could still be running when the plugins were already unloaded. With the loader a member variable, it gets destroyed when the thread stops. Note: in Qt 5.7, QFactoryLoader no longer unloads the plugins (since commit 494376f980e96339b6f1eff7c41336ca4d853065), so this crash cannot happen in that version. [ChangeLog][QtNetwork][Bearer management] Fixed a bug that could cause a crash on application exit, depending on the order of destruction of the QCoreApplication object and the QtDBus manager thread. Task-number: QTBUG-56228 Task-number: QTBUG-52988 Change-Id: I33dc971f005a4848bb8ffffd147853376f82de2a Reviewed-by: Lorn Potter Reviewed-by: Edward Welbourne --- src/network/bearer/qnetworkconfigmanager_p.cpp | 7 +++---- src/network/bearer/qnetworkconfigmanager_p.h | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 2da073fa5a..a903ecda5f 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -40,8 +40,6 @@ #include "qnetworkconfigmanager_p.h" #include "qbearerplugin_p.h" -#include - #include #include #include @@ -60,7 +58,9 @@ QT_BEGIN_NAMESPACE QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() - : QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) + : QObject(), pollTimer(0), mutex(QMutex::Recursive), + loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")), + forcedPolling(0), firstUpdate(true) { qRegisterMetaType(); qRegisterMetaType(); @@ -365,7 +365,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() bool envOK = false; const int skipGeneric = qEnvironmentVariableIntValue("QT_EXCLUDE_GENERIC_BEARER", &envOK); QBearerEngine *generic = 0; - static QFactoryLoader loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")); QFactoryLoader *l = &loader; const PluginKeyMap keyMap = l->keyMap(); const PluginKeyMapConstIterator cend = keyMap.constEnd(); diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index a804e037a3..380e25c22f 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -55,6 +55,7 @@ #include "qnetworkconfigmanager.h" #include "qnetworkconfiguration_p.h" +#include #include #include @@ -118,6 +119,7 @@ private: private: mutable QMutex mutex; + QFactoryLoader loader; QList sessionEngines; QSet onlineConfigurations; From 7adfe7494bb4a2c1d3a036fe9dfd946bc00c5d49 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 18 Dec 2016 11:32:27 +0000 Subject: [PATCH 006/304] Update model-view documentation about layoutChanged This has always been true, but hasn't been documented well enough, so triagers are giving incorrect information in bug reports (eg QTBUG-47711 and QTBUG-53221). That incorrect information is being treated as truth by Qt users which take action based on incorrect information. That is a problem, so try to make the documentation clear. Change-Id: I4e44a9a0675cdd7d9289ec209ae32d5a92899fc9 Reviewed-by: David Faure --- .../doc/src/model-view-programming.qdoc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index e727d7fe56..84819e8c1a 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -2070,9 +2070,22 @@ Normally, the begin and end functions are capable of informing other components about changes to the model's underlying structure. For more complex changes to the - model's structure, perhaps involving internal reorganization or sorting of data, - it is necessary to emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} - signal to cause any attached views to be updated. + model's structure, perhaps involving internal reorganization, sorting of data or + any other structural change, it is necessary to perform the following sequence: + + \li Emit the \l{QAbstractItemModel::layoutAboutToBeChanged()}{layoutAboutToBeChanged()} signal + \li Update internal data which represents the structure of the model. + \li Update persistent indexes using \l{QAbstractItemModel::changePersistentIndexList()}{changePersistentIndexList()} + \li Emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} signal. + + This sequence can be used for any structural update in lieu of the more + high-level and convenient protected methods. For example, if a model of + two million rows needs to have all odd numbered rows removed, that + is 1 million discountiguous ranges of 1 element each. It would be + possible to use beginRemoveRows and endRemoveRows 1 million times, but + that would obviously be inefficient. Instead, this can be signalled as a + single layout change which updates all necessary persistent indexes at + once. \section3 Lazy population of model data From 6614f7754c2616aa66ddd9bbad23d0f415db5b6c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 15 Dec 2016 15:21:23 +0100 Subject: [PATCH 007/304] Silence implicit-fallthough warnings Fixes Werror build with GCC 7. Change-Id: Ie0e9fb907af545b6c200558faaaf83b8ec058b7a Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/moc.cpp | 1 + src/tools/moc/parser.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 89bf2bd6a1..03f022da69 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -197,6 +197,7 @@ Type Moc::parseType() prev(); break; } + Q_FALLTHROUGH(); case CHAR: case SHORT: case INT: diff --git a/src/tools/moc/parser.h b/src/tools/moc/parser.h index ee8761108b..bedcbbf7e2 100644 --- a/src/tools/moc/parser.h +++ b/src/tools/moc/parser.h @@ -68,8 +68,8 @@ public: inline QByteArray unquotedLexem() { return symbols.at(index-1).unquotedLexem();} inline const Symbol &symbol() { return symbols.at(index-1);} - void error(int rollback); - void error(const char *msg = 0); + Q_NORETURN void error(int rollback); + Q_NORETURN void error(const char *msg = 0); void warning(const char * = 0); void note(const char * = 0); From 29a929668b832a3fceda69a5c5f2d07b796a3fc8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 19 Dec 2016 16:23:47 +0100 Subject: [PATCH 008/304] Fix capitalization of This tag was never spelled "PlatformToolSet". The correct spelling is "PlatformToolset" (lower case s). VS itself can load qmake-generated projects despite this misspelling, but tools like PVS-Studio are bothered by it. Task-number: QTBUG-57435 Task-number: QTBUG-57694 Change-Id: Ib70e8561f1827e195194bcf518445b2909a8d8c0 Reviewed-by: Jake Petroules --- qmake/generators/win32/msbuild_objectmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 914505a362..a0050c9f1f 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -176,7 +176,7 @@ const char _Optimization[] = "Optimization"; const char _OptimizeReferences[] = "OptimizeReferences"; const char _OutputDirectory[] = "OutputDirectory"; const char _OutputFile[] = "OutputFile"; -const char _PlatformToolSet[] = "PlatformToolSet"; +const char _PlatformToolSet[] = "PlatformToolset"; const char _PrecompiledHeader[] = "PrecompiledHeader"; const char _PrecompiledHeaderFile[] = "PrecompiledHeaderFile"; const char _PrecompiledHeaderOutputFile[] = "PrecompiledHeaderOutputFile"; From f2b31fdb6bb357c0c5c97d4fabd2561da3ba2093 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 16 Dec 2016 13:11:49 +0100 Subject: [PATCH 009/304] make QMAKE_DIR_SEP magic on writing since ab0cc305, the spec will be replaced by an entirely new one during configuration, and so needs to update the path separator for $$shell_{path,quote}(). however, the latter didn't happen, as the spec reloading doesn't go through the "real" spec loading path. Change-Id: I45ab3156b8e040f683328ac46e48b09c2eb94ef7 Reviewed-by: Joerg Bornemann --- qmake/library/qmakeevaluator.cpp | 5 +++-- qmake/library/qmakeevaluator_p.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 4ca87e8bc7..69e216d3da 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -152,6 +152,7 @@ void QMakeEvaluator::initStatics() statics.strhost_build = QLatin1String("host_build"); statics.strTEMPLATE = ProKey("TEMPLATE"); statics.strQMAKE_PLATFORM = ProKey("QMAKE_PLATFORM"); + statics.strQMAKE_DIR_SEP = ProKey("QMAKE_DIR_SEP"); statics.strQMAKESPEC = ProKey("QMAKESPEC"); #ifdef PROEVALUATOR_FULL statics.strREQUIRES = ProKey("REQUIRES"); @@ -938,6 +939,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable( setTemplate(); else if (varName == statics.strQMAKE_PLATFORM) m_featureRoots = 0; + else if (varName == statics.strQMAKE_DIR_SEP) + m_dirSep = first(varName); else if (varName == statics.strQMAKESPEC) { if (!values(varName).isEmpty()) { QString spec = values(varName).first().toQString(); @@ -1218,8 +1221,6 @@ bool QMakeEvaluator::loadSpecInternal() // This also ensures that m_featureRoots is valid. if (evaluateFeatureFile(QLatin1String("spec_post.prf")) != ReturnTrue) return false; - // The MinGW and x-build specs may change the separator; $$shell_{path,quote}() need it - m_dirSep = first(ProKey("QMAKE_DIR_SEP")); return true; } diff --git a/qmake/library/qmakeevaluator_p.h b/qmake/library/qmakeevaluator_p.h index f444e0d0be..42aaef70c3 100644 --- a/qmake/library/qmakeevaluator_p.h +++ b/qmake/library/qmakeevaluator_p.h @@ -78,6 +78,7 @@ struct QMakeStatics { QString strhost_build; ProKey strTEMPLATE; ProKey strQMAKE_PLATFORM; + ProKey strQMAKE_DIR_SEP; ProKey strQMAKESPEC; #ifdef PROEVALUATOR_FULL ProKey strREQUIRES; From d88ff29c57b5407339da00389c522e5f1d4e3398 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 16 Dec 2016 13:31:07 +0100 Subject: [PATCH 010/304] fix conditionals on the spec after assigning QMAKESPEC this is of marginal value, as only our own code ever messes with QMAKESPEC, and we mostly stopped matching on the spec in favor of compiler and platform flags. Change-Id: Ibdd9a9c85067623f0f1f064d139d23b4e6b0677d Reviewed-by: Joerg Bornemann --- qmake/library/qmakeevaluator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 69e216d3da..38c0cec23f 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -946,6 +946,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable( QString spec = values(varName).first().toQString(); if (IoUtils::isAbsolutePath(spec)) { m_qmakespec = spec; + m_qmakespecName = IoUtils::fileName(m_qmakespec).toString(); m_featureRoots = 0; } } From 33c33f6475910bad607abac67eef6c581d6188dd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 16 Dec 2016 13:34:02 +0100 Subject: [PATCH 011/304] micro-optimize FOO-=$$BAR for empty FOO there is no point in iterating BAR if FOO is (or became) empty. Change-Id: I86c89bf0ad726a5ab7ead990a27ef7cc32caebbf Reviewed-by: Joerg Bornemann --- qmake/library/proitems.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qmake/library/proitems.cpp b/qmake/library/proitems.cpp index 66db190bc1..f41ace6231 100644 --- a/qmake/library/proitems.cpp +++ b/qmake/library/proitems.cpp @@ -396,9 +396,12 @@ void ProStringList::removeAll(const char *str) void ProStringList::removeEach(const ProStringList &value) { - for (const ProString &str : value) + for (const ProString &str : value) { + if (isEmpty()) + break; if (!str.isEmpty()) removeAll(str); + } } void ProStringList::removeEmpty() From 20fd99d86379b0df3c9c4159d397d3451622c325 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 14 Dec 2016 19:00:37 +0100 Subject: [PATCH 012/304] fix typos in "ras[p]berry pi" Change-Id: I2d8910df9266d9cbf2426e5f2ba2a88eb2e821ef Reviewed-by: Joerg Bornemann --- src/gui/configure.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/configure.json b/src/gui/configure.json index f4171a8e9f..2fce7eebb8 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -322,7 +322,7 @@ "use": "egl xcb_xlib" }, "egl-brcm": { - "label": "Broadcom EGL (Rasberry Pi)", + "label": "Broadcom EGL (Raspberry Pi)", "type": "compile", "test": "qpa/eglfs-brcm", "use": "egl bcm_host" @@ -599,7 +599,7 @@ "output": [ "privateFeature" ] }, "eglfs_brcm": { - "label": "EGLFS Rasberry Pi", + "label": "EGLFS Raspberry Pi", "condition": "features.eglfs && tests.egl-brcm", "output": [ "privateFeature" ] }, From bee9a78e13a903fd26a467464aa178fc67dbd0a2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Dec 2016 14:38:34 +0100 Subject: [PATCH 013/304] Avoid using QRgba64 for buffers Benchmarking showed most time rendering in rgb64 mode was spend on memsetting the buffers because they were not declared with a primitive type. This patch changes the buffers to quint64, but leaves refactoring function arguments to a later patch in the dev branch. Change-Id: Iacc81b0d8e9570b1975dffb85c955b0aabb096a7 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 66 ++++++++++++++++---------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a2e49dbfdb..adc28f07d3 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -2870,8 +2870,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *b = buffer; while (length) { int len = qMin(length, buffer_size / 2); @@ -2947,9 +2947,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fx += fdx; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); if (disty) - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff); @@ -2967,7 +2967,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8)); _mm_storel_epi64((__m128i*)(b+i), vt); #else - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); #endif fracX += fdx; } @@ -2978,8 +2978,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *end = buffer + length; QRgba64 *b = buffer; @@ -3087,13 +3087,13 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fx += fdx; fy += fdy; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff); int disty = (fracY & 0x0000ffff); - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); fracX += fdx; fracY += fdy; } @@ -3110,8 +3110,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint sbuf1[buffer_size]; uint sbuf2[buffer_size]; - QRgba64 buf1[buffer_size]; - QRgba64 buf2[buffer_size]; + quint64 buf1[buffer_size]; + quint64 buf2[buffer_size]; QRgba64 *b = buffer; int distxs[buffer_size / 2]; @@ -3159,13 +3159,13 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fw += fdw; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM((QRgba64 *)buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = distxs[i]; int disty = distys[i]; - b[i] = interpolate_4_pixels_rgb64(buf1 + i*2, buf2 + i*2, distx, disty); + b[i] = interpolate_4_pixels_rgb64((QRgba64 *)buf1 + i*2, (QRgba64 *)buf2 + i*2, distx, disty); } length -= len; @@ -3712,7 +3712,7 @@ void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) return blend_color_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; + quint64 buffer[buffer_size]; const QRgba64 color = data->solid.color; while (count--) { @@ -3720,7 +3720,7 @@ void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) int length = spans->len; while (length) { int l = qMin(buffer_size, length); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.funcSolid64(dest, l, color, spans->coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); length -= l; @@ -3901,11 +3901,11 @@ public: } }; -class BlendSrcGenericRGB64 : public QBlendBase +class BlendSrcGenericRGB64 : public QBlendBase { public: BlendSrcGenericRGB64(QSpanData *d, const Operator &o) - : QBlendBase(d, o) + : QBlendBase(d, o) { } @@ -3914,20 +3914,20 @@ public: return op.func64 && op.destFetch64 && op.destStore64; } - const QRgba64 *fetch(int x, int y, int len) + const quint64 *fetch(int x, int y, int len) { - dest = op.destFetch64(buffer, data->rasterBuffer, x, y, len); - return op.srcFetch64(src_buffer, &op, data, y, x, len); + dest = (quint64 *)op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, y, len); + return (const quint64 *)op.srcFetch64((QRgba64 *)src_buffer, &op, data, y, x, len); } - void process(int, int, int len, int coverage, const QRgba64 *src, int offset) + void process(int, int, int len, int coverage, const quint64 *src, int offset) { - op.func64(dest + offset, src + offset, len, coverage); + op.func64((QRgba64 *)dest + offset, (const QRgba64 *)src + offset, len, coverage); } void store(int x, int y, int len) { - op.destStore64(data->rasterBuffer, x, y, dest, len); + op.destStore64(data->rasterBuffer, x, y, (QRgba64 *)dest, len); } }; @@ -4006,8 +4006,8 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi qWarning("Unsupported blend"); return blend_untransformed_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; - QRgba64 src_buffer[buffer_size]; + quint64 buffer[buffer_size]; + quint64 src_buffer[buffer_size]; const int image_width = data->texture.width; const int image_height = data->texture.height; @@ -4031,8 +4031,8 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; while (length) { int l = qMin(buffer_size, length); - const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + const QRgba64 *src = op.srcFetch64((QRgba64 *)src_buffer, &op, data, sy, sx, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.func64(dest, src, l, coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); x += l; @@ -4247,8 +4247,8 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD qDebug("unsupported rgb64 blend"); return blend_tiled_generic(count, spans, userData); } - QRgba64 buffer[buffer_size]; - QRgba64 src_buffer[buffer_size]; + quint64 buffer[buffer_size]; + quint64 src_buffer[buffer_size]; const int image_width = data->texture.width; const int image_height = data->texture.height; @@ -4275,8 +4275,8 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD int l = qMin(image_width - sx, length); if (buffer_size < l) l = buffer_size; - const QRgba64 *src = op.srcFetch64(src_buffer, &op, data, sy, sx, l); - QRgba64 *dest = op.destFetch64(buffer, data->rasterBuffer, x, spans->y, l); + const QRgba64 *src = op.srcFetch64((QRgba64 *)src_buffer, &op, data, sy, sx, l); + QRgba64 *dest = op.destFetch64((QRgba64 *)buffer, data->rasterBuffer, x, spans->y, l); op.func64(dest, src, l, coverage); op.destStore64(data->rasterBuffer, x, spans->y, dest, l); x += l; From 1274a7e419c9f25d6dcd01b8dc86d764776ef1b4 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 14 Dec 2016 22:04:37 +0100 Subject: [PATCH 014/304] Doc: Updated code sample to match documentation of QCompleter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QCompleter documentation mentions QFileSystemModel while the code sample still uses QDirModel. This patch fixes this by updating the code sample. Change-Id: I99a0d2419efcf781af3e9530508df088d77fbbfa Reviewed-by: Sze Howe Koh Reviewed-by: Topi Reiniö --- src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp index 284a4ce404..7d003e4886 100644 --- a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp +++ b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp @@ -62,7 +62,7 @@ lineEdit->setCompleter(completer); //! [1] QCompleter *completer = new QCompleter(this); -completer->setModel(new QDirModel(completer)); +completer->setModel(new QFileSystemModel(completer)); lineEdit->setCompleter(completer); //! [1] From 3bd0fd8f97e7a33a874929a383a42e6c710bfff3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 17 Dec 2016 06:20:06 +0000 Subject: [PATCH 015/304] QSFPM: Fix handling of source model layout change In sourceLayoutAboutToBeChanged the source model update is ignored if the affected parents are filtered out anyway. The same logic is attempted in the sourceLayoutChanged slot, but there the early-return logic is applied too late - the mapping is cleared before performing the early-return. Because pointers into the mapping are used in the internalPointer of QModelIndexes in this class, persistent indexes used later will segfault when attempting to dereference it. Additionally, if a parent becomes invalid as a result of the layoutChange, it would be filtered out by the condition in the loop, resulting in a different result in the comparison of emptiness of the parents container. Fix that by persisting the parent's container, and performing the test for early-return before clearing the mapping. Task-number: QTBUG-47711 Task-number: QTBUG-32981 Change-Id: If45e8a1c97d39454160f52041bc9ae7e337dce97 Reviewed-by: David Faure --- .../itemmodels/qsortfilterproxymodel.cpp | 31 ++--- .../tst_qsortfilterproxymodel.cpp | 126 ++++++++++++++++++ 2 files changed, 137 insertions(+), 20 deletions(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index b0ddfa879d..333152138e 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -171,6 +171,7 @@ public: QRowsRemoval itemsBeingRemoved; QModelIndexPairList saved_persistent_indexes; + QList saved_layoutChange_parents; QHash::const_iterator create_mapping( const QModelIndex &source_parent) const; @@ -1331,23 +1332,23 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList parents; + saved_layoutChange_parents.clear(); for (const QPersistentModelIndex &parent : sourceParents) { if (!parent.isValid()) { - parents << QPersistentModelIndex(); + saved_layoutChange_parents << QPersistentModelIndex(); continue; } const QModelIndex mappedParent = q->mapFromSource(parent); // Might be filtered out. if (mappedParent.isValid()) - parents << mappedParent; + saved_layoutChange_parents << mappedParent; } // All parents filtered out. - if (!sourceParents.isEmpty() && parents.isEmpty()) + if (!sourceParents.isEmpty() && saved_layoutChange_parents.isEmpty()) return; - emit q->layoutAboutToBeChanged(parents); + emit q->layoutAboutToBeChanged(saved_layoutChange_parents); if (persistent.indexes.isEmpty()) return; @@ -1359,6 +1360,9 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList parents; - for (const QPersistentModelIndex &parent : sourceParents) { - if (!parent.isValid()) { - parents << QPersistentModelIndex(); - continue; - } - const QModelIndex mappedParent = q->mapFromSource(parent); - if (mappedParent.isValid()) - parents << mappedParent; - } - - if (!sourceParents.isEmpty() && parents.isEmpty()) - return; - - emit q->layoutChanged(parents); + emit q->layoutChanged(saved_layoutChange_parents); + saved_layoutChange_parents.clear(); } void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted( diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 38e3c6890d..6b98d9f4a3 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -145,6 +145,8 @@ private slots: void canDropMimeData(); void filterHint(); + void sourceLayoutChangeLeavesValidPersistentIndexes(); + protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); void checkHierarchy(const QStringList &data, const QAbstractItemModel *model); @@ -4181,5 +4183,129 @@ void tst_QSortFilterProxyModel::filterHint() QAbstractItemModel::NoLayoutChangeHint); } +/** + + Creates a model where each item has one child, to a set depth, + and the last item has no children. For a model created with + setDepth(4): + + - 1 + - - 2 + - - - 3 + - - - - 4 +*/ +class StepTreeModel : public QAbstractItemModel +{ + Q_OBJECT +public: + StepTreeModel(QObject * parent = 0) + : QAbstractItemModel(parent), m_depth(0) {} + + int columnCount(const QModelIndex& = QModelIndex()) const override { return 1; } + + int rowCount(const QModelIndex& parent = QModelIndex()) const override + { + quintptr parentId = (parent.isValid()) ? parent.internalId() : 0; + return (parentId < m_depth) ? 1 : 0; + } + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override + { + if (role != Qt::DisplayRole) + return QVariant(); + + return QString::number(index.internalId()); + } + + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override + { + quintptr parentId = (parent.isValid()) ? parent.internalId() : 0; + if (parentId >= m_depth) + return QModelIndex(); + + return createIndex(0, 0, parentId + 1); + } + + QModelIndex parent(const QModelIndex& index) const override + { + if (index.internalId() == 0) + return QModelIndex(); + + return createIndex(0, 0, index.internalId() - 1); + } + + void setDepth(quintptr depth) + { + int parentIdWithLayoutChange = (m_depth < depth) ? m_depth : depth; + + QList parentsOfLayoutChange; + parentsOfLayoutChange.push_back(createIndex(0, 0, parentIdWithLayoutChange)); + + layoutAboutToBeChanged(parentsOfLayoutChange); + + auto existing = persistentIndexList(); + + QList updated; + + for (auto idx : existing) { + if (indexDepth(idx) <= depth) + updated.push_back(idx); + else + updated.push_back({}); + } + + m_depth = depth; + + changePersistentIndexList(existing, updated); + + layoutChanged(parentsOfLayoutChange); + } + +private: + static quintptr indexDepth(QModelIndex const& index) + { + return (index.isValid()) ? 1 + indexDepth(index.parent()) : 0; + } + +private: + quintptr m_depth; +}; + +void tst_QSortFilterProxyModel::sourceLayoutChangeLeavesValidPersistentIndexes() +{ + StepTreeModel model; + Q_SET_OBJECT_NAME(model); + model.setDepth(4); + + QSortFilterProxyModel proxy1; + proxy1.setSourceModel(&model); + Q_SET_OBJECT_NAME(proxy1); + + proxy1.setFilterRegExp("1|2"); + + // The current state of things: + // model proxy + // - 1 - 1 + // - - 2 - - 2 + // - - - 3 + // - - - - 4 + + // The setDepth call below removes '4' with a layoutChanged call. + // Because the proxy filters that out anyway, the proxy doesn't need + // to emit any signals or update persistent indexes. + + QPersistentModelIndex persistentIndex = proxy1.index(0, 0, proxy1.index(0, 0)); + + model.setDepth(3); + + // Calling parent() causes the internalPointer to be used. + // Before fixing QTBUG-47711, that could be a dangling pointer. + // The use of qDebug here makes sufficient use of the heap to + // cause corruption at runtime with normal use on linux (before + // the fix). valgrind confirms the fix. + qDebug() << persistentIndex.parent(); + QVERIFY(persistentIndex.parent().isValid()); +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" From 0874861bcc70313c343aba5e5566ed30b69eed1c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 19 Dec 2016 21:13:57 +0000 Subject: [PATCH 016/304] QSFPM: Remove data manipulation from move handlers Similar to the fix in the parent commit, incorrect updating of the internal data structures during layout changes can lead to dangling pointers being dereferenced later. Moves are treated as layoutChanges by this proxy by forwarding to the appropriate method. However, data is incorrectly cleared prior to that forwarding. Remove that, and let the layoutChange handling take appropriate action. Change-Id: Iee951e37152328a4e6a5fb8e5385c32a2fe4c0bd Reviewed-by: David Faure --- .../itemmodels/qsortfilterproxymodel.cpp | 67 ++++--------------- .../tst_qsortfilterproxymodel.cpp | 46 +++++++++++++ 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 333152138e..226a2401e1 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -1418,49 +1418,27 @@ void QSortFilterProxyModelPrivate::_q_sourceRowsRemoved( void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeMoved( const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) { - Q_Q(QSortFilterProxyModel); // Because rows which are contiguous in the source model might not be contiguous // in the proxy due to sorting, the best thing we can do here is be specific about what // parents are having their children changed. // Optimize: Emit move signals if the proxy is not sorted. Will need to account for rows // being filtered out though. - saved_persistent_indexes.clear(); - QList parents; - parents << q->mapFromSource(sourceParent); + parents << sourceParent; if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutAboutToBeChanged(parents); - if (persistent.indexes.isEmpty()) - return; - saved_persistent_indexes = store_persistent_indexes(); + parents << destParent; + _q_sourceLayoutAboutToBeChanged(parents, QAbstractItemModel::NoLayoutChangeHint); } void QSortFilterProxyModelPrivate::_q_sourceRowsMoved( const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) { - Q_Q(QSortFilterProxyModel); - - // Optimize: We only need to clear and update the persistent indexes which are children of - // sourceParent or destParent - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - - update_persistent_indexes(saved_persistent_indexes); - saved_persistent_indexes.clear(); - - if (dynamic_sortfilter && update_source_sort_column()) { - //update_source_sort_column might have created wrong mapping so we have to clear it again - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } - QList parents; - parents << q->mapFromSource(sourceParent); + parents << sourceParent; if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutChanged(parents); + parents << destParent; + _q_sourceLayoutChanged(parents, QAbstractItemModel::NoLayoutChangeHint); } void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeInserted( @@ -1522,42 +1500,21 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved( void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeMoved( const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) { - Q_Q(QSortFilterProxyModel); - - saved_persistent_indexes.clear(); - QList parents; - parents << q->mapFromSource(sourceParent); + parents << sourceParent; if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutAboutToBeChanged(parents); - - if (persistent.indexes.isEmpty()) - return; - saved_persistent_indexes = store_persistent_indexes(); + parents << destParent; + _q_sourceLayoutAboutToBeChanged(parents, QAbstractItemModel::NoLayoutChangeHint); } void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved( const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) { - Q_Q(QSortFilterProxyModel); - - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - - update_persistent_indexes(saved_persistent_indexes); - saved_persistent_indexes.clear(); - - if (dynamic_sortfilter && update_source_sort_column()) { - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } - QList parents; - parents << q->mapFromSource(sourceParent); + parents << sourceParent; if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutChanged(parents); + parents << destParent; + _q_sourceLayoutChanged(parents, QAbstractItemModel::NoLayoutChangeHint); } /*! diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 6b98d9f4a3..7b6c470dc4 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -146,6 +146,7 @@ private slots: void filterHint(); void sourceLayoutChangeLeavesValidPersistentIndexes(); + void rowMoveLeavesValidPersistentIndexes(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -4307,5 +4308,50 @@ void tst_QSortFilterProxyModel::sourceLayoutChangeLeavesValidPersistentIndexes() QVERIFY(persistentIndex.parent().isValid()); } +void tst_QSortFilterProxyModel::rowMoveLeavesValidPersistentIndexes() +{ + DynamicTreeModel model; + Q_SET_OBJECT_NAME(model); + + QList ancestors; + for (auto i = 0; i < 5; ++i) + { + Q_UNUSED(i); + ModelInsertCommand insertCommand(&model); + insertCommand.setAncestorRowNumbers(ancestors); + insertCommand.setStartRow(0); + insertCommand.setEndRow(0); + insertCommand.doCommand(); + ancestors.push_back(0); + } + + QSortFilterProxyModel proxy1; + proxy1.setSourceModel(&model); + Q_SET_OBJECT_NAME(proxy1); + + proxy1.setFilterRegExp("1|2"); + + auto item5 = model.match(model.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first(); + auto item3 = model.match(model.index(0, 0), Qt::DisplayRole, "3", 1, Qt::MatchRecursive).first(); + + Q_ASSERT(item5.isValid()); + Q_ASSERT(item3.isValid()); + + QPersistentModelIndex persistentIndex = proxy1.match(proxy1.index(0, 0), Qt::DisplayRole, "2", 1, Qt::MatchRecursive).first(); + + ModelMoveCommand moveCommand(&model, 0); + moveCommand.setAncestorRowNumbers(QList{0, 0, 0, 0}); + moveCommand.setStartRow(0); + moveCommand.setEndRow(0); + moveCommand.setDestRow(0); + moveCommand.setDestAncestors(QList{0, 0, 0}); + moveCommand.doCommand(); + + // Calling parent() causes the internalPointer to be used. + // Before fixing QTBUG-47711 (moveRows case), that could be + // a dangling pointer. + QVERIFY(persistentIndex.parent().isValid()); +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" From baad82d242a4d8c1af6c87faaa7f25584183fd53 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 20 Dec 2016 00:44:12 +0000 Subject: [PATCH 017/304] QIPM: Persist model indexes after emitting layoutChange, not before Callers can persist a QModelIndex which was not persisted before in a slot connected to the signal, and such a persisted index must be updated in the course of the layoutChange. Store the indexes to persist after emitting the signal. Task-number: QTBUG-32981 Change-Id: Ibee4c0d84817d72603a03fe5b22fdeefeac0695e Reviewed-by: David Faure --- .../itemmodels/qidentityproxymodel.cpp | 18 ++--- .../tst_qidentityproxymodel.cpp | 76 +++++++++++++++++++ 2 files changed, 85 insertions(+), 9 deletions(-) diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index e537793146..7c306799d0 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -496,15 +496,6 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QListpersistentIndexList(); - for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { - proxyIndexes << proxyPersistentIndex; - Q_ASSERT(proxyPersistentIndex.isValid()); - const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); - Q_ASSERT(srcPersistentIndex.isValid()); - layoutChangePersistentIndexes << srcPersistentIndex; - } - QList parents; parents.reserve(sourceParents.size()); for (const QPersistentModelIndex &parent : sourceParents) { @@ -518,6 +509,15 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QListlayoutAboutToBeChanged(parents, hint); + + const auto proxyPersistentIndexes = q->persistentIndexList(); + for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { + proxyIndexes << proxyPersistentIndex; + Q_ASSERT(proxyPersistentIndex.isValid()); + const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); + Q_ASSERT(srcPersistentIndex.isValid()); + layoutChangePersistentIndexes << srcPersistentIndex; + } } void QIdentityProxyModelPrivate::_q_sourceLayoutChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint) diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index e946f3104a..564b8547b1 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -68,6 +68,8 @@ private slots: void itemData(); + void persistIndexOnLayoutChange(); + protected: void verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent = QModelIndex()); @@ -377,5 +379,79 @@ void tst_QIdentityProxyModel::itemData() QCOMPARE(proxy.itemData(topIndex).value(Qt::DisplayRole).toString(), QStringLiteral("Monday_appended")); } +void dump(QAbstractItemModel* model, QString const& indent = " - ", QModelIndex const& parent = {}) +{ + for (auto row = 0; row < model->rowCount(parent); ++row) + { + auto idx = model->index(row, 0, parent); + qDebug() << (indent + idx.data().toString()); + dump(model, indent + "- ", idx); + } +} + +void tst_QIdentityProxyModel::persistIndexOnLayoutChange() +{ + DynamicTreeModel model; + + QList ancestors; + for (auto i = 0; i < 3; ++i) + { + Q_UNUSED(i); + ModelInsertCommand insertCommand(&model); + insertCommand.setAncestorRowNumbers(ancestors); + insertCommand.setStartRow(0); + insertCommand.setEndRow(0); + insertCommand.doCommand(); + ancestors.push_back(0); + } + ModelInsertCommand insertCommand(&model); + insertCommand.setAncestorRowNumbers(ancestors); + insertCommand.setStartRow(0); + insertCommand.setEndRow(1); + insertCommand.doCommand(); + + // dump(&model); + // " - 1" + // " - - 2" + // " - - - 3" + // " - - - - 4" + // " - - - - 5" + + QIdentityProxyModel proxy; + proxy.setSourceModel(&model); + + QPersistentModelIndex persistentIndex; + + QPersistentModelIndex sourcePersistentIndex = model.match(model.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first(); + + QCOMPARE(sourcePersistentIndex.data().toString(), QStringLiteral("5")); + + bool gotLayoutAboutToBeChanged = false; + bool gotLayoutChanged = false; + + QObject::connect(&proxy, &QAbstractItemModel::layoutAboutToBeChanged, &proxy, [&proxy, &persistentIndex, &gotLayoutAboutToBeChanged] + { + gotLayoutAboutToBeChanged = true; + persistentIndex = proxy.match(proxy.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first(); + }); + + QObject::connect(&proxy, &QAbstractItemModel::layoutChanged, &proxy, [&proxy, &persistentIndex, &sourcePersistentIndex, &gotLayoutChanged] + { + gotLayoutChanged = true; + QCOMPARE(QModelIndex(persistentIndex), proxy.mapFromSource(sourcePersistentIndex)); + }); + + ModelChangeChildrenLayoutsCommand layoutChangeCommand(&model, 0); + + layoutChangeCommand.setAncestorRowNumbers(QList{0, 0, 0}); + layoutChangeCommand.setSecondAncestorRowNumbers(QList{0, 0}); + + layoutChangeCommand.doCommand(); + + QVERIFY(gotLayoutAboutToBeChanged); + QVERIFY(gotLayoutChanged); + QVERIFY(persistentIndex.isValid()); +} + QTEST_MAIN(tst_QIdentityProxyModel) #include "tst_qidentityproxymodel.moc" From b9edbb5d54290331f89a7ced4e4d7807098b61d7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 21 Dec 2016 12:49:53 +0100 Subject: [PATCH 018/304] QLockFile: make sure we encode the hostname as UTF-8 in the lock file We chose to use UTF-8 as it allows us to ensure there's no mistaking the hostname in case the locale is changed, if the host name contains characters outside of US-ASCII. But this didn't work because the code that wrote the hostname always used the local 8-bit codec instead of UTF-8. On Unix, we used the result of gethostname(3) directly, which is supposedly on the locale codec. This commit doesn't fix Windows, which requires _wgetenv, the plan being to encapsulate that with a qEnvironmentVariable() method. [ChangeLog][QtCore][QLockFile] Fixed a bug that caused QLockFile not to recognize a stale lock file if the machine's hostname contained non-US- ASCII characters, on Unix. A Windows fix is still pending. Task-number: QTBUG-49640 Change-Id: Ib9d045544ff370ec901626658a84ec4e6575fe21 Reviewed-by: Thiago Macieira --- src/corelib/io/qlockfile_unix.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 82beb15912..3a80014c00 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -81,15 +81,6 @@ QT_BEGIN_NAMESPACE -static QByteArray localHostName() // from QHostInfo::localHostName(), modified to return a QByteArray -{ - QByteArray hostName(512, Qt::Uninitialized); - if (gethostname(hostName.data(), hostName.size()) == -1) - return QByteArray(); - hostName.truncate(strlen(hostName.data())); - return hostName; -} - // ### merge into qt_safe_write? static qint64 qt_write_loop(int fd, const char *data, qint64 len) { @@ -185,7 +176,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() // Use operator% from the fast builder to avoid multiple memory allocations. QByteArray fileData = QByteArray::number(QCoreApplication::applicationPid()) % '\n' % QCoreApplication::applicationName().toUtf8() % '\n' - % localHostName() % '\n'; + % QSysInfo::machineHostName().toUtf8() % '\n'; const QByteArray lockFileName = QFile::encodeName(fileName); const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0666); @@ -242,7 +233,7 @@ bool QLockFilePrivate::isApparentlyStale() const qint64 pid; QString hostname, appname; if (getLockInfo(&pid, &hostname, &appname)) { - if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) { + if (hostname.isEmpty() || hostname == QSysInfo::machineHostName()) { if (::kill(pid, 0) == -1 && errno == ESRCH) return true; // PID doesn't exist anymore const QString processName = processNameByPid(pid); From 8533c94a244b7ed14dcfaac69b512901fe10737e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 20 Dec 2016 14:28:23 +0100 Subject: [PATCH 019/304] macOS: Take DPR into account when creating CGContexts for a QPixmap Missing logic when refactoring image manipulation methods into QtGui in c52bb030907. Task-number: QTBUG-57723 Change-Id: I7b55d4451d35faf5fd794daa0b80acbd712f30cd Reviewed-by: Gabriel de Dietrich --- src/gui/painting/qcoregraphics.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index 466b18d59b..804c40ecbb 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -495,6 +495,8 @@ QMacCGContext::QMacCGContext(QPaintDevice *paintDevice) : context(0) context = CGBitmapContextCreate(image->bits(), image->width(), image->height(), 8, image->bytesPerLine(), colorspace, flags); CGContextTranslateCTM(context, 0, image->height()); + qreal devicePixelRatio = paintDevice->devicePixelRatioF(); + CGContextScaleCTM(context, devicePixelRatio, devicePixelRatio); CGContextScaleCTM(context, 1, -1); } From 31f0728ac9cc4d49b93742fbe8e948c45c992b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lisandro=20Dami=C3=A1n=20Nicanor=20P=C3=A9rez=20Meyer?= Date: Fri, 16 Dec 2016 16:20:40 -0300 Subject: [PATCH 020/304] Mark QPA symbols as private QPA headers are shipped as private symbols, so they should be marked as such. This helps distros to check which applications/libraries need recompiling on each Qt patch update. Task-number: QTBUG-57060 Change-Id: Ie09d4d10e1edb5127d45a05a3dfa3f4c9dd012f2 Reviewed-by: Dmitry Shachnev Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_module.prf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index 31d628596c..f6cbf99c05 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -206,7 +206,10 @@ android: CONFIG += qt_android_deps no_linker_version_script } else { verscript_content = "Qt_$${QT_MAJOR_VERSION}_PRIVATE_API {" \ " qt_private_api_tag*;" - for(header, SYNCQT.PRIVATE_HEADER_FILES): \ + + private_api_headers = $$SYNCQT.PRIVATE_HEADER_FILES $$SYNCQT.QPA_HEADER_FILES + + for(header, private_api_headers): \ verscript_content += " @FILE:$${_PRO_FILE_PWD_}/$$header@" verscript_content += "};" @@ -227,7 +230,7 @@ android: CONFIG += qt_android_deps no_linker_version_script verscriptprocess.name = linker version script ${QMAKE_FILE_BASE} verscriptprocess.input = verscript_in verscriptprocess.CONFIG += no_link target_predeps - for(header, SYNCQT.PRIVATE_HEADER_FILES): \ + for(header, private_api_headers): \ verscriptprocess.depends += $${_PRO_FILE_PWD_}/$$header verscriptprocess.output = $$verscript verscriptprocess.commands = perl $${PWD}/data/unix/findclasslist.pl < ${QMAKE_FILE_IN} > $@ From 5fc2337d740963d019a1e31960a4d12dfec36ea9 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 19 Dec 2016 18:56:43 +0100 Subject: [PATCH 021/304] Fix unnecessary regeneration of mocables in VS projects Change dcd2f829 introduced fake files with the extension .cbt for custom build tools that generate code from C++ source inputs. The moc_predefs.h header file falls into this category, because it is generated from dummy.cpp. It turns out that these fake files have to exist. Otherwise the custom build step is executed on every build. That means re-moccing all mocables on every build. Fix this by actually creating the fake .cbt files with some explanatory comment in them. Task-number: QTBUG-57695 Change-Id: I251294334425d9914677787d8ba6da1169b4cca5 Reviewed-by: Oswald Buddenhagen Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_vcproj.cpp | 25 +++++++++++++++++++++---- qmake/generators/win32/msvc_vcproj.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 8a77bbe672..ae1d095629 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -766,6 +766,21 @@ bool VcprojGenerator::hasBuiltinCompiler(const QString &file) return false; } +void VcprojGenerator::createCustomBuildToolFakeFile(const QString &cbtFilePath, + const QString &realOutFilePath) +{ + QFile file(fileFixify(cbtFilePath, FileFixifyFromOutdir | FileFixifyAbsolute)); + if (file.exists()) + return; + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + warn_msg(WarnLogic, "Cannot create '%s'.", qPrintable(file.fileName())); + return; + } + file.write("This is a dummy file needed to create "); + file.write(qPrintable(realOutFilePath)); + file.write("\n"); +} + void VcprojGenerator::init() { is64Bit = (project->first("QMAKE_TARGET.arch") == "x86_64"); @@ -893,12 +908,14 @@ void VcprojGenerator::init() if (!hasBuiltinCompiler(file)) { extraCompilerSources[file] += quc.toQString(); } else { - // Use a fake file name foo.moc.cbt for the project view. + // Create a fake file foo.moc.cbt for the project view. // This prevents VS from complaining about a circular // dependency from foo.moc -> foo.moc. - QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables( - compiler_out, file, QString(), NoShell), false); - out += customBuildToolFilterFileSuffix; + QString realOut = replaceExtraCompilerVariables( + compiler_out, file, QString(), NoShell); + QString out = realOut + customBuildToolFilterFileSuffix; + createCustomBuildToolFakeFile(out, realOut); + out = Option::fixPathToTargetOS(out, false); extraCompilerSources[out] += quc.toQString(); extraCompilerOutputs[out] = file; } diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index e3e67d64b9..4882296b46 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -130,6 +130,7 @@ private: bool isStandardSuffix(const QString &suffix) const; ProString firstInputFileName(const ProString &extraCompilerName) const; QString firstExpandedOutputFileName(const ProString &extraCompilerName); + void createCustomBuildToolFakeFile(const QString &cbtFilePath, const QString &realOutFilePath); friend class VCFilter; }; From 88a02c4d6342d092edf3114420e9153c52c90294 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 20 Dec 2016 11:39:22 +0100 Subject: [PATCH 022/304] Remove ToolsVersion from generated VS projects for VS >= 2013 Before VS 2013 ToolsVersion contained a .NET version number (e.g. "4.0"). Since VS 2013 ToolsVersion is the same as the Visual Studio version number (e.g. "12.0"), which is also the default. We always wrote "4.0" (except in one special case which used "14.0"). This doesn't bother Visual Studio itself, but other tools like PVS-Studio. Remove the ToolsVersion attribute from generated VS projects for VS 2013 and newer. Task-number: QTBUG-57694 Change-Id: I7a3bc4534c492e9540f6b968bee8a969980df63f Reviewed-by: Jake Petroules Reviewed-by: Oliver Wolff Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msbuild_objectmodel.cpp | 18 +++++++++++------- qmake/generators/win32/msbuild_objectmodel.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index a0050c9f1f..e42b823598 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -406,7 +406,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) xml << decl("1.0", "utf-8") << tag("Project") << attrTag("DefaultTargets","Build") - << attrTag("ToolsVersion", "4.0") + << attrTagToolsVersion(tool.Configuration) << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003") << tag("ItemGroup") << attrTag("Label", "ProjectConfigurations"); @@ -550,7 +550,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) xmlFilter << decl("1.0", "utf-8") << tag("Project") - << attrTag("ToolsVersion", "4.0") + << attrTagToolsVersion(tool.Configuration) << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); xmlFilter << tag("ItemGroup"); @@ -603,13 +603,10 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) xml.setIndentString(" "); - const QString toolsVersion = (tool.SdkVersion == QLatin1String("10.0")) ? QStringLiteral("14.0") - : QStringLiteral("4.0"); - xml << decl("1.0", "utf-8") << tag("Project") << attrTag("DefaultTargets","Build") - << attrTag("ToolsVersion", toolsVersion) + << attrTagToolsVersion(tool.SingleProjects.first().Configuration) << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003") << tag("ItemGroup") << attrTag("Label", "ProjectConfigurations"); @@ -796,7 +793,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) xmlFilter << decl("1.0", "utf-8") << tag("Project") - << attrTag("ToolsVersion", "4.0") + << attrTagToolsVersion(tool.SingleProjects.first().Configuration) << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); xmlFilter << tag("ItemGroup"); @@ -2056,4 +2053,11 @@ QString VCXProjectWriter::generateCondition(const VCConfiguration &config) return QStringLiteral("'$(Configuration)|$(Platform)'=='") + config.Name + QLatin1Char('\''); } +XmlOutput::xml_output VCXProjectWriter::attrTagToolsVersion(const VCConfiguration &config) +{ + if (config.CompilerVersion >= NET2013) + return noxml(); + return attrTag("ToolsVersion", "4.0"); +} + QT_END_NAMESPACE diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h index d594fbaca8..4bec517fa6 100644 --- a/qmake/generators/win32/msbuild_objectmodel.h +++ b/qmake/generators/win32/msbuild_objectmodel.h @@ -185,6 +185,7 @@ private: bool fileAdded, bool hasCustomBuildStep); static void outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &fileName, const QString &filterName); static QString generateCondition(const VCConfiguration &config); + static XmlOutput::xml_output attrTagToolsVersion(const VCConfiguration &config); friend class XTreeNode; friend class XFlatNode; From 674430cea0edafc374552b4743e2da7d29143453 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 17 Nov 2016 14:59:34 +0100 Subject: [PATCH 023/304] Silence maybe_uninitialized warning with gcc -Og GCC produces false positives for maybe_uninitialized when compiling with -Og in these three places. Simply initialize the variables to silence it. This should be entirely cost-free for normal compilation. Change-Id: Iab778a6ba25993f78f190e928c1fcc2dbd8b2fcd Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/gui/painting/qtriangulatingstroker.cpp | 2 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 +- src/widgets/kernel/qapplication.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qtriangulatingstroker.cpp b/src/gui/painting/qtriangulatingstroker.cpp index d9a3231165..6243f1e2a4 100644 --- a/src/gui/painting/qtriangulatingstroker.cpp +++ b/src/gui/painting/qtriangulatingstroker.cpp @@ -321,7 +321,7 @@ void QTriangulatingStroker::cubicTo(const qreal *pts) if (threshold < 4) threshold = 4; qreal threshold_minus_1 = threshold - 1; - float vx, vy; + float vx = 0, vy = 0; float cx = m_cx, cy = m_cy; float x, y; diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 9e275efa25..1af2cf9b89 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -417,7 +417,7 @@ void QXcbConnection::initializeScreens() qWarning("failed to get the current screen resources"); free(error); } else { - xcb_timestamp_t timestamp; + xcb_timestamp_t timestamp = 0; xcb_randr_output_t *outputs = Q_NULLPTR; int outputCount = xcb_randr_get_screen_resources_current_outputs_length(resources_current.data()); if (outputCount) { diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 358838b4e9..128b5dc2b8 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3305,7 +3305,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), wheel->modifiers(), phase, wheel->source(), wheel->inverted()); bool eventAccepted; - while (w) { + do { we.spont = spontaneous && w == receiver; we.ignore(); res = d->notify_helper(w, &we); @@ -3323,7 +3323,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) we.p += w->pos(); w = w->parentWidget(); - } + } while (w); wheel->setAccepted(eventAccepted); } else if (!spontaneous) { // wheel_widget may forward the wheel event to a delegate widget, From a71b53d6004edb59ad1801f3281ef631fb38c7c4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 12:34:20 +0100 Subject: [PATCH 024/304] fix sysrootification of install paths initially, the idea was that QLibraryInfo would receive a pre-sysrootified ExtPrefix from the builtin qt.conf. matching this against the sysroot would then tell us whether to sysrootify the Prefix from a "regular" qt.conf as well. however, this would have lead to some major ugliness and inconsistency between the code paths, so i changed my mind. unfortunately, i failed to adjust the remaining code, leading to 169a40d51 entirely breaking sysrootification ... the proper (and nicely consistent) solution is to introduce a SysrootifyPrefix key to qt.conf. this is user-accessible as well, so as a bonus it is now possible to adjust the setting at qmake installation time. incidentally, this omission was the last thing that prevented using the same qmake host build for any imaginable configuration of the same qt version ... i think. Change-Id: Ic0eebf21f93651f6374628c0ad8b206d696a4a7e Reviewed-by: Andy Nichols --- configure.pri | 1 + src/corelib/global/qlibraryinfo.cpp | 30 ++++++++++++++--------------- src/corelib/global/qlibraryinfo.h | 1 + 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/configure.pri b/configure.pri index 92020abbbb..7dd1069c0b 100644 --- a/configure.pri +++ b/configure.pri @@ -680,6 +680,7 @@ defineReplace(printHostPaths) { $$printInstallPath(HostLibraries, hostlibdir, lib) \ $$printInstallPath(HostData, hostdatadir, .) \ "Sysroot=$$config.input.sysroot" \ + "SysrootifyPrefix=$$qmake_sysrootify" \ "TargetSpec=$$XSPEC" \ "HostSpec=$$[QMAKE_SPEC]" return($$ret) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 87ee75fa45..3ff37a5818 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -113,13 +113,6 @@ public: ? ls->haveDevicePaths : ls->havePaths) : false; } - static bool sysrootify() - { - // This is actually bogus, as it does not consider post-configure settings. - QLibrarySettings *ls = qt_library_settings(); - return ls ? (!ls->builtinValues[QLibraryInfo::SysrootPath].isEmpty() - && ls->builtinValues[QLibraryInfo::ExtPrefixPath].isEmpty()) : false; - } static QString builtinValue(int loc) { QLibrarySettings *ls = qt_library_settings(); @@ -483,6 +476,7 @@ static const struct { { "Tests", "tests" }, #ifdef QT_BUILD_QMAKE { "Sysroot", "" }, + { "SysrootifyPrefix", "" }, { "HostBinaries", "bin" }, { "HostLibraries", "lib" }, { "HostData", "." }, @@ -522,13 +516,17 @@ QLibraryInfo::location(LibraryLocation loc) QString ret = rawLocation(loc, FinalPaths); // Automatically prepend the sysroot to target paths - if ((loc < SysrootPath || loc > LastHostPath) && QLibraryInfoPrivate::sysrootify()) { + if (loc < SysrootPath || loc > LastHostPath) { QString sysroot = rawLocation(SysrootPath, FinalPaths); - if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':') - && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) - ret.replace(0, 2, sysroot); // Strip out the drive on Windows targets - else - ret.prepend(sysroot); + if (!sysroot.isEmpty() + && QVariant::fromValue(rawLocation(SysrootifyPrefixPath, FinalPaths)).toBool()) { + if (ret.length() > 2 && ret.at(1) == QLatin1Char(':') + && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) { + ret.replace(0, 2, sysroot); // Strip out the drive on Windows targets + } else { + ret.prepend(sysroot); + } + } } return ret; @@ -591,7 +589,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) if (loc == HostPrefixPath) ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key), QLatin1String(qtConfEntries[PrefixPath].value)).toString(); - else if (loc == TargetSpecPath || loc == HostSpecPath) + else if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath) fromConf = false; // The last case here is SysrootPath, which can be legitimately empty. // All other keys have non-empty fallbacks to start with. @@ -645,8 +643,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) } #ifdef QT_BUILD_QMAKE - // The specs need to be returned verbatim. - if (loc == TargetSpecPath || loc == HostSpecPath) + // These values aren't actually paths and thus need to be returned verbatim. + if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath) return ret; #endif diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 9d794ce1da..812ab9a263 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -91,6 +91,7 @@ public: #ifdef QT_BUILD_QMAKE // These are not subject to binary compatibility constraints SysrootPath, + SysrootifyPrefixPath, HostBinariesPath, HostLibrariesPath, HostDataPath, From 4cbec6b7303302a2b3026d5602262e2e9469a0a6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 16:32:59 +0100 Subject: [PATCH 025/304] configure: reload spec after configuring paths this fixes the x-build for raspberry pi, as that spec refers to the sysroot. the path setup doesn't require the device options to be in effect yet, so it was sufficient to move the existing spec reload to a later point in time. Change-Id: Idc521aa13ff441931e954c7c9004472cf7061ee1 Reviewed-by: Andy Nichols --- configure.json | 2 +- configure.pri | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/configure.json b/configure.json index 77f956ed1a..2c27891729 100644 --- a/configure.json +++ b/configure.json @@ -423,7 +423,7 @@ "features": { "prepare": { - "output": [ "prepareSpec", "prepareOptions", "preparePaths" ] + "output": [ "prepareSpec", "prepareOptions", "preparePaths", "reloadSpec" ] }, "machineTuple": { "condition": "!config.linux || config.android || tests.machineTuple", diff --git a/configure.pri b/configure.pri index 7dd1069c0b..10eb8b287e 100644 --- a/configure.pri +++ b/configure.pri @@ -593,9 +593,8 @@ defineTest(qtConfOutput_prepareOptions) { export($${currentConfig}.output.devicePro) - # reload the spec to make the settings actually take effect. - !isEmpty($${currentConfig}.output.devicePro): \ - reloadSpec() + # if any settings were made, the spec will be reloaded later + # to make them take effect. } defineTest(qtConfOutput_machineTuple) { @@ -842,6 +841,15 @@ defineTest(qtConfOutput_preparePaths) { "Prefix=$$QT_SOURCE_TREE" write_file($$QT_BUILD_TREE/bin/qt.conf, cont)|error() reload_properties() + + # if a sysroot was configured, the spec will be reloaded later, + # as some specs contain $$[SYSROOT] references. +} + +defineTest(qtConfOutput_reloadSpec) { + !isEmpty($${currentConfig}.output.devicePro)| \ + !isEmpty(config.input.sysroot): \ + reloadSpec() } defineTest(qtConfOutput_shared) { From 63e7ff97e960987080e6bda668ba960650dca87f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 17:59:07 +0100 Subject: [PATCH 026/304] configure: properly serialize machine tuple detection detecting the machine tuple must happen before committing qdevice.pri. Change-Id: Ic37eda42fff805d6e1edb5dd92898abd59d6bdc9 Reviewed-by: Andy Nichols --- configure.json | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.json b/configure.json index 2c27891729..1886f4074e 100644 --- a/configure.json +++ b/configure.json @@ -430,6 +430,7 @@ "output": [ "machineTuple" ] }, "commit": { + "condition": "features.machineTuple", "output": [ "commitOptions" ] }, "android-style-assets": { From fb7bfbf18d91d0bd0f1c88ee6043e3dfa7ae9b9e Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 20 Dec 2016 21:37:37 +0300 Subject: [PATCH 027/304] examples: Use QOverload to select overloaded signals and slots We can use QOverload since Qt 5.7 (it depends on Q_COMPILER_VARIADIC_TEMPLATES which is required since Qt 5.7). Use it in the examples to show the best practice. qOverload currently can't be used because it requires c++14. Change-Id: I94a3c0db9d551fe169fa3d19c07ec0b329d5946c Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- examples/network/fortuneclient/client.cpp | 3 +-- examples/opengl/paintedwindow/paintedwindow.cpp | 4 +--- examples/opengl/qopenglwidget/mainwindow.cpp | 11 +++-------- examples/opengl/qopenglwindow/main.cpp | 6 ++---- examples/widgets/desktop/screenshot/screenshot.cpp | 3 +-- examples/widgets/desktop/systray/window.cpp | 3 +-- .../widgets/itemviews/basicsortfiltermodel/window.cpp | 6 ++---- examples/widgets/itemviews/pixelator/mainwindow.cpp | 5 ++--- examples/widgets/richtext/textedit/textedit.cpp | 8 +++----- examples/widgets/tools/codecs/previewform.cpp | 3 +-- .../regularexpression/regularexpressiondialog.cpp | 4 ++-- .../widgets/tools/settingseditor/locationdialog.cpp | 7 +++---- examples/widgets/widgets/charactermap/mainwindow.cpp | 8 +++----- examples/widgets/widgets/icons/imagedelegate.cpp | 3 +-- examples/widgets/widgets/icons/mainwindow.cpp | 6 ++---- 15 files changed, 28 insertions(+), 52 deletions(-) diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index 205959936d..c0043e246f 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -122,8 +122,7 @@ Client::Client(QWidget *parent) //! [2] //! [3] connect(tcpSocket, &QIODevice::readyRead, this, &Client::readFortune); //! [2] //! [4] - typedef void (QAbstractSocket::*QAbstractSocketErrorSignal)(QAbstractSocket::SocketError); - connect(tcpSocket, static_cast(&QAbstractSocket::error), + connect(tcpSocket, QOverload::of(&QAbstractSocket::error), //! [3] this, &Client::displayError); //! [4] diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp index 6e031e5cb7..799431a765 100644 --- a/examples/opengl/paintedwindow/paintedwindow.cpp +++ b/examples/opengl/paintedwindow/paintedwindow.cpp @@ -95,9 +95,7 @@ PaintedWindow::PaintedWindow() connect(screen(), &QScreen::orientationChanged, this, &PaintedWindow::orientationChanged); connect(m_animation, &QAbstractAnimation::finished, this, &PaintedWindow::rotationDone); - typedef void (PaintedWindow::*PaintedWindowVoidSlot)(); - connect(this, &PaintedWindow::rotationChanged, - this, static_cast(&PaintedWindow::paint)); + connect(this, &PaintedWindow::rotationChanged, this, QOverload<>::of(&PaintedWindow::paint)); } void PaintedWindow::exposeEvent(QExposeEvent *) diff --git a/examples/opengl/qopenglwidget/mainwindow.cpp b/examples/opengl/qopenglwidget/mainwindow.cpp index f602c9995b..1bb2aa2bf0 100644 --- a/examples/opengl/qopenglwidget/mainwindow.cpp +++ b/examples/opengl/qopenglwidget/mainwindow.cpp @@ -61,8 +61,6 @@ #include "glwidget.h" -typedef void (QWidget::*QWidgetVoidSlot)(); - MainWindow::MainWindow() : m_nextX(1), m_nextY(1) { @@ -131,14 +129,11 @@ MainWindow::MainWindow() QMenu *helpMenu = menuBar()->addMenu("&Help"); helpMenu->addAction("About Qt", qApp, &QApplication::aboutQt); - connect(m_timer, &QTimer::timeout, - glwidget, static_cast(&QWidget::update)); + connect(m_timer, &QTimer::timeout, glwidget, QOverload<>::of(&QWidget::update)); connect(slider, &QAbstractSlider::valueChanged, glwidget, &GLWidget::setScaling); connect(transparent, &QCheckBox::toggled, glwidget, &GLWidget::setTransparent); - - typedef void (QSpinBox::*QSpinBoxIntSignal)(int); - connect(updateInterval, static_cast(&QSpinBox::valueChanged), + connect(updateInterval, QOverload::of(&QSpinBox::valueChanged), this, &MainWindow::updateIntervalChanged); connect(timerBased, &QCheckBox::toggled, this, &MainWindow::timerUsageChanged); connect(timerBased, &QCheckBox::toggled, updateInterval, &QWidget::setEnabled); @@ -162,7 +157,7 @@ void MainWindow::addNew() return; GLWidget *w = new GLWidget(this, false, qRgb(qrand() % 256, qrand() % 256, qrand() % 256)); m_glWidgets << w; - connect(m_timer, &QTimer::timeout, w, static_cast(&QWidget::update)); + connect(m_timer, &QTimer::timeout, w, QOverload<>::of(&QWidget::update)); m_layout->addWidget(w, m_nextY, m_nextX, 1, 1); if (m_nextX == 3) { m_nextX = 1; diff --git a/examples/opengl/qopenglwindow/main.cpp b/examples/opengl/qopenglwindow/main.cpp index 4287d42d24..4f008b45a6 100644 --- a/examples/opengl/qopenglwindow/main.cpp +++ b/examples/opengl/qopenglwindow/main.cpp @@ -173,8 +173,6 @@ void OpenGLWindow::keyPressEvent(QKeyEvent *e) void OpenGLWindow::setAnimating(bool enabled) { - typedef void (QPaintDeviceWindow::*QPaintDeviceWindowVoidSlot)(); - if (enabled) { // Animate continuously, throttled by the blocking swapBuffers() call the // QOpenGLWindow internally executes after each paint. Once that is done @@ -182,11 +180,11 @@ void OpenGLWindow::setAnimating(bool enabled) // obviously assumes that the swap interval (see // QSurfaceFormat::setSwapInterval()) is non-zero. connect(this, &QOpenGLWindow::frameSwapped, - this, static_cast(&QPaintDeviceWindow::update)); + this, QOverload<>::of(&QPaintDeviceWindow::update)); update(); } else { disconnect(this, &QOpenGLWindow::frameSwapped, - this, static_cast(&QPaintDeviceWindow::update)); + this, QOverload<>::of(&QPaintDeviceWindow::update)); } } diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp index 6438eb27cc..80f26ae282 100644 --- a/examples/widgets/desktop/screenshot/screenshot.cpp +++ b/examples/widgets/desktop/screenshot/screenshot.cpp @@ -70,8 +70,7 @@ Screenshot::Screenshot() delaySpinBox->setSuffix(tr(" s")); delaySpinBox->setMaximum(60); - typedef void (QSpinBox::*QSpinBoxIntSignal)(int); - connect(delaySpinBox, static_cast(&QSpinBox::valueChanged), + connect(delaySpinBox, QOverload::of(&QSpinBox::valueChanged), this, &Screenshot::updateCheckBox); hideThisWindowCheckBox = new QCheckBox(tr("Hide This Window"), optionsGroupBox); diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp index 518f03d4b5..5e98996ff3 100644 --- a/examples/widgets/desktop/systray/window.cpp +++ b/examples/widgets/desktop/systray/window.cpp @@ -80,8 +80,7 @@ Window::Window() connect(showMessageButton, &QAbstractButton::clicked, this, &Window::showMessage); connect(showIconCheckBox, &QAbstractButton::toggled, trayIcon, &QSystemTrayIcon::setVisible); - typedef void (QComboBox::*QComboIntSignal)(int); - connect(iconComboBox, static_cast(&QComboBox::currentIndexChanged), + connect(iconComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &Window::setIcon); connect(trayIcon, &QSystemTrayIcon::messageClicked, this, &Window::messageClicked); connect(trayIcon, &QSystemTrayIcon::activated, this, &Window::iconActivated); diff --git a/examples/widgets/itemviews/basicsortfiltermodel/window.cpp b/examples/widgets/itemviews/basicsortfiltermodel/window.cpp index a8a8875f6b..b45ee47ee2 100644 --- a/examples/widgets/itemviews/basicsortfiltermodel/window.cpp +++ b/examples/widgets/itemviews/basicsortfiltermodel/window.cpp @@ -89,11 +89,9 @@ Window::Window() connect(filterPatternLineEdit, &QLineEdit::textChanged, this, &Window::filterRegExpChanged); - - typedef void (QComboBox::*QComboIntSignal)(int); - connect(filterSyntaxComboBox, static_cast(&QComboBox::currentIndexChanged), + connect(filterSyntaxComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &Window::filterRegExpChanged); - connect(filterColumnComboBox, static_cast(&QComboBox::currentIndexChanged), + connect(filterColumnComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &Window::filterColumnChanged); connect(filterCaseSensitivityCheckBox, &QAbstractButton::toggled, this, &Window::filterRegExpChanged); diff --git a/examples/widgets/itemviews/pixelator/mainwindow.cpp b/examples/widgets/itemviews/pixelator/mainwindow.cpp index a5a704a864..2a5b572344 100644 --- a/examples/widgets/itemviews/pixelator/mainwindow.cpp +++ b/examples/widgets/itemviews/pixelator/mainwindow.cpp @@ -113,10 +113,9 @@ MainWindow::MainWindow() connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); connect(aboutAction, &QAction::triggered, this, &MainWindow::showAboutBox); //! [4] - typedef void (QSpinBox::*QSpinBoxIntSignal)(int); - connect(pixelSizeSpinBox, static_cast(&QSpinBox::valueChanged), + connect(pixelSizeSpinBox, QOverload::of(&QSpinBox::valueChanged), delegate, &PixelDelegate::setPixelSize); - connect(pixelSizeSpinBox, static_cast(&QSpinBox::valueChanged), + connect(pixelSizeSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &MainWindow::updateView); //! [4] diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index dec0b0bd35..140ae478ff 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -342,13 +342,11 @@ void TextEdit::setupTextActions() comboStyle->addItem("Ordered List (Roman lower)"); comboStyle->addItem("Ordered List (Roman upper)"); - typedef void (QComboBox::*QComboIntSignal)(int); - connect(comboStyle, static_cast(&QComboBox::activated), this, &TextEdit::textStyle); + connect(comboStyle, QOverload::of(&QComboBox::activated), this, &TextEdit::textStyle); - typedef void (QComboBox::*QComboStringSignal)(const QString &); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); - connect(comboFont, static_cast(&QComboBox::activated), this, &TextEdit::textFamily); + connect(comboFont, QOverload::of(&QComboBox::activated), this, &TextEdit::textFamily); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); @@ -360,7 +358,7 @@ void TextEdit::setupTextActions() comboSize->addItem(QString::number(size)); comboSize->setCurrentIndex(standardSizes.indexOf(QApplication::font().pointSize())); - connect(comboSize, static_cast(&QComboBox::activated), this, &TextEdit::textSize); + connect(comboSize, QOverload::of(&QComboBox::activated), this, &TextEdit::textSize); } bool TextEdit::load(const QString &f) diff --git a/examples/widgets/tools/codecs/previewform.cpp b/examples/widgets/tools/codecs/previewform.cpp index e5ca13f011..d19b9c0833 100644 --- a/examples/widgets/tools/codecs/previewform.cpp +++ b/examples/widgets/tools/codecs/previewform.cpp @@ -159,8 +159,7 @@ PreviewForm::PreviewForm(QWidget *parent) new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); okButton = buttonBox->button(QDialogButtonBox::Ok); - typedef void(QComboBox::*ComboBoxIntSignal)(int); - connect(encodingComboBox, static_cast(&QComboBox::activated), + connect(encodingComboBox, QOverload::of(&QComboBox::activated), this, &PreviewForm::updateTextEdit); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp index f13240d06f..7a67c763d8 100644 --- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp +++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp @@ -94,10 +94,10 @@ RegularExpressionDialog::RegularExpressionDialog(QWidget *parent) connect(optimizeOnFirstUsageOptionCheckBox, &QCheckBox::toggled, this, &RegularExpressionDialog::refresh); connect(dontAutomaticallyOptimizeOptionCheckBox, &QCheckBox::toggled, this, &RegularExpressionDialog::refresh); - connect(offsetSpinBox, static_cast(&QSpinBox::valueChanged), + connect(offsetSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &RegularExpressionDialog::refresh); - connect(matchTypeComboBox, static_cast(&QComboBox::currentIndexChanged), + connect(matchTypeComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &RegularExpressionDialog::refresh); connect(anchoredMatchOptionCheckBox, &QCheckBox::toggled, this, &RegularExpressionDialog::refresh); diff --git a/examples/widgets/tools/settingseditor/locationdialog.cpp b/examples/widgets/tools/settingseditor/locationdialog.cpp index 4aa1e6073f..5b6e2652bb 100644 --- a/examples/widgets/tools/settingseditor/locationdialog.cpp +++ b/examples/widgets/tools/settingseditor/locationdialog.cpp @@ -106,10 +106,9 @@ LocationDialog::LocationDialog(QWidget *parent) buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - typedef void (QComboBox::*QComboIntSignal)(int); - connect(formatComboBox, static_cast(&QComboBox::activated), + connect(formatComboBox, QOverload::of(&QComboBox::activated), this, &LocationDialog::updateLocationsTable); - connect(scopeComboBox, static_cast(&QComboBox::activated), + connect(scopeComboBox, QOverload::of(&QComboBox::activated), this, &LocationDialog::updateLocationsTable); connect(organizationComboBox->lineEdit(), &QLineEdit::editingFinished, @@ -117,7 +116,7 @@ LocationDialog::LocationDialog(QWidget *parent) connect(applicationComboBox->lineEdit(), &QLineEdit::editingFinished, this, &LocationDialog::updateLocationsTable); - connect(applicationComboBox, static_cast(&QComboBox::activated), + connect(applicationComboBox, QOverload::of(&QComboBox::activated), this, &LocationDialog::updateLocationsTable); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp index 8b406ba1ca..5f17128a2f 100644 --- a/examples/widgets/widgets/charactermap/mainwindow.cpp +++ b/examples/widgets/widgets/charactermap/mainwindow.cpp @@ -74,8 +74,7 @@ MainWindow::MainWindow() filterCombo->addItem(tr("Monospaced"), QVariant::fromValue(QFontComboBox::MonospacedFonts)); filterCombo->addItem(tr("Proportional"), QVariant::fromValue(QFontComboBox::ProportionalFonts)); filterCombo->setCurrentIndex(0); - typedef void (QComboBox::*QComboBoxIntSignal)(int); - connect(filterCombo, static_cast(&QComboBox::currentIndexChanged), + connect(filterCombo, QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::filterChanged); QLabel *fontLabel = new QLabel(tr("Font:")); @@ -114,10 +113,9 @@ MainWindow::MainWindow() this, &MainWindow::findSizes); connect(fontCombo, &QFontComboBox::currentFontChanged, characterWidget, &CharacterWidget::updateFont); - typedef void (QComboBox::*QComboBoxStringSignal)(const QString &); - connect(sizeCombo, static_cast(&QComboBox::currentIndexChanged), + connect(sizeCombo, QOverload::of(&QComboBox::currentIndexChanged), characterWidget, &CharacterWidget::updateSize); - connect(styleCombo, static_cast(&QComboBox::currentIndexChanged), + connect(styleCombo, QOverload::of(&QComboBox::currentIndexChanged), characterWidget, &CharacterWidget::updateStyle); //! [4] //! [5] connect(characterWidget, &CharacterWidget::characterSelected, diff --git a/examples/widgets/widgets/icons/imagedelegate.cpp b/examples/widgets/widgets/icons/imagedelegate.cpp index 980013daee..3c873f1e24 100644 --- a/examples/widgets/widgets/icons/imagedelegate.cpp +++ b/examples/widgets/widgets/icons/imagedelegate.cpp @@ -71,8 +71,7 @@ QWidget *ImageDelegate::createEditor(QWidget *parent, else if (index.column() == 2) comboBox->addItems(IconPreviewArea::iconStateNames()); - typedef void (QComboBox::*QComboBoxIntSignal)(int); - connect(comboBox, static_cast(&QComboBox::activated), + connect(comboBox, QOverload::of(&QComboBox::activated), this, &ImageDelegate::emitCommitData); return comboBox; diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp index 5f3882de94..f704b8306f 100644 --- a/examples/widgets/widgets/icons/mainwindow.cpp +++ b/examples/widgets/widgets/icons/mainwindow.cpp @@ -362,8 +362,7 @@ QWidget *MainWindow::createIconSizeGroupBox() sizeButtonGroup = new QButtonGroup(this); sizeButtonGroup->setExclusive(true); - typedef void (QButtonGroup::*QButtonGroupIntBoolSignal)(int, bool); - connect(sizeButtonGroup, static_cast(&QButtonGroup::buttonToggled), + connect(sizeButtonGroup, QOverload::of(&QButtonGroup::buttonToggled), this, &MainWindow::changeSize); QRadioButton *smallRadioButton = new QRadioButton; @@ -391,8 +390,7 @@ QWidget *MainWindow::createIconSizeGroupBox() //! [26] //! [27] - typedef void (QSpinBox::*QSpinBoxIntSignal)(int); - connect(otherSpinBox, static_cast(&QSpinBox::valueChanged), + connect(otherSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &MainWindow::triggerChangeSize); QHBoxLayout *otherSizeLayout = new QHBoxLayout; From 49f1b667fa810428f9d3b5451d616c6cd9f390ca Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 28 Nov 2016 15:14:46 +0300 Subject: [PATCH 028/304] platform plugins: Remove unused former overriders They were implied to override QPlatformIntegrationPlugin::keys() but it was removed before releasing Qt 5.0. Change-Id: Ia1f1ad27b7511b1141887f5dcde0dadeb2e5cabf Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/mirclient/qmirclientplugin.cpp | 7 ------- src/plugins/platforms/mirclient/qmirclientplugin.h | 1 - src/plugins/platforms/winrt/main.cpp | 6 ------ 3 files changed, 14 deletions(-) diff --git a/src/plugins/platforms/mirclient/qmirclientplugin.cpp b/src/plugins/platforms/mirclient/qmirclientplugin.cpp index 201b68c304..6899d70f2e 100644 --- a/src/plugins/platforms/mirclient/qmirclientplugin.cpp +++ b/src/plugins/platforms/mirclient/qmirclientplugin.cpp @@ -41,13 +41,6 @@ #include "qmirclientplugin.h" #include "qmirclientintegration.h" -QStringList QMirClientIntegrationPlugin::keys() const -{ - QStringList list; - list << QStringLiteral("mirclient"); - return list; -} - QPlatformIntegration* QMirClientIntegrationPlugin::create(const QString &system, const QStringList &) { diff --git a/src/plugins/platforms/mirclient/qmirclientplugin.h b/src/plugins/platforms/mirclient/qmirclientplugin.h index 8b5da6e4f6..c91f2d1924 100644 --- a/src/plugins/platforms/mirclient/qmirclientplugin.h +++ b/src/plugins/platforms/mirclient/qmirclientplugin.h @@ -49,7 +49,6 @@ class QMirClientIntegrationPlugin : public QPlatformIntegrationPlugin Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "mirclient.json") public: - QStringList keys() const; QPlatformIntegration* create(const QString&, const QStringList&); }; diff --git a/src/plugins/platforms/winrt/main.cpp b/src/plugins/platforms/winrt/main.cpp index 5d0d9e94eb..222287b3ef 100644 --- a/src/plugins/platforms/winrt/main.cpp +++ b/src/plugins/platforms/winrt/main.cpp @@ -49,15 +49,9 @@ class QWinRTIntegrationPlugin : public QPlatformIntegrationPlugin Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "winrt.json") public: - QStringList keys() const; QPlatformIntegration *create(const QString&, const QStringList&) override; }; -QStringList QWinRTIntegrationPlugin::keys() const -{ - return QStringList(QStringLiteral("WinRT")); -} - QPlatformIntegration *QWinRTIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); From fe2f8146d43c769392953cf55014e53510a0ce2b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 6 Dec 2016 18:49:53 +0100 Subject: [PATCH 029/304] prune vestiges of DEPLOYMENT_PLUGIN the code was broken since 5.0, as it still hardcoded the version number 4 for the plugin basenames. wince is not supported any more, so there is no point in trying to restore the code to function. at a later point, we'll make QTPLUGIN universal enough to cover both static and dynamic deployment. Change-Id: I0911ce4aff7a799dd471d6218e046f13dca6d49e Reviewed-by: Jake Petroules Reviewed-by: Joerg Bornemann Reviewed-by: Andy Shaw --- .../imagescaling/imagescaling.pro | 2 -- examples/sql/sqlbrowser/sqlbrowser.pro | 5 ---- .../sql/sqlwidgetmapper/sqlwidgetmapper.pro | 2 -- mkspecs/features/qt.prf | 23 ++----------------- .../snippets/code/doc_src_qmake-manual.pro | 4 ---- qmake/doc/src/qmake-manual.qdoc | 18 --------------- 6 files changed, 2 insertions(+), 52 deletions(-) diff --git a/examples/qtconcurrent/imagescaling/imagescaling.pro b/examples/qtconcurrent/imagescaling/imagescaling.pro index da237bd6af..110f8f1b0b 100644 --- a/examples/qtconcurrent/imagescaling/imagescaling.pro +++ b/examples/qtconcurrent/imagescaling/imagescaling.pro @@ -5,5 +5,3 @@ HEADERS += imagescaling.h target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/imagescaling INSTALLS += target - -wince: DEPLOYMENT_PLUGIN += qgif qjpeg diff --git a/examples/sql/sqlbrowser/sqlbrowser.pro b/examples/sql/sqlbrowser/sqlbrowser.pro index 539796fe71..1cc13d754f 100644 --- a/examples/sql/sqlbrowser/sqlbrowser.pro +++ b/examples/sql/sqlbrowser/sqlbrowser.pro @@ -15,8 +15,3 @@ build_all:!build_pass { # install target.path = $$[QT_INSTALL_EXAMPLES]/sql/sqlbrowser INSTALLS += target - - -wince { - DEPLOYMENT_PLUGIN += qsqlite -} diff --git a/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro b/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro index 44815407d7..fe600a9124 100644 --- a/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro +++ b/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro @@ -7,6 +7,4 @@ QT += sql widgets target.path = $$[QT_INSTALL_EXAMPLES]/sql/sqlwidgetmapper INSTALLS += target -wince: DEPLOYMENT_PLUGIN += qsqlite - diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 98f794c485..28a2104f28 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -315,9 +315,7 @@ contains(TEMPLATE, .*app) { QTPLUGIN = $$manualplugs $$autoplugs } -QT_PLUGIN_VERIFY = DEPLOYMENT_PLUGIN qtConfig(static) { - QT_PLUGIN_VERIFY += QTPLUGIN force_import_plugins|contains(TEMPLATE, .*app) { import_plugins:!isEmpty(QTPLUGIN) { IMPORT_FILE_CONT = \ @@ -337,10 +335,8 @@ qtConfig(static) { QMAKE_DISTCLEAN += $$IMPORT_CPP } } -} -for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) { - for(QTPLUG, $$list($$lower($$unique($$QT_CURRENT_VERIFY)))) { + for (QTPLUG, $$list($$lower($$unique(QTPLUGIN)))) { # Check if the plugin is known to Qt. We can use this to determine # the plugin path. Unknown plugins must rely on the default link path. QT_PLUGINPATH = $$eval(QT_PLUGIN.$${QTPLUG}.TYPE) @@ -349,7 +345,7 @@ for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) { QT_LINKAGE = -l$${QTPLUG}$$qtPlatformTargetSuffix() # Only link against plugin in static builds - isEqual(QT_CURRENT_VERIFY, QTPLUGIN) { + { !isEmpty(QT_PLUGINPATH) { plugpath = $$eval(QT_PLUGIN.$${QTPLUG}.PATH) isEmpty(plugpath): \ @@ -357,21 +353,6 @@ for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) { LIBS *= -L$$plugpath/$$QT_PLUGINPATH } LIBS += $$QT_LINKAGE - # if the plugin is linked statically there is no need to deploy it - DEPLOYMENT_PLUGIN -= $$QT_CURRENT_VERIFY - } - - # The following block is currently broken, because qt_plugin_XXX.prf files - # are not generated for dynamic builds. - false:isEqual(QT_CURRENT_VERIFY, DEPLOYMENT_PLUGIN):shared:winrt { - QT_ITEM = - debug: QT_ITEM = $${QTPLUG}d4.dll - else: QT_ITEM = $${QTPLUG}4.dll - - qt_additional_plugin_$${QTPLUG}.files = $$[QT_INSTALL_PLUGINS/get]/$${QT_PLUGINPATH}/$${QT_ITEM} - qt_additional_plugin_$${QTPLUG}.path = $${QT_PLUGINPATH} - - INSTALLS *= qt_additional_plugin_$${QTPLUG} } } } diff --git a/qmake/doc/snippets/code/doc_src_qmake-manual.pro b/qmake/doc/snippets/code/doc_src_qmake-manual.pro index c3b6e6595f..1710826f2d 100644 --- a/qmake/doc/snippets/code/doc_src_qmake-manual.pro +++ b/qmake/doc/snippets/code/doc_src_qmake-manual.pro @@ -784,10 +784,6 @@ CONFIG(debug, debug|release) { } #! [127] -#! [142] -DEPLOYMENT_PLUGIN += qjpeg -#! [142] - #! [149] SUBDIRS += my_executable my_library my_executable.subdir = app diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index c3c878ebb8..4ff64f59d6 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -1119,24 +1119,6 @@ Specifies a list of all directories to look in to resolve dependencies. This variable is used when crawling through \c included files. - \target DEPLOYMENT_PLUGIN - \section1 DEPLOYMENT_PLUGIN - - \note This variable is used only on the Windows CE platform. - - Specifies the Qt plugins that will be deployed. All plugins - available in Qt can be explicitly deployed to the device. See - \l{Static Plugins}{Static Plugins} for a complete list. - - \note No plugins will be deployed automatically to Windows CE devices. - If the application depends on plugins, these plugins have to be specified - manually. - - For example, the following definition uploads the jpeg imageformat plugin to - the plugins directory on the Windows CE device: - - \snippet code/doc_src_qmake-manual.pro 142 - \target DESTDIR \section1 DESTDIR From d0db09681fc12082d717f3af88175775e0fa18fb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 19:35:19 +0100 Subject: [PATCH 030/304] prune obsolete qml file deployment static builds of qt have been embedding their qml files via the qt resource system since qt 5.7, so the code which attempted to deploy them into mac bundles (introduced in qt 5.2) is useless nowadays. Change-Id: I830cd2b660f7cab42a46ec8e002a42d9d299b528 Reviewed-by: Jake Petroules Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 28a2104f28..bfa6c7988d 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -238,40 +238,6 @@ contains(qt_module_deps, qml): \ write_file($$QML_IMPORT_CPP, IMPORT_FILE_CONT)|error() GENERATED_SOURCES += $$QML_IMPORT_CPP QMAKE_DISTCLEAN += $$QML_IMPORT_CPP - - # copy qml files. this part is platform spesific. - mac { - osx { - # Note: user can override QMAKE_BUNDLE_QML from pro file to change target bundle path - isEmpty(QMAKE_QML_BUNDLE_PATH):QMAKE_QML_BUNDLE_PATH = "Resources/qt_qml" - qmlTargetPath = $$OUT_PWD/$${TARGET}.app/Contents/$$QMAKE_QML_BUNDLE_PATH - qtconfTargetPath = $$OUT_PWD/$${TARGET}.app/Contents/Resources/qt.conf - } else { - # iOS: flat bundle layout (no Contents/Resources) - isEmpty(QMAKE_QML_BUNDLE_PATH):QMAKE_QML_BUNDLE_PATH = "qt_qml" - qmlTargetPath = $CODESIGNING_FOLDER_PATH/$$QMAKE_QML_BUNDLE_PATH - qtconfTargetPath = $CODESIGNING_FOLDER_PATH/qt.conf - } - - # set import path in qt.conf to point to the bundeled qml: - QT_CONF_CONTENTS = \ - "[Paths]" \ - "Imports = $$QMAKE_QML_BUNDLE_PATH" \ - "Qml2Imports = $$QMAKE_QML_BUNDLE_PATH" - write_file("$$OUT_PWD/qt.conf", QT_CONF_CONTENTS)|error() - - # write qt.conf and copy each qml import dir into the bundle. - # But strip away archives and other files that are not needed: - !isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK += ";" - QMAKE_POST_LINK += \ - "cp $$shell_quote($$OUT_PWD/qt.conf) \"$$qtconfTargetPath\"; " \ - "test -d \"$$qmlTargetPath\" && rm -r \"$$qmlTargetPath\"; " \ - "mkdir -p \"$$qmlTargetPath\" && " \ - "for p in $$QMLPATHS; do" \ - "rsync -r --exclude='*.a' --exclude='*.prl' --exclude='*.qmltypes' " - macx-xcode: QMAKE_POST_LINK += "$p/ \"$$qmlTargetPath\"; done" - else: QMAKE_POST_LINK += "\$\$p/ \"$$qmlTargetPath\"; done" - } } } From 1b5271f27f7d5c6f814567d6d3bf211b41244cc8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 15 Dec 2016 16:20:27 +0100 Subject: [PATCH 031/304] determine compiler version at build time, not in configure this makes it consistent with the determination of the default include/library paths. this makes sense, as it's possible to switch the sdk/toolchain after building qt (within reason). a side effect of this change is that for compilers which emulate other compilers, both the real and the emulated version are now made available. Change-Id: Icfcc672c0d2e3d1b5e622993c366063d70ad327c Started-by: Thiago Macieira Reviewed-by: Lars Knoll --- config.tests/win/msvc_version.cpp | 1 - configure.json | 10 ---- configure.pri | 63 -------------------- mkspecs/common/msvc-desktop.conf | 2 +- mkspecs/features/data/macros.cpp | 28 +++++++++ mkspecs/features/toolchain.prf | 76 ++++++++++++++++++++++++ mkspecs/winphone-arm-msvc2013/qmake.conf | 1 - mkspecs/winphone-x86-msvc2013/qmake.conf | 1 - mkspecs/winrt-arm-msvc2013/qmake.conf | 1 - mkspecs/winrt-arm-msvc2015/qmake.conf | 1 - mkspecs/winrt-x64-msvc2013/qmake.conf | 1 - mkspecs/winrt-x64-msvc2015/qmake.conf | 2 +- mkspecs/winrt-x86-msvc2013/qmake.conf | 2 +- mkspecs/winrt-x86-msvc2015/qmake.conf | 2 +- 14 files changed, 108 insertions(+), 83 deletions(-) delete mode 100644 config.tests/win/msvc_version.cpp create mode 100644 mkspecs/features/data/macros.cpp diff --git a/config.tests/win/msvc_version.cpp b/config.tests/win/msvc_version.cpp deleted file mode 100644 index 3d7232e8e2..0000000000 --- a/config.tests/win/msvc_version.cpp +++ /dev/null @@ -1 +0,0 @@ -_MSC_FULL_VER diff --git a/configure.json b/configure.json index 1886f4074e..7d675c02be 100644 --- a/configure.json +++ b/configure.json @@ -253,11 +253,6 @@ "type": "compile", "test": "common/c++98default" }, - "compiler": { - "label": "Compiler", - "type": "checkCompiler", - "log": "compilerDescription" - }, "precompile_header": { "label": "precompiled header support", "type": "compile", @@ -684,11 +679,6 @@ "condition": "features.c++14 && tests.c++1z", "output": [ "publicFeature", "publicQtConfig" ] }, - "compiler": { - "label": "Compiler version", - "condition": "tests.compiler", - "output": [ "compilerVersion" ] - }, "precompile_header": { "label": "Using precompiled headers", "condition": "config.msvc || tests.precompile_header", diff --git a/configure.pri b/configure.pri index 10eb8b287e..1744972f92 100644 --- a/configure.pri +++ b/configure.pri @@ -397,50 +397,6 @@ defineTest(qtConfTest_buildParts) { return(true) } -defineTest(qtConfTest_checkCompiler) { - contains(QMAKE_CXX, ".*clang.*") { - qtRunLoggedCommand("$$QMAKE_CXX -v 2>&1", versionstr)|return(false) - versionstr = "$$versionstr" - contains(versionstr, "^Apple (clang|LLVM) version .*") { - $${1}.compilerDescription = "Apple Clang" - $${1}.compilerId = "apple_clang" - $${1}.compilerVersion = $$replace(versionstr, "^Apple (clang|LLVM) version ([0-9.]+).*$", "\\2") - } else: contains(versionstr, ".*clang version.*") { - $${1}.compilerDescription = "Clang" - $${1}.compilerId = "clang" - $${1}.compilerVersion = $$replace(versionstr, "^.*clang version ([0-9.]+).*", "\\1") - } else { - return(false) - } - } else: contains(QMAKE_CXX, ".*g\\+\\+.*") { - qtRunLoggedCommand("$$QMAKE_CXX -dumpversion", version)|return(false) - $${1}.compilerDescription = "GCC" - $${1}.compilerId = "gcc" - $${1}.compilerVersion = $$version - } else: contains(QMAKE_CXX, ".*icpc") { - qtRunLoggedCommand("$$QMAKE_CXX -dumpversion", version)|return(false) - $${1}.compilerDescription = "ICC" - $${1}.compilerId = "icc" - $${1}.compilerVersion = $$version - } else: msvc { - command = $$QMAKE_CXX /EP /nologo $$source $$system_quote($$QMAKE_CONFIG_TESTS_DIR/win/msvc_version.cpp) - qtRunLoggedCommand("$$command", version)|return(false) - version = "$$version" - $${1}.compilerDescription = "MSVC" - $${1}.compilerId = "cl" - $${1}.compilerVersion = $$replace(version, "^.*([0-9]{2})([0-9]{2})([0-9]{5}).*$", "\\1.\\2.\\3") - } else { - return(false) - } - $${1}.compilerDescription += $$eval($${1}.compilerVersion) - export($${1}.compilerDescription) - export($${1}.compilerId) - export($${1}.compilerVersion) - $${1}.cache += compilerDescription compilerId compilerVersion - export($${1}.cache) - return(true) -} - # custom outputs # this reloads the qmakespec as completely as reasonably possible. @@ -947,25 +903,6 @@ defineTest(qtConfOutput_debugAndRelease) { } } -defineTest(qtConfOutput_compilerVersion) { - !$${2}: return() - - name = $$upper($$eval($${currentConfig}.tests.compiler.compilerId)) - version = $$eval($${currentConfig}.tests.compiler.compilerVersion) - major = $$section(version, '.', 0, 0) - minor = $$section(version, '.', 1, 1) - patch = $$section(version, '.', 2, 2) - isEmpty(minor): minor = 0 - isEmpty(patch): patch = 0 - - $${currentConfig}.output.publicPro += \ - "QT_$${name}_MAJOR_VERSION = $$major" \ - "QT_$${name}_MINOR_VERSION = $$minor" \ - "QT_$${name}_PATCH_VERSION = $$patch" - - export($${currentConfig}.output.publicPro) -} - defineTest(qtConfOutput_compilerFlags) { # this output also exports the variables locally, so that subsequent compiler tests can use them diff --git a/mkspecs/common/msvc-desktop.conf b/mkspecs/common/msvc-desktop.conf index 1b9d57bff0..ebe804db64 100644 --- a/mkspecs/common/msvc-desktop.conf +++ b/mkspecs/common/msvc-desktop.conf @@ -16,7 +16,7 @@ QMAKE_PLATFORM = win32 QMAKE_COMPILER = msvc CONFIG += incremental flat precompile_header autogen_precompile_source debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe DEFINES += UNICODE WIN32 -QMAKE_COMPILER_DEFINES += _MSC_VER=$$MSC_VER _WIN32 +QMAKE_COMPILER_DEFINES += _WIN32 contains(QMAKE_TARGET.arch, x86_64) { DEFINES += WIN64 QMAKE_COMPILER_DEFINES += _WIN64 diff --git a/mkspecs/features/data/macros.cpp b/mkspecs/features/data/macros.cpp new file mode 100644 index 0000000000..88473fb980 --- /dev/null +++ b/mkspecs/features/data/macros.cpp @@ -0,0 +1,28 @@ +// Keep this file small. The pre-processed contents are eval'd by qmake. +#ifdef _MSC_VER +QMAKE_MSC_VER = _MSC_VER +QMAKE_MSC_FULL_VER = _MSC_FULL_VER +#endif +#ifdef __INTEL_COMPILER +QMAKE_ICC_VER = __INTEL_COMPILER +QMAKE_ICC_UPDATE_VER = __INTEL_COMPILER_UPDATE +#endif +#ifdef __APPLE_CC__ +QMAKE_APPLE_CC = __APPLE_CC__ +#endif +#ifdef __clang__ +#ifdef __APPLE_CC__ +QT_APPLE_CLANG_MAJOR_VERSION = __clang_major__ +QT_APPLE_CLANG_MINOR_VERSION = __clang_minor__ +QT_APPLE_CLANG_PATCH_VERSION = __clang_patchlevel__ +#else +QT_CLANG_MAJOR_VERSION = __clang_major__ +QT_CLANG_MINOR_VERSION = __clang_minor__ +QT_CLANG_PATCH_VERSION = __clang_patchlevel__ +#endif +#endif +#ifdef __GNUC__ +QT_GCC_MAJOR_VERSION = __GNUC__ +QT_GCC_MINOR_VERSION = __GNUC_MINOR__ +QT_GCC_PATCH_VERSION = __GNUC_PATCHLEVEL__ +#endif diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 0ef0fa8fc7..2fccd64fc5 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -58,3 +58,79 @@ isEmpty(QMAKE_DEFAULT_INCDIRS):!host_build { !isEmpty(QMAKE_DEFAULT_INCDIRS): cache(QMAKE_DEFAULT_INCDIRS, set stash) !isEmpty(QMAKE_DEFAULT_LIBDIRS): cache(QMAKE_DEFAULT_LIBDIRS, set stash) } + +# +# Determine and cache the compiler version +# + +defineReplace(qtVariablesFromMSVC) { + return($$system("$$1 -nologo -E $$2 $$system_quote($$PWD/data/macros.cpp) NUL", lines)) +} + +defineReplace(qtVariablesFromGCC) { + null_device = /dev/null + equals(QMAKE_HOST.os, Windows): null_device = NUL + return($$system("$$1 -E $$system_quote($$PWD/data/macros.cpp) <$$null_device 2>$$null_device", lines)) +} + +host_build: \ + target_prefix = QMAKE_HOST_CXX +else: \ + target_prefix = QMAKE_CXX + +isEmpty($${target_prefix}.COMPILER_MACROS) { + msvc { + vars = $$qtVariablesFromMSVC($$QMAKE_CXX $$QMAKE_CXXFLAGS) + } else: gcc { + vars = $$qtVariablesFromGCC($$QMAKE_CXX) + } + for (v, vars) { + isEmpty(v)|contains(v, $${LITERAL_HASH}.*): next() + # Set both for the outer scope ... + eval($$v) + v ~= s/ .*// + isEmpty($$v): error("Compiler produced empty value for $${v}.") + # ... and save QMAKE_(HOST_)?CXX. in the cache. + cache($${target_prefix}.$$v, set stash, $$v) + $${target_prefix}.COMPILER_MACROS += $$v + } + cache($${target_prefix}.COMPILER_MACROS, set stash) +} else { + # load from the cache + for (i, $${target_prefix}.COMPILER_MACROS): \ + $$i = $$eval($${target_prefix}.$$i) +} + +unset(target_prefix) + +# Populate QMAKE_COMPILER_DEFINES and some compatibility variables. +# The $$format_number() calls strip leading zeros to avoid misinterpretation as octal. +!isEmpty(QMAKE_MSC_VER) { + QMAKE_COMPILER_DEFINES += _MSC_VER=$$QMAKE_MSC_VER _MSC_FULL_VER=$$QMAKE_MSC_FULL_VER + QT_MSVC_MAJOR_VERSION = $$replace(QMAKE_MSC_FULL_VER, "(..)(..)(.*)", "\\1") + QT_MSVC_MINOR_VERSION = $$format_number($$replace(QMAKE_MSC_FULL_VER, "(..)(..)(.*)", "\\2")) + QT_MSVC_PATCH_VERSION = $$replace(QMAKE_MSC_FULL_VER, "(..)(..)(.*)", "\\3")) +} +!isEmpty(QMAKE_ICC_VER) { + QMAKE_COMPILER_DEFINES += __INTEL_COMPILER=$$QMAKE_ICC_VER __INTEL_COMPILER_UPDATE=$$QMAKE_ICC_UPDATE_VER + QT_ICC_MAJOR_VERSION = $$replace(QMAKE_ICC_VER, "(..)(..)", "\\1") + QT_ICC_MINOR_VERSION = $$format_number($$replace(QMAKE_ICC_VER, "(..)(..)", "\\2")) + QT_ICC_PATCH_VERSION = $$QMAKE_ICC_UPDATE_VER +} +!isEmpty(QMAKE_APPLE_CC): \ + QMAKE_COMPILER_DEFINES += __APPLE_CC__=$$QMAKE_APPLE_CC +!isEmpty(QT_APPLE_CLANG_MAJOR_VERSION): \ + QMAKE_COMPILER_DEFINES += __clang__ \ + __clang_major__=$$QT_APPLE_CLANG_MAJOR_VERSION \ + __clang_minor__=$$QT_APPLE_CLANG_MINOR_VERSION \ + __clang_patchlevel__=$$QT_APPLE_CLANG_PATCH_VERSION +!isEmpty(QT_CLANG_MAJOR_VERSION): \ + QMAKE_COMPILER_DEFINES += __clang__ \ + __clang_major__=$$QT_CLANG_MAJOR_VERSION \ + __clang_minor__=$$QT_CLANG_MINOR_VERSION \ + __clang_patchlevel__=$$QT_CLANG_PATCH_VERSION +!isEmpty(QT_GCC_MAJOR_VERSION): \ + QMAKE_COMPILER_DEFINES += \ + __GNUC__=$$QT_GCC_MAJOR_VERSION \ + __GNUC_MINOR__=$$QT_GCC_MINOR_VERSION \ + __GNUC_PATCHLEVEL__=$$QT_GCC_PATCH_VERSION diff --git a/mkspecs/winphone-arm-msvc2013/qmake.conf b/mkspecs/winphone-arm-msvc2013/qmake.conf index ca2cc50e84..64ff295f14 100644 --- a/mkspecs/winphone-arm-msvc2013/qmake.conf +++ b/mkspecs/winphone-arm-msvc2013/qmake.conf @@ -5,7 +5,6 @@ # include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _MSC_VER=1800 QMAKE_PLATFORM = winphone $$QMAKE_PLATFORM DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP ARM __ARM__ __ARM__ CONFIG += no_generated_target_info diff --git a/mkspecs/winphone-x86-msvc2013/qmake.conf b/mkspecs/winphone-x86-msvc2013/qmake.conf index ad8dbe1fee..bc074f03dd 100644 --- a/mkspecs/winphone-x86-msvc2013/qmake.conf +++ b/mkspecs/winphone-x86-msvc2013/qmake.conf @@ -5,7 +5,6 @@ # include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _MSC_VER=1800 QMAKE_PLATFORM = winphone $$QMAKE_PLATFORM DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP X86 __X86__ __x86__ CONFIG += no_generated_target_info diff --git a/mkspecs/winrt-arm-msvc2013/qmake.conf b/mkspecs/winrt-arm-msvc2013/qmake.conf index f8b48b0829..547884ce7e 100644 --- a/mkspecs/winrt-arm-msvc2013/qmake.conf +++ b/mkspecs/winrt-arm-msvc2013/qmake.conf @@ -5,7 +5,6 @@ # include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _MSC_VER=1800 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP ARM __ARM__ __arm__ QMAKE_CFLAGS += -FS diff --git a/mkspecs/winrt-arm-msvc2015/qmake.conf b/mkspecs/winrt-arm-msvc2015/qmake.conf index 7a9375246d..ef145ae44b 100644 --- a/mkspecs/winrt-arm-msvc2015/qmake.conf +++ b/mkspecs/winrt-arm-msvc2015/qmake.conf @@ -6,7 +6,6 @@ MSC_VER = 1900 include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _MSC_VER=1900 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 ARM __ARM__ __arm__ QMAKE_CFLAGS += -FS diff --git a/mkspecs/winrt-x64-msvc2013/qmake.conf b/mkspecs/winrt-x64-msvc2013/qmake.conf index 594d0dafd0..c90db8b314 100644 --- a/mkspecs/winrt-x64-msvc2013/qmake.conf +++ b/mkspecs/winrt-x64-msvc2013/qmake.conf @@ -5,7 +5,6 @@ # include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _MSC_VER=1800 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_APP X64 __X64__ __x64__ QMAKE_CFLAGS += -FS diff --git a/mkspecs/winrt-x64-msvc2015/qmake.conf b/mkspecs/winrt-x64-msvc2015/qmake.conf index ca2dc88bf0..3bf5aa4bc8 100644 --- a/mkspecs/winrt-x64-msvc2015/qmake.conf +++ b/mkspecs/winrt-x64-msvc2015/qmake.conf @@ -6,7 +6,7 @@ MSC_VER = 1900 include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _MSC_VER=1900 _WIN32 +QMAKE_COMPILER_DEFINES += _WIN32 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X64 __X64__ __x64__ QMAKE_CFLAGS += -FS diff --git a/mkspecs/winrt-x86-msvc2013/qmake.conf b/mkspecs/winrt-x86-msvc2013/qmake.conf index 3359102e7e..729a0ba068 100644 --- a/mkspecs/winrt-x86-msvc2013/qmake.conf +++ b/mkspecs/winrt-x86-msvc2013/qmake.conf @@ -5,7 +5,7 @@ # include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _MSC_VER=1800 _WIN32 +QMAKE_COMPILER_DEFINES += _WIN32 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP X86 __X86__ __x86__ QMAKE_CFLAGS += -FS diff --git a/mkspecs/winrt-x86-msvc2015/qmake.conf b/mkspecs/winrt-x86-msvc2015/qmake.conf index 3b2681e93d..00d9126790 100644 --- a/mkspecs/winrt-x86-msvc2015/qmake.conf +++ b/mkspecs/winrt-x86-msvc2015/qmake.conf @@ -6,7 +6,7 @@ MSC_VER = 1900 include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _MSC_VER=1900 _WIN32 +QMAKE_COMPILER_DEFINES += _WIN32 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X86 __X86__ __x86__ QMAKE_CFLAGS += -FS From 5196d5602c70b8d4c08e49921e9459425ada8a42 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 16 Nov 2016 14:10:29 +0100 Subject: [PATCH 032/304] determine msvc compat version in clang spec dynamically instead of hardcoding the compat version in the spec, run cl.exe (which needs to be around anyway) to figure out what version to emulate. Change-Id: I6eae97fe9a78f8e340ecdabcdc0d48738497c6d2 Started-by: Thiago Macieira Reviewed-by: Lars Knoll --- mkspecs/features/toolchain.prf | 21 ++++++++++++++++++++- mkspecs/win32-clang-msvc2015/qmake.conf | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 2fccd64fc5..d71f40b831 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -80,7 +80,23 @@ else: \ isEmpty($${target_prefix}.COMPILER_MACROS) { msvc { - vars = $$qtVariablesFromMSVC($$QMAKE_CXX $$QMAKE_CXXFLAGS) + clang_cl { + # We need to obtain the cl.exe version first + vars = $$qtVariablesFromMSVC(cl) + for (v, vars) { + isEmpty(v)|contains(v, $${LITERAL_HASH}.*): next() + eval($$v) + } + isEmpty(QMAKE_MSC_FULL_VER): error("Could not determine the Visual Studio version") + + QMAKE_CFLAGS_MSVC_COMPAT = $$replace(QMAKE_MSC_FULL_VER, "(..)(..)(.*)", \ + "-fms-compatibility-version=\\1.\\2.\\3") + cache($${target_prefix}.QMAKE_CFLAGS_MSVC_COMPAT, set stash, QMAKE_CFLAGS_MSVC_COMPAT) + $${target_prefix}.COMPILER_MACROS += QMAKE_CFLAGS_MSVC_COMPAT + vars = $$qtVariablesFromMSVC($$QMAKE_CXX, $$QMAKE_CFLAGS_MSVC_COMPAT) + } else { + vars = $$qtVariablesFromMSVC($$QMAKE_CXX) + } } else: gcc { vars = $$qtVariablesFromGCC($$QMAKE_CXX) } @@ -134,3 +150,6 @@ unset(target_prefix) __GNUC__=$$QT_GCC_MAJOR_VERSION \ __GNUC_MINOR__=$$QT_GCC_MINOR_VERSION \ __GNUC_PATCHLEVEL__=$$QT_GCC_PATCH_VERSION + +QMAKE_CFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT +QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT diff --git a/mkspecs/win32-clang-msvc2015/qmake.conf b/mkspecs/win32-clang-msvc2015/qmake.conf index 73cfdcbab9..3d04087fdf 100644 --- a/mkspecs/win32-clang-msvc2015/qmake.conf +++ b/mkspecs/win32-clang-msvc2015/qmake.conf @@ -15,7 +15,7 @@ QMAKE_COMPILER += clang_cl llvm QMAKE_CC = clang-cl QMAKE_CXX = $$QMAKE_CC -QMAKE_CFLAGS += -fms-compatibility-version=19.00.23506 -Wno-microsoft-enum-value +QMAKE_CFLAGS += -Wno-microsoft-enum-value QMAKE_CXXFLAGS = $$QMAKE_CFLAGS # Precompiled headers are not supported yet by clang From 4d9fbb33458c82aaf37d9712495a0653aae70533 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Nov 2016 14:18:42 +0100 Subject: [PATCH 033/304] Remove hard-coded MS compiler versions from the mkspecs We're asking the compiler anyway, so we can fully use this information just as well. Note that this actually happens after the spec itself has been processed, so it was necessary to delay the version-specific flag handling as well. Change-Id: Ib57b52598e2f452985e9fffd14587b581d946022 Reviewed-by: Lars Knoll --- mkspecs/common/msvc-desktop.conf | 7 +---- .../{msvc-base.conf => msvc-version.conf} | 26 ++++++++++++++----- mkspecs/common/winrt_winphone/qmake.conf | 4 --- mkspecs/features/win32/default_pre.prf | 2 +- mkspecs/win32-clang-msvc2015/qmake.conf | 2 -- mkspecs/win32-msvc2005/qmake.conf | 2 -- mkspecs/win32-msvc2008/qmake.conf | 2 -- mkspecs/win32-msvc2010/qmake.conf | 2 -- mkspecs/win32-msvc2012/qmake.conf | 2 -- mkspecs/win32-msvc2013/qmake.conf | 2 -- mkspecs/win32-msvc2015/qmake.conf | 2 -- mkspecs/win32-msvc2017/qmake.conf | 2 -- mkspecs/winphone-arm-msvc2013/qmake.conf | 1 - mkspecs/winphone-x86-msvc2013/qmake.conf | 1 - mkspecs/winrt-arm-msvc2013/qmake.conf | 1 - mkspecs/winrt-arm-msvc2015/qmake.conf | 2 -- mkspecs/winrt-x64-msvc2013/qmake.conf | 1 - mkspecs/winrt-x64-msvc2015/qmake.conf | 2 -- mkspecs/winrt-x86-msvc2013/qmake.conf | 1 - mkspecs/winrt-x86-msvc2015/qmake.conf | 2 -- 20 files changed, 22 insertions(+), 44 deletions(-) rename mkspecs/common/{msvc-base.conf => msvc-version.conf} (70%) diff --git a/mkspecs/common/msvc-desktop.conf b/mkspecs/common/msvc-desktop.conf index ebe804db64..604321551b 100644 --- a/mkspecs/common/msvc-desktop.conf +++ b/mkspecs/common/msvc-desktop.conf @@ -3,10 +3,9 @@ # This mkspec is used for all win32-msvcXXXX specs # -isEmpty(MSC_VER)|isEmpty(MSVC_VER): error("Source mkspec must set both MSC_VER and MSVC_VER.") - # # Baseline: Visual Studio 2005 (8.0), VC++ 14.0 +# Version-specific settings go in msvc-version.conf (loaded by default_pre) # include(angle.conf) @@ -105,7 +104,3 @@ QMAKE_RC = rc VCPROJ_EXTENSION = .vcproj VCSOLUTION_EXTENSION = .sln VCPROJ_KEYWORD = Qt4VSv1.0 - -include(msvc-base.conf) - -unset(MSC_VER) diff --git a/mkspecs/common/msvc-base.conf b/mkspecs/common/msvc-version.conf similarity index 70% rename from mkspecs/common/msvc-base.conf rename to mkspecs/common/msvc-version.conf index d54b11507e..8158ee37ab 100644 --- a/mkspecs/common/msvc-base.conf +++ b/mkspecs/common/msvc-version.conf @@ -8,14 +8,20 @@ # Version-specific changes # -greaterThan(MSC_VER, 1499) { +isEmpty(QMAKE_MSC_VER): error("msvc-version.conf loaded but QMAKE_MSC_VER isn't set") + +MSVC_VER = 8.0 + +greaterThan(QMAKE_MSC_VER, 1499) { # Visual Studio 2008 (9.0) / Visual C++ 15.0 and up + MSVC_VER = 9.0 QMAKE_CFLAGS_MP = -MP QMAKE_CXXFLAGS_MP = $$QMAKE_CFLAGS_MP } -greaterThan(MSC_VER, 1599) { +greaterThan(QMAKE_MSC_VER, 1599) { # Visual Studio 2010 (10.0) / Visual C++ 16.0 and up + MSVC_VER = 10.0 MAKEFILE_GENERATOR = MSBUILD QMAKE_CFLAGS_AVX = -arch:AVX @@ -24,19 +30,21 @@ greaterThan(MSC_VER, 1599) { VCPROJ_EXTENSION = .vcxproj } -greaterThan(MSC_VER, 1699) { +greaterThan(QMAKE_MSC_VER, 1699) { # Visual Studio 2012 (11.0) / Visual C++ 17.0 and up + MSVC_VER = 11.0 QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -D_HAS_EXCEPTIONS=0 QT_CONFIG += c++11 CONFIG += c++11 } -greaterThan(MSC_VER, 1799) { +greaterThan(QMAKE_MSC_VER, 1799) { # Visual Studio 2013 (12.0) / Visual C++ 18.0 and up + MSVC_VER = 12.0 QMAKE_CFLAGS += -FS QMAKE_CXXFLAGS += -FS - equals(MSC_VER, 1800) { + equals(QMAKE_MSC_VER, 1800) { QMAKE_CFLAGS_RELEASE += -Zc:strictStrings QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -Zc:strictStrings QMAKE_CXXFLAGS_RELEASE += -Zc:strictStrings @@ -44,11 +52,17 @@ greaterThan(MSC_VER, 1799) { } } -greaterThan(MSC_VER, 1899) { +greaterThan(QMAKE_MSC_VER, 1899) { # Visual Studio 2015 (14.0) / Visual C++ 19.0 and up + MSVC_VER = 14.0 QMAKE_CFLAGS += -Zc:strictStrings QMAKE_CFLAGS_WARN_ON += -w44456 -w44457 -w44458 QMAKE_CFLAGS_AVX2 = -arch:AVX2 QMAKE_CXXFLAGS += -Zc:strictStrings -Zc:throwingNew QMAKE_CXXFLAGS_WARN_ON += -w44456 -w44457 -w44458 -wd4577 -wd4467 } + +greaterThan(QMAKE_MSC_VER, 1909) { + # Visual Studio 2017 (15.0) / Visual C++ 19.10 and up + MSVC_VER = 15.0 +} diff --git a/mkspecs/common/winrt_winphone/qmake.conf b/mkspecs/common/winrt_winphone/qmake.conf index 05c9bd39a5..27269176d0 100644 --- a/mkspecs/common/winrt_winphone/qmake.conf +++ b/mkspecs/common/winrt_winphone/qmake.conf @@ -97,8 +97,4 @@ WINRT_ASSETS_PATH = $$PWD/assets WINRT_MANIFEST.capabilities = defaults WINRT_MANIFEST.capabilities_device = defaults -include(../msvc-base.conf) - -unset(MSC_VER) - load(qt_config) diff --git a/mkspecs/features/win32/default_pre.prf b/mkspecs/features/win32/default_pre.prf index 385184f632..11160f5b5c 100644 --- a/mkspecs/features/win32/default_pre.prf +++ b/mkspecs/features/win32/default_pre.prf @@ -1,3 +1,3 @@ CONFIG = rtti_off incremental_off windows $$CONFIG load(default_pre) - +msvc:!intel_icl:!clang_cl: include(../../common/msvc-version.conf) diff --git a/mkspecs/win32-clang-msvc2015/qmake.conf b/mkspecs/win32-clang-msvc2015/qmake.conf index 3d04087fdf..aa78ebf83b 100644 --- a/mkspecs/win32-clang-msvc2015/qmake.conf +++ b/mkspecs/win32-clang-msvc2015/qmake.conf @@ -6,8 +6,6 @@ # Notice: this uses the clang-cl wrapper # -MSC_VER = 1900 -MSVC_VER = 14.0 include(../common/msvc-desktop.conf) QMAKE_COMPILER += clang_cl llvm diff --git a/mkspecs/win32-msvc2005/qmake.conf b/mkspecs/win32-msvc2005/qmake.conf index 458f37cc04..3fbf797b5b 100644 --- a/mkspecs/win32-msvc2005/qmake.conf +++ b/mkspecs/win32-msvc2005/qmake.conf @@ -4,7 +4,5 @@ # Written for Microsoft Visual C++ 2005 # -MSC_VER = 1400 -MSVC_VER = 8.0 include(../common/msvc-desktop.conf) load(qt_config) diff --git a/mkspecs/win32-msvc2008/qmake.conf b/mkspecs/win32-msvc2008/qmake.conf index d1382ff2d4..0d9eac7008 100644 --- a/mkspecs/win32-msvc2008/qmake.conf +++ b/mkspecs/win32-msvc2008/qmake.conf @@ -4,7 +4,5 @@ # Written for Microsoft Visual C++ 2008 # -MSC_VER = 1500 -MSVC_VER = 9.0 include(../common/msvc-desktop.conf) load(qt_config) diff --git a/mkspecs/win32-msvc2010/qmake.conf b/mkspecs/win32-msvc2010/qmake.conf index 3ad9d478ee..3b8a50f17a 100644 --- a/mkspecs/win32-msvc2010/qmake.conf +++ b/mkspecs/win32-msvc2010/qmake.conf @@ -4,7 +4,5 @@ # Written for Microsoft Visual C++ 2010 # -MSC_VER = 1600 -MSVC_VER = 10.0 include(../common/msvc-desktop.conf) load(qt_config) diff --git a/mkspecs/win32-msvc2012/qmake.conf b/mkspecs/win32-msvc2012/qmake.conf index 3d9c5864af..25aaf1f5d1 100644 --- a/mkspecs/win32-msvc2012/qmake.conf +++ b/mkspecs/win32-msvc2012/qmake.conf @@ -4,7 +4,5 @@ # Written for Microsoft Visual C++ 2012 # -MSC_VER = 1700 -MSVC_VER = 11.0 include(../common/msvc-desktop.conf) load(qt_config) diff --git a/mkspecs/win32-msvc2013/qmake.conf b/mkspecs/win32-msvc2013/qmake.conf index 34108b2c32..87f72317ba 100644 --- a/mkspecs/win32-msvc2013/qmake.conf +++ b/mkspecs/win32-msvc2013/qmake.conf @@ -4,7 +4,5 @@ # Written for Microsoft Visual C++ 2013 # -MSC_VER = 1800 -MSVC_VER = 12.0 include(../common/msvc-desktop.conf) load(qt_config) diff --git a/mkspecs/win32-msvc2015/qmake.conf b/mkspecs/win32-msvc2015/qmake.conf index ea654d4296..e1f5376894 100644 --- a/mkspecs/win32-msvc2015/qmake.conf +++ b/mkspecs/win32-msvc2015/qmake.conf @@ -4,7 +4,5 @@ # Written for Microsoft Visual C++ 2015 # -MSC_VER = 1900 -MSVC_VER = 14.0 include(../common/msvc-desktop.conf) load(qt_config) diff --git a/mkspecs/win32-msvc2017/qmake.conf b/mkspecs/win32-msvc2017/qmake.conf index b8351eb3fe..c945c8c00d 100644 --- a/mkspecs/win32-msvc2017/qmake.conf +++ b/mkspecs/win32-msvc2017/qmake.conf @@ -4,7 +4,5 @@ # Written for Microsoft Visual C++ 2017 # -MSC_VER = 1910 -MSVC_VER = 15.0 include(../common/msvc-desktop.conf) load(qt_config) diff --git a/mkspecs/winphone-arm-msvc2013/qmake.conf b/mkspecs/winphone-arm-msvc2013/qmake.conf index 64ff295f14..7656adbf00 100644 --- a/mkspecs/winphone-arm-msvc2013/qmake.conf +++ b/mkspecs/winphone-arm-msvc2013/qmake.conf @@ -16,7 +16,6 @@ QMAKE_LFLAGS += /MACHINE:ARM /NODEFAULTLIB:kernel32.lib QMAKE_LIBS += WindowsPhoneCore.lib PhoneAppModelHost.lib VCPROJ_ARCH = ARM -MSVC_VER = 12.0 WINSDK_VER = 8.1 WINTARGET_VER = WP81 WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/8.1_wp/AppxManifest.xml.in diff --git a/mkspecs/winphone-x86-msvc2013/qmake.conf b/mkspecs/winphone-x86-msvc2013/qmake.conf index bc074f03dd..aa9e5b791b 100644 --- a/mkspecs/winphone-x86-msvc2013/qmake.conf +++ b/mkspecs/winphone-x86-msvc2013/qmake.conf @@ -16,7 +16,6 @@ QMAKE_LFLAGS += /MACHINE:X86 /NODEFAULTLIB:kernel32.lib QMAKE_LIBS += WindowsPhoneCore.lib PhoneAppModelHost.lib VCPROJ_ARCH = Win32 -MSVC_VER = 12.0 WINSDK_VER = 8.1 WINTARGET_VER = WP81 WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/8.1_wp/AppxManifest.xml.in diff --git a/mkspecs/winrt-arm-msvc2013/qmake.conf b/mkspecs/winrt-arm-msvc2013/qmake.conf index 547884ce7e..14bd16d555 100644 --- a/mkspecs/winrt-arm-msvc2013/qmake.conf +++ b/mkspecs/winrt-arm-msvc2013/qmake.conf @@ -14,7 +14,6 @@ QMAKE_LFLAGS += /MACHINE:ARM QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = ARM -MSVC_VER = 12.0 WINSDK_VER = 8.1 WINTARGET_VER = winv6.3 WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/8.1/AppxManifest.xml.in diff --git a/mkspecs/winrt-arm-msvc2015/qmake.conf b/mkspecs/winrt-arm-msvc2015/qmake.conf index ef145ae44b..8bca6f4af8 100644 --- a/mkspecs/winrt-arm-msvc2015/qmake.conf +++ b/mkspecs/winrt-arm-msvc2015/qmake.conf @@ -4,7 +4,6 @@ # Written for Microsoft Visual C++ 2015 # -MSC_VER = 1900 include(../common/winrt_winphone/qmake.conf) DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 ARM __ARM__ __arm__ @@ -15,7 +14,6 @@ QMAKE_LFLAGS += /MACHINE:ARM /NODEFAULTLIB:kernel32.lib QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib VCPROJ_ARCH = ARM -MSVC_VER = 14.0 WINSDK_VER = 10.0 WINTARGET_VER = winv10.0 WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in diff --git a/mkspecs/winrt-x64-msvc2013/qmake.conf b/mkspecs/winrt-x64-msvc2013/qmake.conf index c90db8b314..238f9f0d93 100644 --- a/mkspecs/winrt-x64-msvc2013/qmake.conf +++ b/mkspecs/winrt-x64-msvc2013/qmake.conf @@ -14,7 +14,6 @@ QMAKE_LFLAGS += /MACHINE:X64 QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = x64 -MSVC_VER = 12.0 WINSDK_VER = 8.1 WINTARGET_VER = winv6.3 WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/8.1/AppxManifest.xml.in diff --git a/mkspecs/winrt-x64-msvc2015/qmake.conf b/mkspecs/winrt-x64-msvc2015/qmake.conf index 3bf5aa4bc8..d7e2fcf3c2 100644 --- a/mkspecs/winrt-x64-msvc2015/qmake.conf +++ b/mkspecs/winrt-x64-msvc2015/qmake.conf @@ -4,7 +4,6 @@ # Written for Microsoft Visual C++ 2015 # -MSC_VER = 1900 include(../common/winrt_winphone/qmake.conf) QMAKE_COMPILER_DEFINES += _WIN32 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X64 __X64__ __x64__ @@ -16,7 +15,6 @@ QMAKE_LFLAGS += /MACHINE:X64 /NODEFAULTLIB:kernel32.lib QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib VCPROJ_ARCH = x64 -MSVC_VER = 14.0 WINSDK_VER = 10.0 WINTARGET_VER = winv10.0 WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in diff --git a/mkspecs/winrt-x86-msvc2013/qmake.conf b/mkspecs/winrt-x86-msvc2013/qmake.conf index 729a0ba068..cc125d3f0c 100644 --- a/mkspecs/winrt-x86-msvc2013/qmake.conf +++ b/mkspecs/winrt-x86-msvc2013/qmake.conf @@ -15,7 +15,6 @@ QMAKE_LFLAGS += /SAFESEH /MACHINE:X86 QMAKE_LIBS += windowscodecs.lib kernel32.lib ole32.lib VCPROJ_ARCH = Win32 -MSVC_VER = 12.0 WINSDK_VER = 8.1 WINTARGET_VER = winv6.3 WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/8.1/AppxManifest.xml.in diff --git a/mkspecs/winrt-x86-msvc2015/qmake.conf b/mkspecs/winrt-x86-msvc2015/qmake.conf index 00d9126790..0983174ae2 100644 --- a/mkspecs/winrt-x86-msvc2015/qmake.conf +++ b/mkspecs/winrt-x86-msvc2015/qmake.conf @@ -4,7 +4,6 @@ # Written for Microsoft Visual C++ 2015 # -MSC_VER = 1900 include(../common/winrt_winphone/qmake.conf) QMAKE_COMPILER_DEFINES += _WIN32 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X86 __X86__ __x86__ @@ -15,7 +14,6 @@ QMAKE_LFLAGS += /SAFESEH /MACHINE:X86 /NODEFAULTLIB:kernel32.lib QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib VCPROJ_ARCH = Win32 -MSVC_VER = 14.0 WINSDK_VER = 10.0 WINTARGET_VER = winv10.0 WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in From 04403d5b12debadf95b565bf84e0527ae787c87d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Jun 2016 23:21:03 -0700 Subject: [PATCH 034/304] Merge all "win32-msvc*" mkspecs into one Since we can tell the MSVC version from the compiler now, each of the qmake.conf files is now the same, so let's just have "win32-msvc" and be future-proof. Likewise for win32-clang-msvc. qplatformdefs.h was already common. Since we can't obtain the MSVC version from the unified mkspec name any more, I dropped the warning level during the qmake bootstrap to reduce the number of warnings that need to be disabled from compiler version to version. There is no point in keeping the old mkspecs, but configure will re-map the -platform argument to the unified spec as necessary, to keep existing configure command lines working. [ChangeLog][Visual Studio] Qt now has a common mkspec for all Visual Studio versions, called "win32-msvc". The old names which contained the version number are now gone (but qmake scopes based on the old names continue to work). The version of the compiler can be obtained from the MSC_VER and MSVC_VER variables (for example, for Visual Studio 2015, those contain the values 1900 and 14.0, respectively). Those variables are also available with the Intel compiler (win32-icc) and with Clang (win32-clang-msvc). Done-with: Oswald Buddenhagen Change-Id: Ib57b52598e2f452985e9fffd14587c0a77a5c09c Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- mkspecs/common/msvc-desktop.conf | 2 +- mkspecs/common/msvc-version.conf | 18 +++- .../qmake.conf | 4 +- .../qplatformdefs.h | 2 +- mkspecs/win32-clang-msvc2015/qplatformdefs.h | 34 -------- mkspecs/win32-icc/qplatformdefs.h | 2 +- mkspecs/win32-msvc/qmake.conf | 8 ++ .../qplatformdefs.h | 0 mkspecs/win32-msvc2005/qmake.conf | 8 -- mkspecs/win32-msvc2008/qmake.conf | 8 -- mkspecs/win32-msvc2010/qmake.conf | 8 -- mkspecs/win32-msvc2010/qplatformdefs.h | 40 --------- mkspecs/win32-msvc2012/qmake.conf | 8 -- mkspecs/win32-msvc2012/qplatformdefs.h | 40 --------- mkspecs/win32-msvc2013/qmake.conf | 8 -- mkspecs/win32-msvc2013/qplatformdefs.h | 40 --------- mkspecs/win32-msvc2015/qmake.conf | 8 -- mkspecs/win32-msvc2015/qplatformdefs.h | 40 --------- mkspecs/win32-msvc2017/qmake.conf | 8 -- mkspecs/win32-msvc2017/qplatformdefs.h | 34 -------- qmake/Makefile.win32 | 15 ++-- tools/configure/Makefile.mingw | 10 +-- tools/configure/Makefile.win32 | 9 +- tools/configure/configure.pro | 7 +- tools/configure/configureapp.cpp | 13 ++- tools/configure/environment.cpp | 85 +++---------------- tools/configure/environment.h | 8 +- 27 files changed, 62 insertions(+), 405 deletions(-) rename mkspecs/{win32-clang-msvc2015 => win32-clang-msvc}/qmake.conf (77%) rename mkspecs/{win32-msvc2008 => win32-clang-msvc}/qplatformdefs.h (97%) delete mode 100644 mkspecs/win32-clang-msvc2015/qplatformdefs.h create mode 100644 mkspecs/win32-msvc/qmake.conf rename mkspecs/{win32-msvc2005 => win32-msvc}/qplatformdefs.h (100%) delete mode 100644 mkspecs/win32-msvc2005/qmake.conf delete mode 100644 mkspecs/win32-msvc2008/qmake.conf delete mode 100644 mkspecs/win32-msvc2010/qmake.conf delete mode 100644 mkspecs/win32-msvc2010/qplatformdefs.h delete mode 100644 mkspecs/win32-msvc2012/qmake.conf delete mode 100644 mkspecs/win32-msvc2012/qplatformdefs.h delete mode 100644 mkspecs/win32-msvc2013/qmake.conf delete mode 100644 mkspecs/win32-msvc2013/qplatformdefs.h delete mode 100644 mkspecs/win32-msvc2015/qmake.conf delete mode 100644 mkspecs/win32-msvc2015/qplatformdefs.h delete mode 100644 mkspecs/win32-msvc2017/qmake.conf delete mode 100644 mkspecs/win32-msvc2017/qplatformdefs.h diff --git a/mkspecs/common/msvc-desktop.conf b/mkspecs/common/msvc-desktop.conf index 604321551b..52d9408c1c 100644 --- a/mkspecs/common/msvc-desktop.conf +++ b/mkspecs/common/msvc-desktop.conf @@ -1,6 +1,6 @@ # # qmake configuration for Microsoft Visual Studio C/C++ Compiler -# This mkspec is used for all win32-msvcXXXX specs +# This mkspec is used by the win32-msvc and win32-clang-msvc specs # # diff --git a/mkspecs/common/msvc-version.conf b/mkspecs/common/msvc-version.conf index 8158ee37ab..147009cd9f 100644 --- a/mkspecs/common/msvc-version.conf +++ b/mkspecs/common/msvc-version.conf @@ -1,7 +1,7 @@ # # qmake configuration for Microsoft Visual Studio C/C++ Compiler -# This mkspec is used for all win32-msvcXXXX, winrt-XXX-msvcXXX -# and winphone-XXX-msvcXXX specs +# This file is used by win32-msvc, win32-clang-msvc, and all +# winphone-XXX-msvcXXXX specs # # @@ -11,10 +11,12 @@ isEmpty(QMAKE_MSC_VER): error("msvc-version.conf loaded but QMAKE_MSC_VER isn't set") MSVC_VER = 8.0 +COMPAT_MKSPEC = win32-msvc2005 greaterThan(QMAKE_MSC_VER, 1499) { # Visual Studio 2008 (9.0) / Visual C++ 15.0 and up MSVC_VER = 9.0 + COMPAT_MKSPEC = win32-msvc2008 QMAKE_CFLAGS_MP = -MP QMAKE_CXXFLAGS_MP = $$QMAKE_CFLAGS_MP } @@ -22,6 +24,7 @@ greaterThan(QMAKE_MSC_VER, 1499) { greaterThan(QMAKE_MSC_VER, 1599) { # Visual Studio 2010 (10.0) / Visual C++ 16.0 and up MSVC_VER = 10.0 + COMPAT_MKSPEC = win32-msvc2010 MAKEFILE_GENERATOR = MSBUILD QMAKE_CFLAGS_AVX = -arch:AVX @@ -33,6 +36,7 @@ greaterThan(QMAKE_MSC_VER, 1599) { greaterThan(QMAKE_MSC_VER, 1699) { # Visual Studio 2012 (11.0) / Visual C++ 17.0 and up MSVC_VER = 11.0 + COMPAT_MKSPEC = win32-msvc2012 QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -D_HAS_EXCEPTIONS=0 QT_CONFIG += c++11 CONFIG += c++11 @@ -41,6 +45,7 @@ greaterThan(QMAKE_MSC_VER, 1699) { greaterThan(QMAKE_MSC_VER, 1799) { # Visual Studio 2013 (12.0) / Visual C++ 18.0 and up MSVC_VER = 12.0 + COMPAT_MKSPEC = win32-msvc2013 QMAKE_CFLAGS += -FS QMAKE_CXXFLAGS += -FS @@ -55,6 +60,7 @@ greaterThan(QMAKE_MSC_VER, 1799) { greaterThan(QMAKE_MSC_VER, 1899) { # Visual Studio 2015 (14.0) / Visual C++ 19.0 and up MSVC_VER = 14.0 + COMPAT_MKSPEC = win32-msvc2015 QMAKE_CFLAGS += -Zc:strictStrings QMAKE_CFLAGS_WARN_ON += -w44456 -w44457 -w44458 QMAKE_CFLAGS_AVX2 = -arch:AVX2 @@ -65,4 +71,12 @@ greaterThan(QMAKE_MSC_VER, 1899) { greaterThan(QMAKE_MSC_VER, 1909) { # Visual Studio 2017 (15.0) / Visual C++ 19.10 and up MSVC_VER = 15.0 + COMPAT_MKSPEC = win32-msvc2017 } + +greaterThan(QMAKE_MSC_VER, 1910) { + # No compat spec past MSVC 2017 + COMPAT_MKSPEC = +} + +!isEmpty(COMPAT_MKSPEC):!$$COMPAT_MKSPEC: CONFIG += $$COMPAT_MKSPEC diff --git a/mkspecs/win32-clang-msvc2015/qmake.conf b/mkspecs/win32-clang-msvc/qmake.conf similarity index 77% rename from mkspecs/win32-clang-msvc2015/qmake.conf rename to mkspecs/win32-clang-msvc/qmake.conf index aa78ebf83b..0041788ef9 100644 --- a/mkspecs/win32-clang-msvc2015/qmake.conf +++ b/mkspecs/win32-clang-msvc/qmake.conf @@ -1,8 +1,6 @@ # -# qmake configuration for win32-clang-msvc2015 - +# qmake configuration for win32-clang-msvc # -# Written for Clang 3.8 with Microsoft Visual C++ 2015 Update 1 # Notice: this uses the clang-cl wrapper # diff --git a/mkspecs/win32-msvc2008/qplatformdefs.h b/mkspecs/win32-clang-msvc/qplatformdefs.h similarity index 97% rename from mkspecs/win32-msvc2008/qplatformdefs.h rename to mkspecs/win32-clang-msvc/qplatformdefs.h index 9c59826555..8a3afa7630 100644 --- a/mkspecs/win32-msvc2008/qplatformdefs.h +++ b/mkspecs/win32-clang-msvc/qplatformdefs.h @@ -37,4 +37,4 @@ ** ****************************************************************************/ -#include "../win32-msvc2005/qplatformdefs.h" +#include "../win32-msvc/qplatformdefs.h" diff --git a/mkspecs/win32-clang-msvc2015/qplatformdefs.h b/mkspecs/win32-clang-msvc2015/qplatformdefs.h deleted file mode 100644 index 7100e3aa41..0000000000 --- a/mkspecs/win32-clang-msvc2015/qplatformdefs.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the qmake spec 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 "../win32-msvc2005/qplatformdefs.h" diff --git a/mkspecs/win32-icc/qplatformdefs.h b/mkspecs/win32-icc/qplatformdefs.h index 9c59826555..8a3afa7630 100644 --- a/mkspecs/win32-icc/qplatformdefs.h +++ b/mkspecs/win32-icc/qplatformdefs.h @@ -37,4 +37,4 @@ ** ****************************************************************************/ -#include "../win32-msvc2005/qplatformdefs.h" +#include "../win32-msvc/qplatformdefs.h" diff --git a/mkspecs/win32-msvc/qmake.conf b/mkspecs/win32-msvc/qmake.conf new file mode 100644 index 0000000000..1d8b8f0e97 --- /dev/null +++ b/mkspecs/win32-msvc/qmake.conf @@ -0,0 +1,8 @@ +# +# qmake configuration for win32-msvc +# +# Written for Microsoft Visual C++ (all desktop versions) +# + +include(../common/msvc-desktop.conf) +load(qt_config) diff --git a/mkspecs/win32-msvc2005/qplatformdefs.h b/mkspecs/win32-msvc/qplatformdefs.h similarity index 100% rename from mkspecs/win32-msvc2005/qplatformdefs.h rename to mkspecs/win32-msvc/qplatformdefs.h diff --git a/mkspecs/win32-msvc2005/qmake.conf b/mkspecs/win32-msvc2005/qmake.conf deleted file mode 100644 index 3fbf797b5b..0000000000 --- a/mkspecs/win32-msvc2005/qmake.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# qmake configuration for win32-msvc2005 -# -# Written for Microsoft Visual C++ 2005 -# - -include(../common/msvc-desktop.conf) -load(qt_config) diff --git a/mkspecs/win32-msvc2008/qmake.conf b/mkspecs/win32-msvc2008/qmake.conf deleted file mode 100644 index 0d9eac7008..0000000000 --- a/mkspecs/win32-msvc2008/qmake.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# qmake configuration for win32-msvc2008 -# -# Written for Microsoft Visual C++ 2008 -# - -include(../common/msvc-desktop.conf) -load(qt_config) diff --git a/mkspecs/win32-msvc2010/qmake.conf b/mkspecs/win32-msvc2010/qmake.conf deleted file mode 100644 index 3b8a50f17a..0000000000 --- a/mkspecs/win32-msvc2010/qmake.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# qmake configuration for win32-msvc2010 -# -# Written for Microsoft Visual C++ 2010 -# - -include(../common/msvc-desktop.conf) -load(qt_config) diff --git a/mkspecs/win32-msvc2010/qplatformdefs.h b/mkspecs/win32-msvc2010/qplatformdefs.h deleted file mode 100644 index 9c59826555..0000000000 --- a/mkspecs/win32-msvc2010/qplatformdefs.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the qmake spec 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$ -** -****************************************************************************/ - -#include "../win32-msvc2005/qplatformdefs.h" diff --git a/mkspecs/win32-msvc2012/qmake.conf b/mkspecs/win32-msvc2012/qmake.conf deleted file mode 100644 index 25aaf1f5d1..0000000000 --- a/mkspecs/win32-msvc2012/qmake.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# qmake configuration for win32-msvc2012 -# -# Written for Microsoft Visual C++ 2012 -# - -include(../common/msvc-desktop.conf) -load(qt_config) diff --git a/mkspecs/win32-msvc2012/qplatformdefs.h b/mkspecs/win32-msvc2012/qplatformdefs.h deleted file mode 100644 index 9c59826555..0000000000 --- a/mkspecs/win32-msvc2012/qplatformdefs.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the qmake spec 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$ -** -****************************************************************************/ - -#include "../win32-msvc2005/qplatformdefs.h" diff --git a/mkspecs/win32-msvc2013/qmake.conf b/mkspecs/win32-msvc2013/qmake.conf deleted file mode 100644 index 87f72317ba..0000000000 --- a/mkspecs/win32-msvc2013/qmake.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# qmake configuration for win32-msvc2013 -# -# Written for Microsoft Visual C++ 2013 -# - -include(../common/msvc-desktop.conf) -load(qt_config) diff --git a/mkspecs/win32-msvc2013/qplatformdefs.h b/mkspecs/win32-msvc2013/qplatformdefs.h deleted file mode 100644 index 9c59826555..0000000000 --- a/mkspecs/win32-msvc2013/qplatformdefs.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the qmake spec 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$ -** -****************************************************************************/ - -#include "../win32-msvc2005/qplatformdefs.h" diff --git a/mkspecs/win32-msvc2015/qmake.conf b/mkspecs/win32-msvc2015/qmake.conf deleted file mode 100644 index e1f5376894..0000000000 --- a/mkspecs/win32-msvc2015/qmake.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# qmake configuration for win32-msvc2015 -# -# Written for Microsoft Visual C++ 2015 -# - -include(../common/msvc-desktop.conf) -load(qt_config) diff --git a/mkspecs/win32-msvc2015/qplatformdefs.h b/mkspecs/win32-msvc2015/qplatformdefs.h deleted file mode 100644 index 9c59826555..0000000000 --- a/mkspecs/win32-msvc2015/qplatformdefs.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the qmake spec 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$ -** -****************************************************************************/ - -#include "../win32-msvc2005/qplatformdefs.h" diff --git a/mkspecs/win32-msvc2017/qmake.conf b/mkspecs/win32-msvc2017/qmake.conf deleted file mode 100644 index c945c8c00d..0000000000 --- a/mkspecs/win32-msvc2017/qmake.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# qmake configuration for win32-msvc2017 -# -# Written for Microsoft Visual C++ 2017 -# - -include(../common/msvc-desktop.conf) -load(qt_config) diff --git a/mkspecs/win32-msvc2017/qplatformdefs.h b/mkspecs/win32-msvc2017/qplatformdefs.h deleted file mode 100644 index 7100e3aa41..0000000000 --- a/mkspecs/win32-msvc2017/qplatformdefs.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the qmake spec 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 "../win32-msvc2005/qplatformdefs.h" diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 862c1e833e..8e41facde2 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -14,29 +14,24 @@ QMKSRC = $(SOURCE_PATH)\qmake CXX = icl LINKER = link CFLAGS_EXTRA = /Zc:forScope /Qstd=c++11 -!elseif "$(QMAKESPEC)" == "win32-clang-msvc2015" +!elseif "$(QMAKESPEC)" == "win32-clang-msvc" CXX = clang-cl LINKER = link CFLAGS_EXTRA = -fms-compatibility-version=19.00.23506 -Wno-microsoft-enum-value !else CXX = cl LINKER = link -! if "$(QMAKESPEC)" == "win32-msvc2013" -CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS $(CFLAGS_CRT) -! elseif "$(QMAKESPEC)" == "win32-msvc2015" || "$(QMAKESPEC)" == "win32-msvc2017" || "$(QMAKESPEC)" == "win32-clang-msvc2015" -CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /Zc:strictStrings /w44456 /w44457 /w44458 /wd4577 $(CFLAGS_CRT) -! else -! error Unsupported compiler for this Makefile -! endif +CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS \ + /wd4577 $(CFLAGS_CRT) !endif # !win32-icc -!if "$(QMAKESPEC)" != "win32-clang-msvc2015" +!if "$(QMAKESPEC)" != "win32-clang-msvc" CFLAGS_PCH = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch PCH_OBJECT = qmake_pch.obj !endif CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \ - -W3 -nologo -O1 \ + -W2 -nologo -O1 \ $(CFLAGS_EXTRA) \ -I$(QMKSRC) -I$(QMKSRC)\library -I$(QMKSRC)\generators -I$(QMKSRC)\generators\unix -I$(QMKSRC)\generators\win32 -I$(QMKSRC)\generators\mac \ -I$(INC_PATH) -I$(INC_PATH)\QtCore -I$(INC_PATH)\QtCore\$(QT_VERSION) -I$(INC_PATH)\QtCore\$(QT_VERSION)\QtCore \ diff --git a/tools/configure/Makefile.mingw b/tools/configure/Makefile.mingw index b61dc38de4..ccc3a64cdf 100644 --- a/tools/configure/Makefile.mingw +++ b/tools/configure/Makefile.mingw @@ -1,11 +1,10 @@ CORESRC = $(QTSRC)src/corelib -TOOLSRC = $(QTSRC)tools -CONFSRC = $(TOOLSRC)/configure +CONFSRC = $(QTSRC)tools/configure RAW_PCH = configure_pch.h PCH = $(RAW_PCH).gch/c++ DEFINES = -DUNICODE -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE -DQT_USE_QSTRINGBUILDER -DQT_VERSION_STR=\"$(QTVERSION)\" -DQT_VERSION_MAJOR=$(QT_VERSION_MAJOR) -DQT_VERSION_MINOR=$(QT_VERSION_MINOR) -DQT_VERSION_PATCH=$(QT_VERSION_PATCH) -INCPATH = -I"../../include" -I"../../include/QtCore" -I"../../include/QtCore/$(QTVERSION)" -I"../../include/QtCore/$(QTVERSION)/QtCore" -I"$(TOOLSRC)/shared" -I"$(QTSRC)mkspecs/win32-g++" +INCPATH = -I"../../include" -I"../../include/QtCore" -I"../../include/QtCore/$(QTVERSION)" -I"../../include/QtCore/$(QTVERSION)/QtCore" -I"$(QTSRC)mkspecs/win32-g++" CXXFLAGS_BARE = -std=c++11 -fno-rtti -fno-exceptions -mthreads -Wall -Wextra $(DEFINES) $(INCPATH) CXXFLAGS = -include $(RAW_PCH) $(CXXFLAGS_BARE) LINK = g++ @@ -70,8 +69,7 @@ OBJECTS = \ qmalloc.o \ qxmlstream.o \ qxmlutils.o \ - quuid.o \ - registry.o + quuid.o $(TARGET): $(OBJECTS) $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) @@ -112,7 +110,7 @@ $(PCH): $(CONFSRC)/configure_pch.h @$(CHK_DIR_EXISTS) $(RAW_PCH).gch $(CHK_DIR_EXISTS_GLUE) $(MKDIR) $(RAW_PCH).gch $(CXX) -x c++-header -c $(CXXFLAGS_BARE) -o $@ $< -VPATH = $(CONFSRC):$(TOOLSRC)/shared/windows:$(CORESRC)/global:$(CORESRC)/kernel:$(CORESRC)/tools:$(CORESRC)/codecs:$(CORESRC)/io:$(CORESRC)/xml:$(CORESRC)/plugin +VPATH = $(CONFSRC):$(CORESRC)/global:$(CORESRC)/kernel:$(CORESRC)/tools:$(CORESRC)/codecs:$(CORESRC)/io:$(CORESRC)/xml:$(CORESRC)/plugin main.o: $(CONFSRC)/configureapp.h configureapp.o: $(CONFSRC)/configureapp.h $(CONFSRC)/environment.h diff --git a/tools/configure/Makefile.win32 b/tools/configure/Makefile.win32 index 8864d6fc8f..f0199343be 100644 --- a/tools/configure/Makefile.win32 +++ b/tools/configure/Makefile.win32 @@ -1,9 +1,8 @@ CORESRC = $(QTSRC)src\corelib -TOOLSRC = $(QTSRC)tools -CONFSRC = $(TOOLSRC)\configure +CONFSRC = $(QTSRC)tools\configure DEFINES = -DUNICODE -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE -DQT_USE_QSTRINGBUILDER -DQT_VERSION_STR=\"$(QTVERSION)\" -DQT_VERSION_MAJOR=$(QT_VERSION_MAJOR) -DQT_VERSION_MINOR=$(QT_VERSION_MINOR) -DQT_VERSION_PATCH=$(QT_VERSION_PATCH) -INCPATH = -I"..\..\include" -I"..\..\include\QtCore" -I"..\..\include\QtCore\$(QTVERSION)" -I"..\..\include\QtCore\$(QTVERSION)\QtCore" -I"$(TOOLSRC)\shared" -I"$(QTSRC)mkspecs\win32-msvc2012" +INCPATH = -I"..\..\include" -I"..\..\include\QtCore" -I"..\..\include\QtCore\$(QTVERSION)" -I"..\..\include\QtCore\$(QTVERSION)\QtCore" -I"$(QTSRC)mkspecs\win32-msvc" CXXFLAGS_BARE = -nologo -Zc:wchar_t -W3 -GR -EHsc -w34100 -w34189 -wd4577 $(CFLAGS_CRT) $(EXTRA_CXXFLAGS) $(DEFINES) $(INCPATH) !IF ("$(CXX)" != "clang-cl") PCH = configure_pch.pch @@ -76,7 +75,6 @@ OBJECTS = \ qxmlstream.obj \ qxmlutils.obj \ quuid.obj \ - registry.obj \ $(PCH_OBJECT) $(TARGET): $(OBJECTS) @@ -98,7 +96,6 @@ $(OBJECTS): $(PCH) main.obj: $(CONFSRC)\main.cpp $(CONFSRC)\configureapp.h $(PCH) configureapp.obj: $(CONFSRC)\configureapp.cpp $(CONFSRC)\configureapp.h $(CONFSRC)\environment.h $(PCH) environment.obj: $(CONFSRC)\environment.cpp $(CONFSRC)\environment.h $(PCH) -registry.obj: $(TOOLSRC)\shared\windows\registry.cpp $(PCH) qarraydata.obj: $(CORESRC)\tools\qarraydata.cpp $(PCH) qbytearray.obj: $(CORESRC)\tools\qbytearray.cpp $(PCH) qbytearraymatcher.obj: $(CORESRC)\tools\qbytearraymatcher.cpp $(PCH) @@ -157,8 +154,6 @@ quuid.obj: $(CORESRC)\plugin\quuid.cpp $(PCH) {$(CONFSRC)}.cpp{}.obj:: $(CXX) -c $(CXXFLAGS) $< -{$(TOOLSRC)\shared\windows}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< {$(CORESRC)\tools}.cpp{}.obj:: $(CXX) -c $(CXXFLAGS) $< {$(CORESRC)\codecs}.cpp{}.obj:: diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index 93e6a197a2..90da2de119 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -76,9 +76,7 @@ HEADERS = configureapp.h environment.h \ $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables_p.h \ $$QT_SOURCE_TREE/src/corelib/kernel/qsystemerror_p.h \ $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.h \ - $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils_p.h \ - $$QT_SOURCE_TREE/tools/shared/windows/registry_p.h - + $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils_p.h SOURCES = main.cpp configureapp.cpp environment.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qbytearray.cpp \ @@ -134,5 +132,4 @@ SOURCES = main.cpp configureapp.cpp environment.cpp \ $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.cpp \ $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils.cpp \ $$QT_SOURCE_TREE/src/corelib/plugin/quuid.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qcryptographichash.cpp \ - $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp + $$QT_SOURCE_TREE/src/corelib/tools/qcryptographichash.cpp diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 2ffec0707f..6a09705cc1 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -163,6 +163,14 @@ void Configure::parseCmdLine() mkspecs << mkspec; } + if (dictionary[ "QMAKESPEC" ] == "win32-msvc2012" + || dictionary[ "QMAKESPEC" ] == "win32-msvc2013" + || dictionary[ "QMAKESPEC" ] == "win32-msvc2015" + || dictionary[ "QMAKESPEC" ] == "win32-msvc2017") { + cout << "\nNotice: re-mapping requested qmake spec to unified 'win32-msvc'.\n\n"; + dictionary[ "QMAKESPEC" ] = "win32-msvc"; + } + if (dictionary["QMAKESPEC"].toLower() == "features" || !mkspecs.contains(dictionary["QMAKESPEC"], Qt::CaseInsensitive)) { dictionary[ "DONE" ] = "error"; @@ -175,10 +183,7 @@ void Configure::parseCmdLine() cout << "See the README file for a list of supported operating systems and compilers." << endl; } else { if (dictionary[ "QMAKESPEC" ].endsWith("-icc") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2012") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2013") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2015") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2017")) { + dictionary[ "QMAKESPEC" ].contains("-msvc")) { if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake"; dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32"; } else if (dictionary[ "QMAKESPEC" ].startsWith(QLatin1String("win32-g++"))) { diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index 260af276fa..312e2f9e56 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -51,25 +51,18 @@ using namespace std; #include #endif -#include // from tools/shared - QT_BEGIN_NAMESPACE struct CompilerInfo{ Compiler compiler; const char *compilerStr; - const char *regKey; const char *executable; } compiler_info[] = { // The compilers here are sorted in a reversed-preferred order - {CC_MINGW, "MinGW (Minimalist GNU for Windows)", 0, "g++.exe"}, - {CC_INTEL, "Intel(R) C++ Compiler for 32-bit applications", 0, "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe - {CC_MSVC2012, "Microsoft (R) Visual Studio 2012 C/C++ Compiler (11.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\11.0", "cl.exe"}, // link.exe, lib.exe - {CC_MSVC2013, "Microsoft (R) Visual Studio 2013 C/C++ Compiler (12.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\12.0", "cl.exe"}, // link.exe, lib.exe - // Microsoft skipped version 13 - {CC_MSVC2015, "Microsoft (R) Visual Studio 2015 C/C++ Compiler (14.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\14.0", "cl.exe"}, // link.exe, lib.exe - {CC_MSVC2017, "Microsoft (R) Visual Studio 2017 C/C++ Compiler (15.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\15.0", "cl.exe"}, // link.exe, lib.exe - {CC_UNKNOWN, "Unknown", 0, 0}, + {CC_MINGW, "MinGW (Minimalist GNU for Windows)", "g++.exe"}, + {CC_INTEL, "Intel(R) C++ Compiler for 32-bit applications", "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe + {CC_MSVC, "Microsoft (R) Visual Studio C/C++ Compiler", "cl.exe"}, // link.exe, lib.exe + {CC_UNKNOWN, "Unknown", 0}, }; @@ -94,17 +87,8 @@ QString Environment::detectQMakeSpec() { QString spec; switch (detectCompiler()) { - case CC_MSVC2017: - spec = "win32-msvc2017"; - break; - case CC_MSVC2015: - spec = "win32-msvc2015"; - break; - case CC_MSVC2013: - spec = "win32-msvc2013"; - break; - case CC_MSVC2012: - spec = "win32-msvc2012"; + case CC_MSVC: + spec = "win32-msvc"; break; case CC_INTEL: spec = "win32-icc"; @@ -128,61 +112,15 @@ QString Environment::detectQMakeSpec() */ Compiler Environment::detectCompiler() { -#ifndef Q_OS_WIN32 - return CC_UNKNOWN; // Always generate CC_UNKNOWN on other platforms -#else if(detectedCompiler != CC_UNKNOWN) return detectedCompiler; int installed = 0; - - // Check for compilers in registry first, to see which version is in PATH - QString paths = qgetenv("PATH"); - QStringList pathlist = paths.toLower().split(";"); - for(int i = 0; compiler_info[i].compiler; ++i) { - QString productPath = qt_readRegistryKey(HKEY_LOCAL_MACHINE, compiler_info[i].regKey, - KEY_WOW64_32KEY).toLower(); - if (productPath.length()) { - QStringList::iterator it; - for(it = pathlist.begin(); it != pathlist.end(); ++it) { - if((*it).contains(productPath)) { - if (detectedCompiler != compiler_info[i].compiler) { - ++installed; - detectedCompiler = compiler_info[i].compiler; - } - /* else { - - We detected the same compiler again, which happens when - configure is build with the 64-bit compiler. Skip the - duplicate so that we don't think it's installed twice. - - } - */ - break; - } - } - } - } - - // Now just go looking for the executables, and accept any executable as the lowest version - if (!installed) { - for(int i = 0; compiler_info[i].compiler; ++i) { - QString executable = QString(compiler_info[i].executable).toLower(); - if (executable.length() && !QStandardPaths::findExecutable(executable).isEmpty()) { - if (detectedCompiler != compiler_info[i].compiler) { - ++installed; - detectedCompiler = compiler_info[i].compiler; - } - /* else { - - We detected the same compiler again, which happens when - configure is build with the 64-bit compiler. Skip the - duplicate so that we don't think it's installed twice. - - } - */ - break; - } + for (int i = 0; compiler_info[i].compiler; ++i) { + if (!QStandardPaths::findExecutable(compiler_info[i].executable).isEmpty()) { + if (detectedCompiler == CC_UNKNOWN) + detectedCompiler = compiler_info[i].compiler; + ++installed; } } @@ -191,7 +129,6 @@ Compiler Environment::detectCompiler() detectedCompiler = CC_UNKNOWN; } return detectedCompiler; -#endif }; /*! diff --git a/tools/configure/environment.h b/tools/configure/environment.h index 8415fa10a6..65ddc60eff 100644 --- a/tools/configure/environment.h +++ b/tools/configure/environment.h @@ -35,13 +35,7 @@ enum Compiler { CC_UNKNOWN = 0, CC_MINGW = 0x02, CC_INTEL = 0x03, - CC_MSVC2005 = 0x80, - CC_MSVC2008 = 0x90, - CC_MSVC2010 = 0xA0, - CC_MSVC2012 = 0xB0, - CC_MSVC2013 = 0xC0, - CC_MSVC2015 = 0xD0, - CC_MSVC2017 = 0xE0 + CC_MSVC = 0x04 }; struct CompilerInfo; From 9b68bc4147e1a8e61cbe0b5e318001fd6b76c7be Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 18 Nov 2016 11:42:35 +0100 Subject: [PATCH 035/304] move "shared" registry reading code into qmake now that configureapp does not use it any more, qmake is the only remaining user. and the license headers already claimed that this code is part of qmake ... Change-Id: I9b8a16f8f2b432d2b1143efbdd1f0042305ccc0c Reviewed-by: Thiago Macieira --- qmake/Makefile.unix | 9 ++++----- qmake/Makefile.unix.win32 | 2 +- qmake/Makefile.win32 | 4 ---- qmake/generators/win32/msvc_nmake.cpp | 2 +- qmake/generators/win32/msvc_vcproj.cpp | 2 +- .../windows => qmake/generators/win32}/registry.cpp | 0 .../windows => qmake/generators/win32}/registry_p.h | 0 7 files changed, 7 insertions(+), 12 deletions(-) rename {tools/shared/windows => qmake/generators/win32}/registry.cpp (100%) rename {tools/shared/windows => qmake/generators/win32}/registry_p.h (100%) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index aa6c876c73..72431f51ea 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -33,6 +33,7 @@ DEPEND_SRC = \ $(QMKGENSRC)/projectgenerator.cpp $(QMKGENSRC)/makefile.cpp \ $(QMKGENSRC)/unix/unixmake.cpp $(QMKGENSRC)/unix/unixmake2.cpp \ $(QMKGENSRC)/mac/pbuilder_pbx.cpp \ + $(QMKGENSRC)/win32/registry.cpp \ $(QMKGENSRC)/win32/winmakefile.cpp \ $(QMKGENSRC)/win32/mingw_make.cpp $(QMKGENSRC)/win32/msvc_nmake.cpp \ $(QMKGENSRC)/mac/xmloutput.cpp \ @@ -84,7 +85,6 @@ DEPEND_SRC = \ $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp \ $(SOURCE_PATH)/src/corelib/global/qlogging.cpp \ $(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp \ - $(SOURCE_PATH)/tools/shared/windows/registry.cpp \ $(SOURCE_PATH)/src/corelib/json/qjson.cpp \ $(SOURCE_PATH)/src/corelib/json/qjsondocument.cpp \ $(SOURCE_PATH)/src/corelib/json/qjsonparser.cpp \ @@ -100,7 +100,6 @@ CPPFLAGS = -g $(EXTRA_CPPFLAGS) \ -I$(INC_PATH)/QtCore/$(QT_VERSION) -I$(INC_PATH)/QtCore/$(QT_VERSION)/QtCore \ -I$(BUILD_PATH)/src/corelib/global \ -I$(QMAKESPEC) \ - -I$(SOURCE_PATH)/tools/shared \ -DQT_VERSION_STR=\"$(QT_VERSION)\" -DQT_VERSION_MAJOR=$(QT_MAJOR_VERSION) -DQT_VERSION_MINOR=$(QT_MINOR_VERSION) -DQT_VERSION_PATCH=$(QT_PATCH_VERSION) \ -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \ -DQT_NO_FOREACH @@ -184,6 +183,9 @@ unixmake.o: $(QMKSRC)/generators/unix/unixmake.cpp unixmake2.o: $(QMKSRC)/generators/unix/unixmake2.cpp $(CXX) -c -o $@ $(CXXFLAGS) $< +registry.o: $(QMKSRC)/generators/win32/registry.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $< + winmakefile.o: $(QMKSRC)/generators/win32/winmakefile.cpp $(CXX) -c -o $@ $(CXXFLAGS) $< @@ -404,9 +406,6 @@ qlogging.o: $(SOURCE_PATH)/src/corelib/global/qlogging.cpp qsystemlibrary.o: $(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp -registry.o: $(SOURCE_PATH)/tools/shared/windows/registry.cpp - $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/tools/shared/windows/registry.cpp - qjson.o: $(SOURCE_PATH)/src/corelib/json/qjson.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/json/qjson.cpp diff --git a/qmake/Makefile.unix.win32 b/qmake/Makefile.unix.win32 index be7245a370..14487e0dbd 100644 --- a/qmake/Makefile.unix.win32 +++ b/qmake/Makefile.unix.win32 @@ -16,4 +16,4 @@ QTSRCS = \ $(SOURCE_PATH)/src/corelib/io/qsettings_win.cpp \ $(SOURCE_PATH)/src/corelib/tools/qlocale_win.cpp \ $(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp \ - $(SOURCE_PATH)/tools/shared/windows/registry.cpp + $(SOURCE_PATH)/qmake/generators/win32/registry.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 8e41facde2..9e1f5136ef 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -37,7 +37,6 @@ CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \ -I$(INC_PATH) -I$(INC_PATH)\QtCore -I$(INC_PATH)\QtCore\$(QT_VERSION) -I$(INC_PATH)\QtCore\$(QT_VERSION)\QtCore \ -I$(BUILD_PATH)\src\corelib\global \ -I$(SOURCE_PATH)\mkspecs\$(QMAKESPEC) \ - -I$(SOURCE_PATH)\tools\shared \ -DQT_VERSION_STR=\"$(QT_VERSION)\" -DQT_VERSION_MAJOR=$(QT_MAJOR_VERSION) -DQT_VERSION_MINOR=$(QT_MINOR_VERSION) -DQT_VERSION_PATCH=$(QT_PATCH_VERSION) \ -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \ -DQT_NO_FOREACH -DUNICODE @@ -197,9 +196,6 @@ qmake_pch.obj: {$(SOURCE_PATH)\src\corelib\json}.cpp{}.obj:: $(CXX) $(CXXFLAGS) $< -{$(SOURCE_PATH)\tools\shared\windows}.cpp{}.obj:: - $(CXX) $(CXXFLAGS) $< - # Make sure qstring_compat.obj isn't compiled with PCH enabled qstring_compat.obj: $(SOURCE_PATH)\src\corelib\tools\qstring_compat.cpp $(CXX) -c $(CXXFLAGS_BARE) $(SOURCE_PATH)\src\corelib\tools\qstring_compat.cpp diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index da10b1984f..5b5eecd373 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index ae1d095629..ef4e9f29b6 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -61,7 +61,7 @@ QT_END_NAMESPACE #ifdef Q_OS_WIN32 #include -#include +#include QT_BEGIN_NAMESPACE diff --git a/tools/shared/windows/registry.cpp b/qmake/generators/win32/registry.cpp similarity index 100% rename from tools/shared/windows/registry.cpp rename to qmake/generators/win32/registry.cpp diff --git a/tools/shared/windows/registry_p.h b/qmake/generators/win32/registry_p.h similarity index 100% rename from tools/shared/windows/registry_p.h rename to qmake/generators/win32/registry_p.h From 8f49da6c18a2a86576f06deb9a6ff1deef748837 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 18 Nov 2016 16:24:31 +0100 Subject: [PATCH 036/304] ... and so configureapp.exe disappeareth Change-Id: I3fd9f2b0d4cf05a625484fce21532da8563cd62c Reviewed-by: Thiago Macieira --- configure.bat | 251 ++++++++++---- src/corelib/global/qconfig-bootstrapped.h | 7 +- tools/configure/Makefile.mingw | 125 ------- tools/configure/Makefile.win32 | 174 ---------- tools/configure/configure.pro | 135 -------- tools/configure/configure_pch.h | 41 --- tools/configure/configureapp.cpp | 380 ---------------------- tools/configure/configureapp.h | 74 ----- tools/configure/environment.cpp | 318 ------------------ tools/configure/environment.h | 57 ---- tools/configure/main.cpp | 72 ---- 11 files changed, 193 insertions(+), 1441 deletions(-) delete mode 100644 tools/configure/Makefile.mingw delete mode 100644 tools/configure/Makefile.win32 delete mode 100644 tools/configure/configure.pro delete mode 100644 tools/configure/configure_pch.h delete mode 100644 tools/configure/configureapp.cpp delete mode 100644 tools/configure/configureapp.h delete mode 100644 tools/configure/environment.cpp delete mode 100644 tools/configure/environment.h delete mode 100644 tools/configure/main.cpp diff --git a/configure.bat b/configure.bat index 385b1e3556..a5968e2ec7 100644 --- a/configure.bat +++ b/configure.bat @@ -28,13 +28,35 @@ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @echo off -setlocal ENABLEEXTENSIONS +setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS set ARGS=%* set QTSRC=%~dp0 +set QTSRC=%QTSRC:~0,-1% set QTDIR=%CD% +rem Parse command line + +set TOPLEVEL=false +set TOPQTSRC=%QTSRC% +set TOPQTDIR=%QTDIR% +if /i not "%~1" == "-top-level" goto notoplevel +set ARGS=%ARGS:~10% +set TOPLEVEL=true +for %%P in ("%TOPQTSRC%") do set TOPQTSRC=%%~dpP +set TOPQTSRC=%TOPQTSRC:~0,-1% +for %%P in ("%QTDIR%") do set TOPQTDIR=%%~dpP +set TOPQTDIR=%TOPQTDIR:~0,-1% +:notoplevel + +set SYNCQT= +set PLATFORM= +set MAKE= +call :doargs %ARGS% +if errorlevel 1 exit /b +goto doneargs + :doargs - if "%~1" == "" goto doneargs + if "%~1" == "" exit /b if "%~1" == "/?" goto help if "%~1" == "-?" goto help @@ -44,25 +66,118 @@ set QTDIR=%CD% if /i "%~1" == "-help" goto help if /i "%~1" == "--help" goto help + if /i "%~1" == "-redo" goto redo + if /i "%~1" == "--redo" goto redo + + if /i "%~1" == "-platform" goto platform + if /i "%~1" == "--platform" goto platform + + if /i "%~1" == "-no-syncqt" goto nosyncqt + if /i "%~1" == "--no-syncqt" goto nosyncqt + + if /i "%~1" == "-make-tool" goto maketool + if /i "%~1" == "--make-tool" goto maketool + +:nextarg shift goto doargs + +:help + type %QTSRC%\config_help.txt + exit /b 1 + +:redo + if not exist "%TOPQTDIR%\config.opt" goto redoerr + set rargs= + for /f "usebackq delims=" %%i in ("%TOPQTDIR%\config.opt") do set rargs=!rargs! "%%i" + call :doargs %rargs% + goto nextarg +:redoerr + echo No config.opt present - cannot redo configuration. >&2 + exit /b 1 + +:platform + shift + if "%~1" == "win32-msvc2012" goto msvc + if "%~1" == "win32-msvc2013" goto msvc + if "%~1" == "win32-msvc2015" goto msvc + if "%~1" == "win32-msvc2017" goto msvc + set PLATFORM=%~1 + goto nextarg +:msvc + echo. >&2 + echo Notice: re-mapping requested qmake spec to unified 'win32-msvc'. >&2 + echo. >&2 + set PLATFORM=win32-msvc + goto nextarg + +:nosyncqt + set SYNCQT=false + goto nextarg + +:maketool + shift + set MAKE=%~1 + goto nextarg + :doneargs -echo Please wait while bootstrapping configure ... - +rem Find various executables for %%C in (clang-cl.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C -if "%perl.exe%" == "" ( - echo Perl not found in PATH. Aborting. >&2 +rem Determine host spec + +if "%PLATFORM%" == "" ( + if not "%icl.exe%" == "" ( + set PLATFORM=win32-icc + ) else if not "%clang-cl.exe%" == "" ( + set PLATFORM=win32-clang-msvc + ) else if not "%cl.exe%" == "" ( + set PLATFORM=win32-msvc + ) else if not "%g++.exe%" == "" ( + set PLATFORM=win32-g++ + ) else ( + echo Cannot detect host toolchain. Please use -platform. Aborting. >&2 + exit /b 1 + ) +) +if not exist "%QTSRC%\mkspecs\%PLATFORM%\qmake.conf" ( + echo Host platform '%PLATFORM%' is invalid. Aborting. >&2 exit /b 1 ) +if "%PLATFORM:win32-g++=%" == "%PLATFORM%" ( + if "%MAKE%" == "" ( + if not "%jom.exe%" == "" ( + set MAKE=jom + ) else ( + set MAKE=nmake + ) + ) + set tmpl=win32 +) else ( + if "%MAKE%" == "" ( + set MAKE=mingw32-make + ) + set tmpl=unix +) + +rem Prepare build dir + if not exist mkspecs ( md mkspecs - if errorlevel 1 goto exit + if errorlevel 1 exit /b +) +if not exist bin ( + md bin + if errorlevel 1 exit /b +) +if not exist qmake ( + md qmake + if errorlevel 1 exit /b ) rem Extract Qt's version from .qmake.conf -for /f "eol=# tokens=1,2,3,4 delims=.= " %%i in (%QTSRC%.qmake.conf) do ( +for /f "eol=# tokens=1,2,3,4 delims=.= " %%i in (%QTSRC%\.qmake.conf) do ( if %%i == MODULE_VERSION ( set QTVERMAJ=%%j set QTVERMIN=%%k @@ -71,69 +186,85 @@ for /f "eol=# tokens=1,2,3,4 delims=.= " %%i in (%QTSRC%.qmake.conf) do ( ) set QTVERSION=%QTVERMAJ%.%QTVERMIN%.%QTVERPAT% -perl %QTSRC%bin\syncqt.pl -minimal -version %QTVERSION% -module QtCore -outdir "%QTDIR%" %QTSRC% -if errorlevel 1 goto exit +rem Create forwarding headers -if not exist tools\configure ( - md tools\configure - if errorlevel 1 goto exit +if "%SYNCQT%" == "" ( + if exist "%QTSRC%\.git" ( + set SYNCQT=true + ) else ( + set SYNCQT=false + ) +) +if "%SYNCQT%" == "true" ( + if not "%perl.exe%" == "" ( + echo Running syncqt ... + "%perl.exe%" -w "%QTSRC%\bin\syncqt.pl" -minimal -version %QTVERSION% -module QtCore -outdir "%QTDIR%" %QTSRC% + if errorlevel 1 exit /b + ) else ( + echo Perl not found in PATH. Aborting. >&2 + exit /b 1 + ) ) -cd tools\configure -if errorlevel 1 goto exit -set make=nmake -if not "%jom.exe%" == "" set make=jom +rem Build qmake + +echo Bootstrapping qmake ... + +cd qmake +if errorlevel 1 exit /b echo #### Generated by configure.bat - DO NOT EDIT! ####> Makefile echo/>> Makefile -echo QTVERSION = %QTVERSION%>> Makefile -rem These must have trailing spaces to avoid misinterpretation as 5>>, etc. -echo QT_VERSION_MAJOR = %QTVERMAJ% >> Makefile -echo QT_VERSION_MINOR = %QTVERMIN% >> Makefile -echo QT_VERSION_PATCH = %QTVERPAT% >> Makefile -if not "%icl.exe%" == "" ( - echo CXX = icl>>Makefile - echo EXTRA_CXXFLAGS = /Qstd=c++11 /Zc:forScope>>Makefile - rem This must have a trailing space. - echo QTSRC = %QTSRC% >> Makefile - set tmpl=win32 -) else if not "%cl.exe%" == "" ( - echo CXX = cl>>Makefile - echo EXTRA_CXXFLAGS =>>Makefile - rem This must have a trailing space. - echo QTSRC = %QTSRC% >> Makefile - set tmpl=win32 -) else if not "%clang-cl.exe%" == "" ( - echo CXX = clang-cl>>Makefile - echo EXTRA_CXXFLAGS = -fms-compatibility-version=19.00.23506 -Wno-microsoft-enum-value>>Makefile - rem This must have a trailing space. - echo QTSRC = %QTSRC% >> Makefile - set tmpl=win32 -) else if not "%g++.exe%" == "" ( - echo CXX = g++>>Makefile - echo EXTRA_CXXFLAGS =>>Makefile - rem This must NOT have a trailing space. - echo QTSRC = %QTSRC:\=/%>> Makefile - set tmpl=mingw - set make=mingw32-make +echo BUILD_PATH = ..>> Makefile +if "%tmpl%" == "win32" ( + echo SOURCE_PATH = %QTSRC%>> Makefile ) else ( - echo No suitable compiler found in PATH. Aborting. >&2 - cd ..\.. - exit /b 1 + echo SOURCE_PATH = %QTSRC:\=/%>> Makefile +) +if exist "%QTSRC%\.git" ( + echo INC_PATH = ../include>> Makefile +) else ( + echo INC_PATH = $^(SOURCE_PATH^)/include>> Makefile +) +echo QT_VERSION = %QTVERSION%>> Makefile +rem These must have trailing spaces to avoid misinterpretation as 5>>, etc. +echo QT_MAJOR_VERSION = %QTVERMAJ% >> Makefile +echo QT_MINOR_VERSION = %QTVERMIN% >> Makefile +echo QT_PATCH_VERSION = %QTVERPAT% >> Makefile +if "%tmpl%" == "win32" ( + echo QMAKESPEC = %PLATFORM%>> Makefile +) else ( + echo QMAKESPEC = $^(SOURCE_PATH^)/mkspecs/%PLATFORM%>> Makefile + echo CONFIG_CXXFLAGS = -std=c++11 -ffunction-sections>> Makefile + echo CONFIG_LFLAGS = -Wl,--gc-sections>> Makefile + type "%QTSRC%\qmake\Makefile.unix.win32" >> Makefile + type "%QTSRC%\qmake\Makefile.unix.mingw" >> Makefile ) echo/>> Makefile -type %QTSRC%tools\configure\Makefile.%tmpl% >> Makefile +type "%QTSRC%\qmake\Makefile.%tmpl%" >> Makefile -%make% -if errorlevel 1 (cd ..\.. & exit /b 1) +%MAKE% +if errorlevel 1 (cd .. & exit /b 1) -cd ..\.. +cd .. -:conf -configureapp.exe -srcdir %QTSRC% %ARGS% -goto exit +rem Generate qt.conf -:help -type %QTSRC%config_help.txt +> "%QTDIR%\bin\qt.conf" ( + @echo [EffectivePaths] + @echo Prefix=.. + @echo [Paths] + @echo TargetSpec=dummy + @echo HostSpec=%PLATFORM% +) +if not "%QTDIR%" == "%QTSRC%" ( + >> "%QTDIR%\bin\qt.conf" ( + @echo [EffectiveSourcePaths] + @echo Prefix=%QTSRC:\=/% + ) +) -:exit +rem Launch qmake-based configure + +cd "%TOPQTDIR%" +"%QTDIR%\bin\qmake.exe" "%TOPQTSRC%" -- %ARGS% diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index d0e45478cc..2bca82535f 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -84,10 +84,11 @@ #define QT_FEATURE_translation -1 #define QT_NO_GEOM_VARIANT -#if defined(QT_BUILD_QMAKE) || defined(QT_BUILD_CONFIGURE) +#ifdef QT_BUILD_QMAKE #define QT_FEATURE_commandlineparser -1 #define QT_NO_COMPRESS #define QT_JSON_READONLY +#define QT_NO_STANDARDPATHS #define QT_NO_TEXTCODEC #define QT_FEATURE_textcodec -1 #else @@ -97,8 +98,4 @@ #define QT_FEATURE_textcodec 1 #endif -#if defined(QT_BUILD_QMAKE) -#define QT_NO_STANDARDPATHS -#endif - #endif // QT_BOOTSTRAPPED diff --git a/tools/configure/Makefile.mingw b/tools/configure/Makefile.mingw deleted file mode 100644 index ccc3a64cdf..0000000000 --- a/tools/configure/Makefile.mingw +++ /dev/null @@ -1,125 +0,0 @@ -CORESRC = $(QTSRC)src/corelib -CONFSRC = $(QTSRC)tools/configure - -RAW_PCH = configure_pch.h -PCH = $(RAW_PCH).gch/c++ -DEFINES = -DUNICODE -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE -DQT_USE_QSTRINGBUILDER -DQT_VERSION_STR=\"$(QTVERSION)\" -DQT_VERSION_MAJOR=$(QT_VERSION_MAJOR) -DQT_VERSION_MINOR=$(QT_VERSION_MINOR) -DQT_VERSION_PATCH=$(QT_VERSION_PATCH) -INCPATH = -I"../../include" -I"../../include/QtCore" -I"../../include/QtCore/$(QTVERSION)" -I"../../include/QtCore/$(QTVERSION)/QtCore" -I"$(QTSRC)mkspecs/win32-g++" -CXXFLAGS_BARE = -std=c++11 -fno-rtti -fno-exceptions -mthreads -Wall -Wextra $(DEFINES) $(INCPATH) -CXXFLAGS = -include $(RAW_PCH) $(CXXFLAGS_BARE) -LINK = g++ -LFLAGS = -Wl,-subsystem,console -mthreads -LIBS = -lole32 -ladvapi32 -luuid - -TARGET = ../../configureapp.exe - -OBJECTS = \ - main.o \ - configureapp.o \ - environment.o \ - qarraydata.o \ - qbytearray.o \ - qbytearraymatcher.o \ - qhash.o \ - qlist.o \ - qlocale.o \ - qlocale_win.o \ - qlocale_tools.o \ - qvector.o \ - qutfcodec.o \ - qtextcodec.o \ - qglobal.o \ - qnumeric.o \ - qbuffer.o \ - qdatastream.o \ - qdir.o \ - qdiriterator.o \ - qfiledevice.o \ - qfile.o \ - qfileinfo.o \ - qabstractfileengine.o \ - qfilesystementry.o \ - qfilesystemengine.o \ - qfilesystemengine_win.o \ - qfilesystemiterator_win.o \ - qfsfileengine.o \ - qfsfileengine_win.o \ - qfsfileengine_iterator.o \ - qiodevice.o \ - qringbuffer.o \ - qdebug.o \ - qtextstream.o \ - qlogging.o \ - qtemporaryfile.o \ - qstandardpaths.o \ - qstandardpaths_win.o \ - qsystemlibrary.o \ - qbitarray.o \ - qdatetime.o \ - qmap.o \ - qregexp.o \ - qstring.o \ - qstring_compat.o \ - qstringbuilder.o \ - qstringlist.o \ - qvsnprintf.o \ - qvariant.o \ - qsystemerror.o \ - qmetatype.o \ - qmalloc.o \ - qxmlstream.o \ - qxmlutils.o \ - quuid.o - -$(TARGET): $(OBJECTS) - $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) - -$(OBJECTS): $(PCH) - -# SHELL is the full path of sh.exe, unless -# 1) it is found in the current directory -# 2) it is not found at all -# 3) it is overridden on the command line with an existing file -# ... otherwise it is always sh.exe. Specifically, SHELL from the -# environment has no effect. -# -# This check will fail if SHELL is explicitly set to a not -# sh-compatible shell. This is not a problem, because configure.bat -# will not do that. -ifeq ($(SHELL), sh.exe) - ifeq ($(wildcard "$(CURDIR)/sh.exe"), ) - SH = 0 - else - SH = 1 - endif -else - SH = 1 -endif - -ifeq ($(SH), 1) - CHK_DIR_EXISTS = test -d - CHK_DIR_EXISTS_GLUE = || - MKDIR = mkdir -p -else - CHK_DIR_EXISTS = if not exist - CHK_DIR_EXISTS_GLUE = - MKDIR = md -endif - -$(PCH): $(CONFSRC)/configure_pch.h - @$(CHK_DIR_EXISTS) $(RAW_PCH).gch $(CHK_DIR_EXISTS_GLUE) $(MKDIR) $(RAW_PCH).gch - $(CXX) -x c++-header -c $(CXXFLAGS_BARE) -o $@ $< - -VPATH = $(CONFSRC):$(CORESRC)/global:$(CORESRC)/kernel:$(CORESRC)/tools:$(CORESRC)/codecs:$(CORESRC)/io:$(CORESRC)/xml:$(CORESRC)/plugin - -main.o: $(CONFSRC)/configureapp.h -configureapp.o: $(CONFSRC)/configureapp.h $(CONFSRC)/environment.h -environment.o: $(CONFSRC)/environment.h - -# Make sure qstring_compat.obj isn't compiled with PCH enabled -qstring_compat.o: $(CORESRC)/tools/qstring_compat.cpp - $(CXX) -c $(CXXFLAGS_BARE) -o $@ $< - -clean: - -rm -f *.o - -rm -rf *.gch diff --git a/tools/configure/Makefile.win32 b/tools/configure/Makefile.win32 deleted file mode 100644 index f0199343be..0000000000 --- a/tools/configure/Makefile.win32 +++ /dev/null @@ -1,174 +0,0 @@ -CORESRC = $(QTSRC)src\corelib -CONFSRC = $(QTSRC)tools\configure - -DEFINES = -DUNICODE -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE -DQT_USE_QSTRINGBUILDER -DQT_VERSION_STR=\"$(QTVERSION)\" -DQT_VERSION_MAJOR=$(QT_VERSION_MAJOR) -DQT_VERSION_MINOR=$(QT_VERSION_MINOR) -DQT_VERSION_PATCH=$(QT_VERSION_PATCH) -INCPATH = -I"..\..\include" -I"..\..\include\QtCore" -I"..\..\include\QtCore\$(QTVERSION)" -I"..\..\include\QtCore\$(QTVERSION)\QtCore" -I"$(QTSRC)mkspecs\win32-msvc" -CXXFLAGS_BARE = -nologo -Zc:wchar_t -W3 -GR -EHsc -w34100 -w34189 -wd4577 $(CFLAGS_CRT) $(EXTRA_CXXFLAGS) $(DEFINES) $(INCPATH) -!IF ("$(CXX)" != "clang-cl") -PCH = configure_pch.pch -PCH_OBJECT = configure_pch.obj -CXXFLAGS = -FIconfigure_pch.h -Yuconfigure_pch.h -Fp$(PCH) -MP $(CXXFLAGS_BARE) -!ELSE -PCH = -CXXFLAGS = -Wmicrosoft $(CXXFLAGS_BARE) -!ENDIF -LINK = link -LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:"configure.intermediate.manifest" -LIBS = ole32.lib advapi32.lib shell32.lib - -TARGET = ..\..\configureapp.exe - -OBJECTS = \ - main.obj \ - configureapp.obj \ - environment.obj \ - qarraydata.obj \ - qbytearray.obj \ - qbytearraymatcher.obj \ - qhash.obj \ - qlist.obj \ - qlocale.obj \ - qlocale_win.obj \ - qlocale_tools.obj \ - qvector.obj \ - qutfcodec.obj \ - qtextcodec.obj \ - qglobal.obj \ - qnumeric.obj \ - qbuffer.obj \ - qdatastream.obj \ - qdir.obj \ - qdiriterator.obj \ - qfiledevice.obj \ - qfile.obj \ - qfileinfo.obj \ - qabstractfileengine.obj \ - qfilesystementry.obj \ - qfilesystemengine.obj \ - qfilesystemengine_win.obj \ - qfilesystemiterator_win.obj \ - qfsfileengine.obj \ - qfsfileengine_win.obj \ - qfsfileengine_iterator.obj \ - qiodevice.obj \ - qringbuffer.obj \ - qdebug.obj \ - qtextstream.obj \ - qlogging.obj \ - qtemporaryfile.obj \ - qstandardpaths.obj \ - qstandardpaths_win.obj \ - qsystemlibrary.obj \ - qbitarray.obj \ - qdatetime.obj \ - qmap.obj \ - qregexp.obj \ - qstring.obj \ - qstring_compat.obj \ - qstringbuilder.obj \ - qstringlist.obj \ - qvsnprintf.obj \ - qvariant.obj \ - qsystemerror.obj \ - qmetatype.obj \ - qmalloc.obj \ - qxmlstream.obj \ - qxmlutils.obj \ - quuid.obj \ - $(PCH_OBJECT) - -$(TARGET): $(OBJECTS) - $(LINK) $(LFLAGS) /OUT:$(TARGET) @<< - $(OBJECTS) $(LIBS) -<< - mt.exe -nologo -manifest "configure.intermediate.manifest" -outputresource:$(TARGET);1 - -clean: - -del *.obj - -del *.pch - -del configure.intermediate.manifest - -$(PCH): $(CONFSRC)\configure_pch.h - $(CXX) -c -Yc $(CXXFLAGS_BARE) -Fp$@ -Foconfigure_pch.obj -TP $** - -$(OBJECTS): $(PCH) - -main.obj: $(CONFSRC)\main.cpp $(CONFSRC)\configureapp.h $(PCH) -configureapp.obj: $(CONFSRC)\configureapp.cpp $(CONFSRC)\configureapp.h $(CONFSRC)\environment.h $(PCH) -environment.obj: $(CONFSRC)\environment.cpp $(CONFSRC)\environment.h $(PCH) -qarraydata.obj: $(CORESRC)\tools\qarraydata.cpp $(PCH) -qbytearray.obj: $(CORESRC)\tools\qbytearray.cpp $(PCH) -qbytearraymatcher.obj: $(CORESRC)\tools\qbytearraymatcher.cpp $(PCH) -qhash.obj: $(CORESRC)\tools\qhash.cpp $(PCH) -qlist.obj: $(CORESRC)\tools\qlist.cpp $(PCH) -qlocale.obj: $(CORESRC)\tools\qlocale.cpp $(PCH) -qlocale_win.obj: $(CORESRC)\tools\qlocale_win.cpp $(PCH) -qlocale_tools.obj: $(CORESRC)\tools\qlocale_tools.cpp $(PCH) -qvector.obj: $(CORESRC)\tools\qvector.cpp $(PCH) -qutfcodec.obj: $(CORESRC)\codecs\qutfcodec.cpp $(PCH) -qtextcodec.obj: $(CORESRC)\codecs\qtextcodec.cpp $(PCH) -qglobal.obj: $(CORESRC)\global\qglobal.cpp $(PCH) -qnumeric.obj: $(CORESRC)\global\qnumeric.cpp $(PCH) -qbuffer.obj: $(CORESRC)\io\qbuffer.cpp $(PCH) -qdatastream.obj: $(CORESRC)\io\qdatastream.cpp $(PCH) -qdir.obj: $(CORESRC)\io\qdir.cpp $(PCH) -qdiriterator.obj: $(CORESRC)\io\qdiriterator.cpp $(PCH) -qfiledevice.obj: $(CORESRC)\io\qfiledevice.cpp $(PCH) -qfile.obj: $(CORESRC)\io\qfile.cpp $(PCH) -qfileinfo.obj: $(CORESRC)\io\qfileinfo.cpp $(PCH) -qabstractfileengine.obj: $(CORESRC)\io\qabstractfileengine.cpp $(PCH) -qfilesystementry.obj: $(CORESRC)\io\qfilesystementry.cpp $(PCH) -qfilesystemengine.obj: $(CORESRC)\io\qfilesystemengine.cpp $(PCH) -qfilesystemengine_win.obj: $(CORESRC)\io\qfilesystemengine_win.cpp $(PCH) -qfilesystemiterator_win.obj: $(CORESRC)\io\qfilesystemiterator_win.cpp $(PCH) -qfsfileengine.obj: $(CORESRC)\io\qfsfileengine.cpp $(PCH) -qfsfileengine_win.obj: $(CORESRC)\io\qfsfileengine_win.cpp $(PCH) -qfsfileengine_iterator.obj: $(CORESRC)\io\qfsfileengine_iterator.cpp $(PCH) -qiodevice.obj: $(CORESRC)\io\qiodevice.cpp $(PCH) -qringbuffer.obj: $(CORESRC)\tools\qringbuffer.cpp $(PCH) -qdebug.obj: $(CORESRC)\io\qdebug.cpp $(PCH) -qtextstream.obj: $(CORESRC)\io\qtextstream.cpp $(PCH) -qtemporaryfile.obj: $(CORESRC)\io\qtemporaryfile.cpp $(PCH) -qstandardpaths.obj: $(CORESRC)\io\qstandardpaths.cpp $(PCH) -qstandardpaths_win.obj: $(CORESRC)\io\qstandardpaths_win.cpp $(PCH) -qsystemlibrary.obj: $(CORESRC)\plugin\qsystemlibrary.cpp $(PCH) -qbitarray.obj: $(CORESRC)\tools\qbitarray.cpp $(PCH) -qdatetime.obj: $(CORESRC)\tools\qdatetime.cpp $(PCH) -qmap.obj: $(CORESRC)\tools\qmap.cpp $(PCH) -qregexp.obj: $(CORESRC)\tools\qregexp.cpp $(PCH) -qstring.obj: $(CORESRC)\tools\qstring.cpp $(PCH) -qstringbuilder.obj: $(CORESRC)\tools\qstringbuilder.cpp $(PCH) -qstringlist.obj: $(CORESRC)\tools\qstringlist.cpp $(PCH) -qvsnprintf.obj: $(CORESRC)\tools\qvsnprintf.cpp $(PCH) -qvariant.obj: $(CORESRC)\kernel\qvariant.cpp $(PCH) -qsystemerror.obj: $(CORESRC)\kernel\qsystemerror.cpp $(PCH) -qline.obj: $(CORESRC)\tools\qline.cpp $(PCH) -qsize.obj: $(CORESRC)\tools\qsize.cpp $(PCH) -qpoint.obj: $(CORESRC)\tools\qpoint.cpp $(PCH) -qrect.obj: $(CORESRC)\tools\qrect.cpp $(PCH) -qmetatype.obj: $(CORESRC)\kernel\qmetatype.cpp $(PCH) -qmalloc.obj: $(CORESRC)\global\qmalloc.cpp $(PCH) -qxmlstream.obj: $(CORESRC)\xml\qxmlstream.cpp $(PCH) -qxmlutils.obj: $(CORESRC)\xml\qxmlutils.cpp $(PCH) -quuid.obj: $(CORESRC)\plugin\quuid.cpp $(PCH) - -{$(CONFSRC)}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< -{$(CORESRC)\tools}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< -{$(CORESRC)\codecs}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< -{$(CORESRC)\global}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< -{$(CORESRC)\io}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< -{$(CORESRC)\kernel}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< -{$(CORESRC)\plugin}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< -{$(CORESRC)\xml}.cpp{}.obj:: - $(CXX) -c $(CXXFLAGS) $< - -# Make sure qstring_compat.obj isn't compiled with PCH enabled -qstring_compat.obj: $(CORESRC)\tools\qstring_compat.cpp - $(CXX) -c $(CXXFLAGS_BARE) $(CORESRC)\tools\qstring_compat.cpp diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro deleted file mode 100644 index 90da2de119..0000000000 --- a/tools/configure/configure.pro +++ /dev/null @@ -1,135 +0,0 @@ -TARGET = configureapp -DESTDIR = $$PWD/../.. # build directly in source dir - -CONFIG += console flat stl rtti_off -CONFIG -= moc qt -DEFINES = UNICODE _CRT_SECURE_NO_DEPRECATE QT_USE_QSTRINGBUILDER -DEFINES += QT_BOOTSTRAPPED QT_BUILD_CONFIGURE - -win32 : LIBS += -lole32 -ladvapi32 -mingw : LIBS += -luuid - -win32-msvc* { - QMAKE_CFLAGS_RELEASE -= -MD - QMAKE_CFLAGS_RELEASE -= -O2 - QMAKE_CFLAGS_RELEASE += -MT -O1 -Os - QMAKE_CFLAGS_DEBUG -= -MDd - QMAKE_CFLAGS_DEBUG += -MTd - QMAKE_CXXFLAGS_RELEASE -= -MD - QMAKE_CXXFLAGS_RELEASE -= -O2 - QMAKE_CXXFLAGS_RELEASE += -MT -O1 -Os - QMAKE_CXXFLAGS_DEBUG -= -MDd - QMAKE_CXXFLAGS_DEBUG += -MTd -} - -PRECOMPILED_HEADER = configure_pch.h - -INCLUDEPATH += \ - $$QT_BUILD_TREE/include \ - $$QT_BUILD_TREE/include/QtCore \ - $$QT_BUILD_TREE/include/QtCore/$$QT.core.VERSION \ - $$QT_BUILD_TREE/include/QtCore/$$QT.core.VERSION/QtCore \ - $$QT_SOURCE_TREE/tools/shared - -HEADERS = configureapp.h environment.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qarraydata.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qbytearray.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qarraydatapointer.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qarraydataops.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qchar.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qhash.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qlist.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qlocale.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qvector.h \ - $$QT_SOURCE_TREE/src/corelib/codecs/qutfcodec_p.h \ - $$QT_SOURCE_TREE/src/corelib/codecs/qtextcodec.h \ - $$QT_SOURCE_TREE/src/corelib/global/qglobal.h \ - $$QT_SOURCE_TREE/src/corelib/global/qnumeric.h \ - $$QT_SOURCE_TREE/src/corelib/global/qlogging.h \ - $$QT_SOURCE_TREE/src/corelib/io/qbuffer.h \ - $$QT_SOURCE_TREE/src/corelib/io/qdatastream.h \ - $$QT_SOURCE_TREE/src/corelib/io/qdir.h \ - $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfiledevice.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfile.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry_p.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_p.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfilesystemmetadata_p.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_p.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.h \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_p.h \ - $$QT_SOURCE_TREE/src/corelib/io/qiodevice.h \ - $$QT_SOURCE_TREE/src/corelib/io/qtextstream.h \ - $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.h \ - $$QT_SOURCE_TREE/src/corelib/io/qstandardpaths.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qbitarray.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qdatetime.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qmap.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qregexp.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qringbuffer_p.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qstring.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qstringbuilder.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qstringmatcher.h \ - $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables_p.h \ - $$QT_SOURCE_TREE/src/corelib/kernel/qsystemerror_p.h \ - $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.h \ - $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils_p.h - -SOURCES = main.cpp configureapp.cpp environment.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qbytearray.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qarraydata.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qhash.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qlist.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qlocale.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qlocale_win.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qlocale_tools.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qvector.cpp \ - $$QT_SOURCE_TREE/src/corelib/codecs/qutfcodec.cpp \ - $$QT_SOURCE_TREE/src/corelib/codecs/qtextcodec.cpp \ - $$QT_SOURCE_TREE/src/corelib/global/qglobal.cpp \ - $$QT_SOURCE_TREE/src/corelib/global/qnumeric.cpp \ - $$QT_SOURCE_TREE/src/corelib/global/qlogging.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qbuffer.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qdatastream.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qdir.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfiledevice.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfile.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_win.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qiodevice.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qdebug.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qtextstream.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qstandardpaths.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qstandardpaths_win.cpp \ - $$QT_SOURCE_TREE/src/corelib/plugin/qsystemlibrary.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qbitarray.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qdatetime.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qmap.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qregexp.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qringbuffer.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qstring.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qstringbuilder.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qstring_compat.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qvsnprintf.cpp \ - $$QT_SOURCE_TREE/src/corelib/kernel/qvariant.cpp \ - $$QT_SOURCE_TREE/src/corelib/kernel/qsystemerror.cpp \ - $$QT_SOURCE_TREE/src/corelib/kernel/qmetatype.cpp \ - $$QT_SOURCE_TREE/src/corelib/global/qmalloc.cpp \ - $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.cpp \ - $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils.cpp \ - $$QT_SOURCE_TREE/src/corelib/plugin/quuid.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qcryptographichash.cpp diff --git a/tools/configure/configure_pch.h b/tools/configure/configure_pch.h deleted file mode 100644 index 8e36f7e54e..0000000000 --- a/tools/configure/configure_pch.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// for rand_s, _CRT_RAND_S must be #defined before #including stdlib.h. -// put it at the beginning so some indirect inclusion doesn't break it -#ifndef _CRT_RAND_S -#define _CRT_RAND_S -#endif -#include -#include -#include -#include // All moc genereated code has this include -#include -#include -#include -#include diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp deleted file mode 100644 index 6a09705cc1..0000000000 --- a/tools/configure/configureapp.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "configureapp.h" -#include "environment.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -std::ostream &operator<<(std::ostream &s, const QString &val) { - s << val.toLocal8Bit().data(); - return s; -} - - -using namespace std; - -Configure::Configure(int& argc, char** argv) -{ - int i; - - for (i = 1; i < argc; i++) - configCmdLine += argv[ i ]; - - if (configCmdLine.size() >= 2 && configCmdLine.at(0) == "-srcdir") { - sourcePath = QDir::cleanPath(configCmdLine.at(1)); - sourceDir = QDir(sourcePath); - configCmdLine.erase(configCmdLine.begin(), configCmdLine.begin() + 2); - } else { - // Get the path to the executable - wchar_t module_name[MAX_PATH]; - GetModuleFileName(0, module_name, sizeof(module_name) / sizeof(wchar_t)); - QFileInfo sourcePathInfo = QString::fromWCharArray(module_name); - sourcePath = sourcePathInfo.absolutePath(); - sourceDir = sourcePathInfo.dir(); - } - buildPath = QDir::currentPath(); - if (sourceDir != buildDir) { //shadow builds! - QDir(buildPath).mkpath("bin"); - - buildDir.mkpath("mkspecs"); - } - - if (dictionary[ "QMAKESPEC" ].size() == 0) { - dictionary[ "QMAKESPEC" ] = Environment::detectQMakeSpec(); - dictionary[ "QMAKESPEC_FROM" ] = "detected"; - } - - dictionary[ "SYNCQT" ] = "auto"; - - QString tmp = dictionary[ "QMAKESPEC" ]; - if (tmp.contains("\\")) { - tmp = tmp.mid(tmp.lastIndexOf("\\") + 1); - } else { - tmp = tmp.mid(tmp.lastIndexOf("/") + 1); - } - dictionary[ "QMAKESPEC" ] = tmp; -} - -Configure::~Configure() -{ -} - -void Configure::parseCmdLine() -{ - sourcePathMangled = sourcePath; - buildPathMangled = buildPath; - if (configCmdLine.size() && configCmdLine.at(0) == "-top-level") { - dictionary[ "TOPLEVEL" ] = "yes"; - configCmdLine.removeAt(0); - sourcePathMangled = QFileInfo(sourcePath).path(); - buildPathMangled = QFileInfo(buildPath).path(); - } - qmakeCmdLine = configCmdLine; - - int argCount = configCmdLine.size(); - int i = 0; - - // Look first for -redo - for (int k = 0 ; k < argCount; ++k) { - if (configCmdLine.at(k) == "-redo") { - configCmdLine.removeAt(k); - if (!reloadCmdLine(k)) { - dictionary["DONE"] = "error"; - return; - } - argCount = configCmdLine.size(); - break; - } - } - - for (; i -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class Configure -{ -public: - Configure( int& argc, char** argv ); - ~Configure(); - - void parseCmdLine(); - - void buildQmake(); - - void prepareConfigureInput(); - void configure(); - - void generateHeaders(); - - bool isDone(); - bool isOk(); - -private: - int verbose; - - // Our variable dictionaries - QMap dictionary; - QStringList configCmdLine, qmakeCmdLine; - - QString outputLine; - - QTextStream outStream; - QString sourcePath, buildPath; - QString sourcePathMangled, buildPathMangled; - QDir sourceDir, buildDir; - - bool reloadCmdLine(int idx); -}; - -QT_END_NAMESPACE diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp deleted file mode 100644 index 312e2f9e56..0000000000 --- a/tools/configure/environment.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "environment.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -//#define CONFIGURE_DEBUG_EXECUTE -//#define CONFIGURE_DEBUG_CP_DIR - -using namespace std; - -#ifdef Q_OS_WIN32 -#include -#endif - -QT_BEGIN_NAMESPACE - -struct CompilerInfo{ - Compiler compiler; - const char *compilerStr; - const char *executable; -} compiler_info[] = { - // The compilers here are sorted in a reversed-preferred order - {CC_MINGW, "MinGW (Minimalist GNU for Windows)", "g++.exe"}, - {CC_INTEL, "Intel(R) C++ Compiler for 32-bit applications", "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe - {CC_MSVC, "Microsoft (R) Visual Studio C/C++ Compiler", "cl.exe"}, // link.exe, lib.exe - {CC_UNKNOWN, "Unknown", 0}, -}; - - -// Initialize static variables -Compiler Environment::detectedCompiler = CC_UNKNOWN; - -/*! - Returns the pointer to the CompilerInfo for a \a compiler. -*/ -CompilerInfo *Environment::compilerInfo(Compiler compiler) -{ - int i = 0; - while(compiler_info[i].compiler != compiler && compiler_info[i].compiler != CC_UNKNOWN) - ++i; - return &(compiler_info[i]); -} - -/*! - Returns the qmakespec for the compiler detected on the system. -*/ -QString Environment::detectQMakeSpec() -{ - QString spec; - switch (detectCompiler()) { - case CC_MSVC: - spec = "win32-msvc"; - break; - case CC_INTEL: - spec = "win32-icc"; - break; - case CC_MINGW: - spec = "win32-g++"; - break; - default: - break; - } - - return spec; -} - -/*! - Returns the enum of the compiler which was detected on the system. - The compilers are detected in the order as entered into the - compiler_info list. - - If more than one compiler is found, CC_UNKNOWN is returned. -*/ -Compiler Environment::detectCompiler() -{ - if(detectedCompiler != CC_UNKNOWN) - return detectedCompiler; - - int installed = 0; - for (int i = 0; compiler_info[i].compiler; ++i) { - if (!QStandardPaths::findExecutable(compiler_info[i].executable).isEmpty()) { - if (detectedCompiler == CC_UNKNOWN) - detectedCompiler = compiler_info[i].compiler; - ++installed; - } - } - - if (installed > 1) { - cout << "Found more than one known compiler! Using \"" << compilerInfo(detectedCompiler)->compilerStr << "\"" << endl; - detectedCompiler = CC_UNKNOWN; - } - return detectedCompiler; -}; - -/*! - Creates a commandling from \a program and it \a arguments, - escaping characters that needs it. -*/ -static QString qt_create_commandline(const QString &program, const QStringList &arguments) -{ - QString programName = program; - if (!programName.startsWith("\"") && !programName.endsWith("\"") && programName.contains(" ")) - programName = "\"" + programName + "\""; - programName.replace("/", "\\"); - - QString args; - // add the prgram as the first arrg ... it works better - args = programName + " "; - for (int i=0; i0 && tmp.at(i-1) == '\\') { - --i; - endQuote += "\\"; - } - args += QString(" \"") + tmp.left(i) + endQuote; - } else { - args += ' ' + tmp; - } - } - return args; -} - -/*! - Creates a QByteArray of the \a environment. -*/ -static QByteArray qt_create_environment(const QStringList &environment) -{ - QByteArray envlist; - if (environment.isEmpty()) - return envlist; - - int pos = 0; - // add PATH if necessary (for DLL loading) - QByteArray path = qgetenv("PATH"); - if (environment.filter(QRegExp("^PATH=",Qt::CaseInsensitive)).isEmpty() && !path.isNull()) { - QString tmp = QString(QLatin1String("PATH=%1")).arg(QString::fromLocal8Bit(path)); - uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1); - envlist.resize(envlist.size() + tmpSize); - memcpy(envlist.data() + pos, tmp.utf16(), tmpSize); - pos += tmpSize; - } - // add the user environment - foreach (const QString &tmp, environment) { - uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1); - envlist.resize(envlist.size() + tmpSize); - memcpy(envlist.data() + pos, tmp.utf16(), tmpSize); - pos += tmpSize; - } - // add the 2 terminating 0 (actually 4, just to be on the safe side) - envlist.resize(envlist.size() + 4); - envlist[pos++] = 0; - envlist[pos++] = 0; - envlist[pos++] = 0; - envlist[pos++] = 0; - - return envlist; -} - -/*! - Executes the command described in \a arguments, in the - environment inherited from the parent process, with the - \a additionalEnv settings applied. - \a removeEnv removes the specified environment variables from - the environment of the executed process. - - Returns the exit value of the process, or -1 if the command could - not be executed. - - This function uses _(w)spawnvpe to spawn a process by searching - through the PATH environment variable. -*/ -int Environment::execute(QStringList arguments, const QStringList &additionalEnv, const QStringList &removeEnv) -{ -#ifdef CONFIGURE_DEBUG_EXECUTE - qDebug() << "About to Execute: " << arguments; - qDebug() << " " << QDir::currentPath(); - qDebug() << " " << additionalEnv; - qDebug() << " " << removeEnv; -#endif - // Create the full environment from the current environment and - // the additionalEnv strings, then remove all variables defined - // in removeEnv - QMap fullEnvMap; - LPWSTR envStrings = GetEnvironmentStrings(); - if (envStrings) { - int strLen = 0; - for (LPWSTR envString = envStrings; *(envString); envString += strLen + 1) { - strLen = int(wcslen(envString)); - QString str = QString((const QChar*)envString, strLen); - if (!str.startsWith("=")) { // These are added by the system - int sepIndex = str.indexOf('='); - fullEnvMap.insert(str.left(sepIndex).toUpper(), str.mid(sepIndex +1)); - } - } - } - FreeEnvironmentStrings(envStrings); - - // Add additionalEnv variables - for (int i = 0; i < additionalEnv.count(); ++i) { - const QString &str = additionalEnv.at(i); - int sepIndex = str.indexOf('='); - fullEnvMap.insert(str.left(sepIndex).toUpper(), str.mid(sepIndex +1)); - } - - // Remove removeEnv variables - for (int j = 0; j < removeEnv.count(); ++j) - fullEnvMap.remove(removeEnv.at(j).toUpper()); - - // Add all variables to a QStringList - QStringList fullEnv; - QMapIterator it(fullEnvMap); - while (it.hasNext()) { - it.next(); - fullEnv += QString(it.key() + "=" + it.value()); - } - - // ---------------------------- - QString program = arguments.takeAt(0); - QString args = qt_create_commandline(program, arguments); - QByteArray envlist = qt_create_environment(fullEnv); - - DWORD exitCode = DWORD(-1); - PROCESS_INFORMATION procInfo; - memset(&procInfo, 0, sizeof(procInfo)); - - STARTUPINFO startInfo; - memset(&startInfo, 0, sizeof(startInfo)); - startInfo.cb = sizeof(startInfo); - - bool couldExecute = CreateProcess(0, (wchar_t*)args.utf16(), - 0, 0, true, CREATE_UNICODE_ENVIRONMENT, - envlist.isEmpty() ? 0 : envlist.data(), - 0, &startInfo, &procInfo); - - if (couldExecute) { - WaitForSingleObject(procInfo.hProcess, INFINITE); - GetExitCodeProcess(procInfo.hProcess, &exitCode); - CloseHandle(procInfo.hThread); - CloseHandle(procInfo.hProcess); - } - - - if (exitCode == DWORD(-1)) { - switch(GetLastError()) { - case E2BIG: - cerr << "execute: Argument list exceeds 1024 bytes" << endl; - foreach (const QString &arg, arguments) - cerr << " (" << arg.toLocal8Bit().constData() << ")" << endl; - break; - case ENOENT: - cerr << "execute: File or path is not found (" << program.toLocal8Bit().constData() << ")" << endl; - break; - case ENOEXEC: - cerr << "execute: Specified file is not executable or has invalid executable-file format (" << program.toLocal8Bit().constData() << ")" << endl; - break; - case ENOMEM: - cerr << "execute: Not enough memory is available to execute new process." << endl; - break; - default: - cerr << "execute: Unknown error" << endl; - foreach (const QString &arg, arguments) - cerr << " (" << arg.toLocal8Bit().constData() << ")" << endl; - break; - } - } - return exitCode; -} - -QT_END_NAMESPACE diff --git a/tools/configure/environment.h b/tools/configure/environment.h deleted file mode 100644 index 65ddc60eff..0000000000 --- a/tools/configure/environment.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -QT_BEGIN_NAMESPACE - - -enum Compiler { - CC_UNKNOWN = 0, - CC_MINGW = 0x02, - CC_INTEL = 0x03, - CC_MSVC = 0x04 -}; - -struct CompilerInfo; -class Environment -{ -public: - static Compiler detectCompiler(); - static QString detectQMakeSpec(); - - static int execute(QStringList arguments, const QStringList &additionalEnv, const QStringList &removeEnv); - -private: - static Compiler detectedCompiler; - - static CompilerInfo *compilerInfo(Compiler compiler); -}; - - -QT_END_NAMESPACE diff --git a/tools/configure/main.cpp b/tools/configure/main.cpp deleted file mode 100644 index c6b555d14d..0000000000 --- a/tools/configure/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* -** Configure tool -** -*/ - -#include "configureapp.h" - -QT_BEGIN_NAMESPACE - -int runConfigure( int argc, char** argv ) -{ - Configure app( argc, argv ); - if (!app.isOk()) - return 3; - - app.parseCmdLine(); - if (!app.isOk()) - return 3; - - // Bootstrapped includes. Needed by qmake. - app.generateHeaders(); - if (!app.isOk()) - return 3; - - // Bootstrap qmake. Needed by config tests. - app.buildQmake(); - if (!app.isOk()) - return 3; - - // run qmake based configure - app.configure(); - if (!app.isOk()) - return 3; - - return 0; -} - -QT_END_NAMESPACE - -int main( int argc, char** argv ) -{ - QT_USE_NAMESPACE - return runConfigure(argc, argv); -} From 7957d0fbd71767055b1fa408d3a05d3892718c84 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 22 Dec 2016 16:54:12 -0800 Subject: [PATCH 037/304] Fix typo in -Xarch handling Change-Id: I05e1491f3b1b5af28992ea53d513c709e1161a8e Reviewed-by: Oswald Buddenhagen --- mkspecs/features/mac/sdk.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf index c7f5850aa0..16a46a362c 100644 --- a/mkspecs/features/mac/sdk.prf +++ b/mkspecs/features/mac/sdk.prf @@ -91,7 +91,7 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_ -Wl,-syslibroot,$$xcodeSDKInfo(Path, $$sdk) QMAKE_XARCH_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch}) - QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch}) + QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS_$${arch}) QMAKE_EXTRA_VARIABLES += \ QMAKE_XARCH_CFLAGS_$${arch} \ From ab732e3b2f775df3c30bd67238b0c1b8cd2fa31a Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 22 Dec 2016 15:07:40 +0300 Subject: [PATCH 038/304] Optimize QtActivity's onCreate a little bit Change-Id: Iabb0f561d99f363dfe1dc206b3ad3e8f1a1d04c0 Reviewed-by: Alex Blasche --- .../org/qtproject/qt5/android/bindings/QtActivityLoader.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java index ce0ce3abc7..759daf4393 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java @@ -118,10 +118,12 @@ public class QtActivityLoader extends QtLoader { public void onCreate(Bundle savedInstanceState) { try { m_contextInfo = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(), PackageManager.GET_META_DATA); + int theme = ((ActivityInfo)m_contextInfo).getThemeResource(); for (Field f : Class.forName("android.R$style").getDeclaredFields()) { - if (f.getInt(null) == ((ActivityInfo)m_contextInfo).getThemeResource()) { + if (f.getInt(null) == theme) { QT_ANDROID_THEMES = new String[] {f.getName()}; QT_ANDROID_DEFAULT_THEME = f.getName(); + break; } } } catch (Exception e) { From 9efd29d1e27702fadcdfa207c9605fcb5b6b8dba Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 15 Dec 2016 15:50:19 +0100 Subject: [PATCH 039/304] Fix GCC 7 developer build Disables escalating the implicit fallthough warning to an error, since Qt is not yet free of unmarked implicit fallthroughs. With this we can clean the code in the dev branch instead of in 5.6 and 5.8, and only backport bug fixes. Change-Id: Id30ee21b77de6defcb7d5bb1e05e86c0db098481 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- mkspecs/features/qt_common.prf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index d30983f62b..7967697eb4 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -98,6 +98,9 @@ warnings_are_errors:warning_clean { # error: assuming signed overflow does not occur when assuming that (X + c) < X is always false QMAKE_CXXFLAGS_WARN_ON += -Wno-error=strict-overflow + # GCC 7 includes -Wimplicit-fallthrough in -Wextra, but Qt is not yet free of implicit fallthroughs. + greaterThan(QT_GCC_MAJOR_VERSION, 6): QMAKE_CXXFLAGS_WARN_ON += -Wno-error=implicit-fallthrough + # Work-around for bug https://code.google.com/p/android/issues/detail?id=58135 android: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=literal-suffix } From 7322c65ba70bc93d034dc570dd314dc9d738f0fa Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 13:38:21 +0100 Subject: [PATCH 040/304] QMimeMagicRule: fix off by one in the number of bytes checked Since the loop says p <= e, no +1 should be added to e. Testcase: The magic for application/x-gameboy-rom says and this code was checking both byte 323 and byte 324, finding a match at pos 324, returning application/x-gameboy-rom erroneously. Given the magic for application/x-gameboy-color-rom: the expected result for game-boy-color-test.gbc is application/x-gameboy-color-rom Not yet detected by tst_qmimedatabase which is based on shared-mime-info 1.0, will be covered by the upgrade to 1.8. Change-Id: I2396cb1ccfb26db5a24d5551fef493cc0b98a247 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimemagicrule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index 7e07f8acb9..7a807dccdb 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -161,7 +161,7 @@ bool QMimeMagicRule::matchNumber(const QByteArray &data) const //qDebug() << "mask" << QString::number(m_numberMask, 16); const char *p = data.constData() + m_startPos; - const char *e = data.constData() + qMin(data.size() - int(sizeof(T)), m_endPos + 1); + const char *e = data.constData() + qMin(data.size() - int(sizeof(T)), m_endPos); for ( ; p <= e; ++p) { if ((qFromUnaligned(p) & mask) == (value & mask)) return true; From f163912b5d577705c3d42428b0af75222f84b761 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 13:42:30 +0100 Subject: [PATCH 041/304] QMimeMagicRule: endianness fixes * apply endianness to the mask as well * do not apply endianness to "host" entries, they were wrongly behaving exactly like "big endian" entries. The issue with the mask was detected by the audio/aac magic which failed to identify the test file ct_faac-adts.aac since it was applying the mask 0xFFF6 instead of 0xF6FF (on a little-endian machine). Not yet detected by tst_qmimedatabase which is based on shared-mime-info 1.0, will be covered by the upgrade to 1.8 in dev. Change-Id: I4fb7af2d367099817e712b14f2a031066d0ac432 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimemagicrule.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index 7a807dccdb..5bbf1bba9d 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -299,20 +299,30 @@ QMimeMagicRule::QMimeMagicRule(const QString &type, } break; case Big16: - case Host16: case Little16: if (m_number <= quint16(-1)) { m_number = m_type == Little16 ? qFromLittleEndian(m_number) : qFromBigEndian(m_number); + if (m_numberMask != 0) + m_numberMask = m_type == Little16 ? qFromLittleEndian(m_numberMask) : qFromBigEndian(m_numberMask); + } + Q_FALLTHROUGH(); + case Host16: + if (m_number <= quint16(-1)) { if (m_numberMask == 0) m_numberMask = quint16(-1); m_matchFunction = &QMimeMagicRule::matchNumber; } break; case Big32: - case Host32: case Little32: if (m_number <= quint32(-1)) { m_number = m_type == Little32 ? qFromLittleEndian(m_number) : qFromBigEndian(m_number); + if (m_numberMask != 0) + m_numberMask = m_type == Little32 ? qFromLittleEndian(m_numberMask) : qFromBigEndian(m_numberMask); + } + Q_FALLTHROUGH(); + case Host32: + if (m_number <= quint32(-1)) { if (m_numberMask == 0) m_numberMask = quint32(-1); m_matchFunction = &QMimeMagicRule::matchNumber; From 6722147696c7ba603d24163498a3f7de76ad6cea Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 13:46:40 +0100 Subject: [PATCH 042/304] QMimeDatabase: fix handling of conflicting globs This code always intended to follow the recommended checking order from the spec, which says "if multiple globs match, use file contents". But if the globs had different weights, it would discard globs with lower weights, and then wrongly conclude, if there is only one glob left, that there was no ambiguity. The correct way is rather: remember that multiple globs matched, do determination from contents, and if that didn't work, *then* use (one of) the highest-weight glob(s). This fixes PGP-encrypted *.asc files being detected as text/plain rather than application/pgp-encrypted. (https://bugs.kde.org/show_bug.cgi?id=346754) Change-Id: I734459daf9f502baa95ebb89432819964e0ce304 Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimedatabase.cpp | 27 ++++++------ src/corelib/mimetypes/qmimedatabase_p.h | 2 +- src/corelib/mimetypes/qmimeglobpattern.cpp | 50 +++++++++++----------- src/corelib/mimetypes/qmimeglobpattern_p.h | 5 ++- src/corelib/mimetypes/qmimeprovider.cpp | 17 +++----- src/corelib/mimetypes/qmimeprovider_p.h | 7 +-- 6 files changed, 56 insertions(+), 52 deletions(-) diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 448e6117b1..fda9f01643 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -108,12 +108,12 @@ QMimeType QMimeDatabasePrivate::mimeTypeForName(const QString &nameOrAlias) return provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias)); } -QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName, QString *foundSuffix) +QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName) { if (fileName.endsWith(QLatin1Char('/'))) return QStringList() << QLatin1String("inode/directory"); - QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName(), foundSuffix); + QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName()).m_matchingMimeTypes; matchingMimeTypes.sort(); // make it deterministic return matchingMimeTypes; } @@ -168,13 +168,17 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa *accuracyPtr = 0; // Pass 1) Try to match on the file name - QStringList candidatesByName = mimeTypeForFileName(fileName); - if (candidatesByName.count() == 1) { + QMimeGlobMatchResult candidatesByName; + if (fileName.endsWith(QLatin1Char('/'))) + candidatesByName.addMatch(QLatin1String("inode/directory"), 100, QString()); + else + candidatesByName = provider()->findByFileName(QFileInfo(fileName).fileName()); + if (candidatesByName.m_allMatchingMimeTypes.count() == 1) { *accuracyPtr = 100; - const QMimeType mime = mimeTypeForName(candidatesByName.at(0)); + const QMimeType mime = mimeTypeForName(candidatesByName.m_matchingMimeTypes.at(0)); if (mime.isValid()) return mime; - candidatesByName.clear(); + candidatesByName = {}; } // Extension is unknown, or matches multiple mimetypes. @@ -193,7 +197,7 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa // "for glob_match in glob_matches:" // "if glob_match is subclass or equal to sniffed_type, use glob_match" const QString sniffedMime = candidateByData.name(); - for (const QString &m : qAsConst(candidatesByName)) { + for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) { if (inherits(m, sniffedMime)) { // We have magic + pattern pointing to this, so it's a pretty good match *accuracyPtr = 100; @@ -205,9 +209,10 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa } } - if (candidatesByName.count() > 1) { + if (candidatesByName.m_allMatchingMimeTypes.count() > 1) { + candidatesByName.m_matchingMimeTypes.sort(); // make it deterministic *accuracyPtr = 20; - const QMimeType mime = mimeTypeForName(candidatesByName.at(0)); + const QMimeType mime = mimeTypeForName(candidatesByName.m_matchingMimeTypes.at(0)); if (mime.isValid()) return mime; } @@ -455,9 +460,7 @@ QList QMimeDatabase::mimeTypesForFileName(const QString &fileName) co QString QMimeDatabase::suffixForFileName(const QString &fileName) const { QMutexLocker locker(&d->mutex); - QString foundSuffix; - d->mimeTypeForFileName(fileName, &foundSuffix); - return foundSuffix; + return d->provider()->findByFileName(QFileInfo(fileName).fileName()).m_foundSuffix; } /*! diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h index 4ff5110a5b..3f63f5f103 100644 --- a/src/corelib/mimetypes/qmimedatabase_p.h +++ b/src/corelib/mimetypes/qmimedatabase_p.h @@ -90,7 +90,7 @@ public: QMimeType mimeTypeForName(const QString &nameOrAlias); QMimeType mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device, int *priorityPtr); QMimeType findByData(const QByteArray &data, int *priorityPtr); - QStringList mimeTypeForFileName(const QString &fileName, QString *foundSuffix = 0); + QStringList mimeTypeForFileName(const QString &fileName); mutable QMimeProviderBase *m_provider; const QString m_defaultMimeType; diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp index 568f9bf4de..a4d2b046fa 100644 --- a/src/corelib/mimetypes/qmimeglobpattern.cpp +++ b/src/corelib/mimetypes/qmimeglobpattern.cpp @@ -58,9 +58,13 @@ QT_BEGIN_NAMESPACE void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const QString &pattern) { - // Is this a lower-weight pattern than the last match? Skip this match then. - if (weight < m_weight) + if (m_allMatchingMimeTypes.contains(mimeType)) return; + // Is this a lower-weight pattern than the last match? Skip this match then. + if (weight < m_weight) { + m_allMatchingMimeTypes.append(mimeType); + return; + } bool replace = weight > m_weight; if (!replace) { // Compare the length of the match @@ -79,6 +83,7 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q } if (!m_matchingMimeTypes.contains(mimeType)) { m_matchingMimeTypes.append(mimeType); + m_allMatchingMimeTypes.append(mimeType); if (pattern.startsWith(QLatin1String("*."))) m_foundSuffix = pattern.mid(2); } @@ -201,35 +206,32 @@ void QMimeGlobPatternList::match(QMimeGlobMatchResult &result, } } -QStringList QMimeAllGlobPatterns::matchingGlobs(const QString &fileName, QString *foundSuffix) const +QMimeGlobMatchResult QMimeAllGlobPatterns::matchingGlobs(const QString &fileName) const { // First try the high weight matches (>50), if any. QMimeGlobMatchResult result; m_highWeightGlobs.match(result, fileName); - if (result.m_matchingMimeTypes.isEmpty()) { - // Now use the "fast patterns" dict, for simple *.foo patterns with weight 50 - // (which is most of them, so this optimization is definitely worth it) - const int lastDot = fileName.lastIndexOf(QLatin1Char('.')); - if (lastDot != -1) { // if no '.', skip the extension lookup - const int ext_len = fileName.length() - lastDot - 1; - const QString simpleExtension = fileName.right(ext_len).toLower(); - // (toLower because fast patterns are always case-insensitive and saved as lowercase) + // Now use the "fast patterns" dict, for simple *.foo patterns with weight 50 + // (which is most of them, so this optimization is definitely worth it) + const int lastDot = fileName.lastIndexOf(QLatin1Char('.')); + if (lastDot != -1) { // if no '.', skip the extension lookup + const int ext_len = fileName.length() - lastDot - 1; + const QString simpleExtension = fileName.right(ext_len).toLower(); + // (toLower because fast patterns are always case-insensitive and saved as lowercase) - const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension); - const QString simplePattern = QLatin1String("*.") + simpleExtension; - for (const QString &mime : matchingMimeTypes) - result.addMatch(mime, 50, simplePattern); - // Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway, - // at least those with weight 50. - } - - // Finally, try the low weight matches (<=50) - m_lowWeightGlobs.match(result, fileName); + const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension); + const QString simplePattern = QLatin1String("*.") + simpleExtension; + for (const QString &mime : matchingMimeTypes) + result.addMatch(mime, 50, simplePattern); + // Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway, + // at least those with weight 50. } - if (foundSuffix) - *foundSuffix = result.m_foundSuffix; - return result.m_matchingMimeTypes; + + // Finally, try the low weight matches (<=50) + m_lowWeightGlobs.match(result, fileName); + + return result; } void QMimeAllGlobPatterns::clear() diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index 3e4fdb50f6..c8b70464fd 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -68,7 +68,8 @@ struct QMimeGlobMatchResult void addMatch(const QString &mimeType, int weight, const QString &pattern); - QStringList m_matchingMimeTypes; + QStringList m_matchingMimeTypes; // only those with highest weight + QStringList m_allMatchingMimeTypes; int m_weight; int m_matchingPatternLength; QString m_foundSuffix; @@ -153,7 +154,7 @@ public: void addGlob(const QMimeGlobPattern &glob); void removeMimeType(const QString &mimeType); - QStringList matchingGlobs(const QString &fileName, QString *foundSuffix) const; + QMimeGlobMatchResult matchingGlobs(const QString &fileName) const; void clear(); PatternsMap m_fastPatterns; // example: "doc" -> "application/msword", "text/plain" diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index 65b011b439..959421bf52 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -287,13 +287,13 @@ QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name) return mimeTypeForNameUnchecked(name); } -QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString *foundSuffix) +QMimeGlobMatchResult QMimeBinaryProvider::findByFileName(const QString &fileName) { checkCache(); - if (fileName.isEmpty()) - return QStringList(); - const QString lowerFileName = fileName.toLower(); QMimeGlobMatchResult result; + if (fileName.isEmpty()) + return result; + const QString lowerFileName = fileName.toLower(); // TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly. for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) { matchGlobList(result, cacheFile, cacheFile->getUint32(PosLiteralListOffset), fileName); @@ -305,9 +305,7 @@ QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString if (result.m_matchingMimeTypes.isEmpty()) matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true); } - if (foundSuffix) - *foundSuffix = result.m_foundSuffix; - return result.m_matchingMimeTypes; + return result; } void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName) @@ -728,12 +726,11 @@ QMimeType QMimeXMLProvider::mimeTypeForName(const QString &name) return m_nameMimeTypeMap.value(name); } -QStringList QMimeXMLProvider::findByFileName(const QString &fileName, QString *foundSuffix) +QMimeGlobMatchResult QMimeXMLProvider::findByFileName(const QString &fileName) { ensureLoaded(); - const QStringList matchingMimeTypes = m_mimeTypeGlobs.matchingGlobs(fileName, foundSuffix); - return matchingMimeTypes; + return m_mimeTypeGlobs.matchingGlobs(fileName); } QMimeType QMimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr) diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h index e6fc47bf80..f410e62267 100644 --- a/src/corelib/mimetypes/qmimeprovider_p.h +++ b/src/corelib/mimetypes/qmimeprovider_p.h @@ -56,6 +56,7 @@ #ifndef QT_NO_MIMETYPE +#include "qmimeglobpattern_p.h" #include #include #include @@ -72,7 +73,7 @@ public: virtual bool isValid() = 0; virtual QMimeType mimeTypeForName(const QString &name) = 0; - virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix) = 0; + virtual QMimeGlobMatchResult findByFileName(const QString &fileName) = 0; virtual QStringList parents(const QString &mime) = 0; virtual QString resolveAlias(const QString &name) = 0; virtual QStringList listAliases(const QString &name) = 0; @@ -99,7 +100,7 @@ public: virtual bool isValid() Q_DECL_OVERRIDE; virtual QMimeType mimeTypeForName(const QString &name) Q_DECL_OVERRIDE; - virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix) Q_DECL_OVERRIDE; + virtual QMimeGlobMatchResult findByFileName(const QString &fileName) Q_DECL_OVERRIDE; virtual QStringList parents(const QString &mime) Q_DECL_OVERRIDE; virtual QString resolveAlias(const QString &name) Q_DECL_OVERRIDE; virtual QStringList listAliases(const QString &name) Q_DECL_OVERRIDE; @@ -142,7 +143,7 @@ public: virtual bool isValid() Q_DECL_OVERRIDE; virtual QMimeType mimeTypeForName(const QString &name) Q_DECL_OVERRIDE; - virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix) Q_DECL_OVERRIDE; + virtual QMimeGlobMatchResult findByFileName(const QString &fileName) Q_DECL_OVERRIDE; virtual QStringList parents(const QString &mime) Q_DECL_OVERRIDE; virtual QString resolveAlias(const QString &name) Q_DECL_OVERRIDE; virtual QStringList listAliases(const QString &name) Q_DECL_OVERRIDE; From 0f5687280ecb19bc0a16e86c3040b0229539a160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Tue, 27 Dec 2016 10:50:45 +0100 Subject: [PATCH 043/304] Fix typo in documentation Change-Id: I86584392f2646e87f26bf6de725802e5c6a6c6e0 Reviewed-by: Thiago Macieira --- src/network/kernel/qnetworkdatagram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/kernel/qnetworkdatagram.cpp b/src/network/kernel/qnetworkdatagram.cpp index ba8a063edf..88ca763187 100644 --- a/src/network/kernel/qnetworkdatagram.cpp +++ b/src/network/kernel/qnetworkdatagram.cpp @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE /*! \class QNetworkDatagram - \brief The QNetworkDatagram class provides the data and matadata of a UDP datagram. + \brief The QNetworkDatagram class provides the data and metadata of a UDP datagram. \since 5.8 \ingroup network \inmodule QtNetwork From b16e73804429af32ed4f536cbcd782ceb9cd3e8e Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Tue, 27 Dec 2016 00:46:05 +0200 Subject: [PATCH 044/304] Fix warning from MinGW/GCC 6.2 src/widgets/styles/qwindowsvistastyle.cpp: In member function 'virtual QSize QWindowsVistaStyle::sizeFromContents(QStyle::ContentsType, const QStyleOption*, const QSize&, const QWidget*) const': src/widgets/styles/qwindowsvistastyle.cpp:1872:9: error: this 'if' clause does not guard... [-Werror=misleading-indentation] if (!sz.isEmpty()) ^~ src/widgets/styles/qwindowsvistastyle.cpp:1874:13: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' return sz; Change-Id: Ifd3faef8c93f12d5fadaf4edf875fbe0fc6fb785 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qwindowsvistastyle.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 7759df9959..7f52d3d2f3 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1871,8 +1871,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption case CT_MenuBarItem: if (!sz.isEmpty()) sz += QSize(windowsItemHMargin * 5 + 1, 5); - return sz; - break; + return sz; #endif case CT_ItemViewItem: sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget); From dfaa32a9455f0449cf2a2d7b5d916f99d5119fdc Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Tue, 27 Dec 2016 07:47:30 +0200 Subject: [PATCH 045/304] windows: use lowercase #include MinGW's headers are lowercase, and MSVC is generally run on a case- insensitive file system. Including in the lowercase is the more compatible option. Change-Id: I288cecb77ddd8029bb3925e613a830dd9ce96a6c Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwin10helpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwin10helpers.cpp b/src/plugins/platforms/windows/qwin10helpers.cpp index 977bbfd11b..12cccd124b 100644 --- a/src/plugins/platforms/windows/qwin10helpers.cpp +++ b/src/plugins/platforms/windows/qwin10helpers.cpp @@ -57,7 +57,7 @@ #endif #ifdef HAS_UI_VIEW_SETTINGS_INTEROP -# include +# include #endif #ifndef HAS_UI_VIEW_SETTINGS_INTEROP From 2be9880ebb3864e6ed703d96c7db5a12a76fe7c3 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Wed, 28 Dec 2016 11:09:34 +0100 Subject: [PATCH 046/304] Removed random notes in the documentation that should not be there Two sentences that read like author notes likely added by accident. Task-number: QTBUG-56630 Change-Id: I7a0b114e128f95e54e9e8f26b43493f67747d650 Reviewed-by: Simon Hausmann --- src/corelib/kernel/qmetatype.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index f27fde6b8d..ef68878f68 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -207,8 +207,6 @@ struct DefinedTypesFilter { \enum QMetaType::Type These are the built-in types supported by QMetaType: - Read doc on QChar - Read doc on \l QChar \value Void \c void \value Bool \c bool From a89c39209721cb194131b2597733a4c235ab44d8 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Wed, 28 Dec 2016 11:29:16 +0100 Subject: [PATCH 047/304] Link QVariant class documentation to the Creating Custom Qt Types article The article does answer the questions asked in the bug. Task-number: QTBUG-56629 Change-Id: Ib8bac0acf45bc10598fc47feb6dd73005b5ad040 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 0ffc22d810..9476ab3f5b 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1186,7 +1186,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names \snippet code/src_corelib_kernel_qvariant.cpp 1 QVariant can be extended to support other types than those - mentioned in the \l Type enum. See the \l QMetaType documentation + mentioned in the \l Type enum. See \l{Creating Custom Qt Types}{Creating Custom Qt Types} for details. \section1 A Note on GUI Types From 69ce68cb899da31d96ce7b9337600ebdc910e024 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Dec 2016 10:02:26 -0200 Subject: [PATCH 048/304] Doc: add a quick note about unfixed Windows encoding bug Task-number: QTBUG-49640 Change-Id: Icb0289e3118a41dd9438fffd1492925b03de62d6 Reviewed-by: David Faure --- src/corelib/io/qlockfile.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp index ae3a7c6abc..cb1ff93ad3 100644 --- a/src/corelib/io/qlockfile.cpp +++ b/src/corelib/io/qlockfile.cpp @@ -84,6 +84,9 @@ QT_BEGIN_NAMESPACE For the use case of protecting a resource over a long time, you should therefore call setStaleLockTime(0), and when tryLock() returns LockFailedError, inform the user that the document is locked, possibly using getLockInfo() for more details. + + \note On Windows, this class has problems detecting a stale lock if the + machine's hostname contains characters outside the US-ASCII character set. */ /*! From 73dafaf265a6c6a51611a093c2cc81a6d61767a9 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 22 Dec 2016 15:12:28 +0300 Subject: [PATCH 049/304] xcb: Ignore XI2 LMB mouse events from touch screens 157ee01a8d0be9a4dbac03883c9eaf3609fc1172 was trying to minimize some side effects of the bug in the evdev driver (https://bugs.freedesktop.org/show_bug.cgi?id=98188) by not changing mouse button state on motion. Unfortunately it resurrected bugs that were fixed by 76de1ac0a4cd384f608a14b5d77a8cf3ef1ec868. Filter out mouse events from touch screens instead. This change reverts 157ee01a8d0be9a4dbac03883c9eaf3609fc1172. Task-number: QTBUG-32609 Task-number: QTBUG-35065 Task-number: QTBUG-43776 Task-number: QTBUG-44166 Task-number: QTBUG-44231 Task-number: QTBUG-56156 Change-Id: Ie17710d94beabeb08681d669a9d8309be9b44e73 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.h | 1 + .../platforms/xcb/qxcbconnection_xi2.cpp | 7 ++++ src/plugins/platforms/xcb/qxcbwindow.cpp | 32 +++++++++---------- src/plugins/platforms/xcb/qxcbwindow.h | 1 - 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 60f0f487c5..a9208ffe09 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -517,6 +517,7 @@ public: #ifdef XCB_USE_XINPUT22 bool xi2MouseEvents() const; + bool isTouchScreen(int id) const; #endif protected: diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 0ace79a4f5..f4f56f25f1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1025,6 +1025,13 @@ Qt::MouseButton QXcbConnection::xiToQtMouseButton(uint32_t b) return Qt::NoButton; } +bool QXcbConnection::isTouchScreen(int id) const +{ + auto device = m_touchDevices.value(id); + return device && device->qtTouchDevice + && device->qtTouchDevice->type() == QTouchDevice::TouchScreen; +} + static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { // keep in sync with wacom_intuos_inout() in Linux kernel driver wacom_wac.c switch (toolId) { diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index ff01fa019e..3204fab197 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2423,22 +2423,27 @@ static inline int fixed1616ToInt(FP1616 val) return int((qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF); } -void QXcbWindow::handleXIMouseButtonState(const xcb_ge_event_t *event) -{ - QXcbConnection *conn = connection(); - const xXIDeviceEvent *ev = reinterpret_cast(event); - if (ev->buttons_len > 0) { - unsigned char *buttonMask = (unsigned char *) &ev[1]; - for (int i = 1; i <= 15; ++i) - conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i)); - } -} - // With XI 2.2+ press/release/motion comes here instead of the above handlers. void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source) { QXcbConnection *conn = connection(); xXIDeviceEvent *ev = reinterpret_cast(event); + + if (ev->buttons_len > 0) { + unsigned char *buttonMask = (unsigned char *) &ev[1]; + // There is a bug in the evdev driver which leads to receiving mouse events without + // XIPointerEmulated being set: https://bugs.freedesktop.org/show_bug.cgi?id=98188 + // Filter them out by other attributes: when their source device is a touch screen + // and the LMB is pressed. + if (XIMaskIsSet(buttonMask, 1) && conn->isTouchScreen(ev->sourceid)) { + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInput, "XI2 mouse event from touch device %d was ignored", ev->sourceid); + return; + } + for (int i = 1; i <= 15; ++i) + conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i)); + } + const Qt::KeyboardModifiers modifiers = conn->keyboard()->translateModifiers(ev->mods.effective_mods); const int event_x = fixed1616ToInt(ev->event_x); const int event_y = fixed1616ToInt(ev->event_y); @@ -2458,23 +2463,18 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource switch (ev->evtype) { case XI_ButtonPress: - handleXIMouseButtonState(event); if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, true); handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_ButtonRelease: - handleXIMouseButtonState(event); if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, false); handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_Motion: - // Here we do NOT call handleXIMouseButtonState because we don't expect button state change to be bundled with motion. - // When a touchscreen is pressed, an XI_Motion event occurs in which XIMaskIsSet says the left button is pressed, - // but we don't want QGuiApplicationPrivate::processMouseEvent() to react by generating a mouse press event. if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName); handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source); diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 089df8f3f6..cfa4964151 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -139,7 +139,6 @@ public: void handleFocusOutEvent(const xcb_focus_out_event_t *event) override; void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) override; #ifdef XCB_USE_XINPUT22 - void handleXIMouseButtonState(const xcb_ge_event_t *); void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) override; void handleXIEnterLeave(xcb_ge_event_t *) override; #endif From 77a8e90cddcfa1c34518ef846a4838874a7bc0c7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 29 Dec 2016 18:15:53 +0100 Subject: [PATCH 050/304] QHeaderView: fix restoreState() on a model with more columns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When saving state for a 3-columns headerview and then restoring that state onto a 5-column headerview, the headerview shouldn't suddenly think it has 3 columns. Rather than making restoreState() fail, we adjust for the additional columns, so that we can still apply the customizations from the user to all other columns (hiding, moving, etc.). Change-Id: I3f220aa322ea8b629d2fe345f8cde13e0ea615d6 Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qheaderview.cpp | 14 ++++ .../itemviews/qheaderview/tst_qheaderview.cpp | 84 ++++++++++++++++--- 2 files changed, 87 insertions(+), 11 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 837383f016..1310a060ea 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3857,6 +3857,20 @@ bool QHeaderViewPrivate::read(QDataStream &in) if (sectionItemsLengthTotal != lengthIn) return false; + const int currentCount = (orient == Qt::Horizontal ? model->columnCount(root) : model->rowCount(root)); + if (newSectionItems.count() < currentCount) { + // we have sections not in the saved state, give them default settings + for (int i = newSectionItems.count(); i < currentCount; ++i) { + visualIndicesIn.append(i); + logicalIndicesIn.append(i); + } + const int insertCount = currentCount - newSectionItems.count(); + const int insertLength = defaultSectionSizeIn * insertCount; + lengthIn += insertLength; + SectionItem section(defaultSectionSizeIn, globalResizeMode); + newSectionItems.insert(newSectionItems.count(), insertCount, section); // append + } + orientation = static_cast(orient); sortIndicatorOrder = static_cast(order); sortIndicatorSection = sortIndicatorSectionIn; diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 32a324b888..1078dcc2e9 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -169,6 +169,9 @@ private slots: void moveSectionAndReset(); void moveSectionAndRemove(); void saveRestore(); + void restoreQt4State(); + void restoreToMoreColumns(); + void restoreBeforeSetModel(); void defaultSectionSizeTest(); void defaultSectionSizeTestStyles(); @@ -1523,11 +1526,11 @@ public: { return hasIndex(row, column, parent) ? createIndex(row, column) : QModelIndex(); } - int rowCount(const QModelIndex & /* parent */) const + int rowCount(const QModelIndex & /*parent*/ = QModelIndex()) const { return 8; } - int columnCount(const QModelIndex &/*parent= QModelIndex()*/) const + int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return m_col_count; } @@ -1588,41 +1591,56 @@ void tst_QHeaderView::moveSectionAndRemove() QCOMPARE(v.count(), 0); } -void tst_QHeaderView::saveRestore() +static QByteArray savedState() { - SimpleModel m; + QStandardItemModel m(4, 4); QHeaderView h1(Qt::Horizontal); h1.setModel(&m); h1.swapSections(0, 2); h1.resizeSection(1, 10); h1.setSortIndicatorShown(true); - h1.setSortIndicator(1,Qt::DescendingOrder); - QByteArray s1 = h1.saveState(); + h1.setSortIndicator(2, Qt::DescendingOrder); + h1.setSectionHidden(3, true); + return h1.saveState(); +} + +void tst_QHeaderView::saveRestore() +{ + QStandardItemModel m(4, 4); + const QByteArray s1 = savedState(); QHeaderView h2(Qt::Vertical); QSignalSpy spy(&h2, SIGNAL(sortIndicatorChanged(int,Qt::SortOrder))); h2.setModel(&m); - h2.restoreState(s1); + QVERIFY(h2.restoreState(s1)); QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).at(0).toInt(), 1); + QCOMPARE(spy.at(0).at(0).toInt(), 2); QCOMPARE(h2.logicalIndex(0), 2); QCOMPARE(h2.logicalIndex(2), 0); QCOMPARE(h2.sectionSize(1), 10); - QCOMPARE(h2.sortIndicatorSection(), 1); + QCOMPARE(h2.sortIndicatorSection(), 2); QCOMPARE(h2.sortIndicatorOrder(), Qt::DescendingOrder); QCOMPARE(h2.isSortIndicatorShown(), true); + QVERIFY(!h2.isSectionHidden(2)); + QVERIFY(h2.isSectionHidden(3)); + QCOMPARE(h2.hiddenSectionCount(), 1); QByteArray s2 = h2.saveState(); - QCOMPARE(s1, s2); - QVERIFY(!h2.restoreState(QByteArrayLiteral("Garbage"))); + QVERIFY(!h2.restoreState(QByteArrayLiteral("Garbage"))); +} + +void tst_QHeaderView::restoreQt4State() +{ // QTBUG-40462 // Setting from Qt4, where information about multiple sections were grouped together in one // sectionItem object + QStandardItemModel m(4, 10); + QHeaderView h2(Qt::Vertical); QByteArray settings_qt4 = QByteArray::fromHex("000000ff00000000000000010000000100000000010000000000000000000000000000" "0000000003e80000000a0101000100000000000000000000000064ffffffff00000081" @@ -1652,6 +1670,50 @@ void tst_QHeaderView::saveRestore() QCOMPARE(h2.saveState(), old_state); } +void tst_QHeaderView::restoreToMoreColumns() +{ + // Restore state onto a model with more columns + const QByteArray s1 = savedState(); + QHeaderView h4(Qt::Horizontal); + QStandardItemModel fiveColumnsModel(1, 5); + h4.setModel(&fiveColumnsModel); + QCOMPARE(fiveColumnsModel.columnCount(), 5); + QCOMPARE(h4.count(), 5); + QVERIFY(h4.restoreState(s1)); + QCOMPARE(fiveColumnsModel.columnCount(), 5); + QCOMPARE(h4.count(), 5); + QCOMPARE(h4.sectionSize(1), 10); + for (int i = 0; i < h4.count(); ++i) + QVERIFY(h4.sectionSize(i) > 0 || h4.isSectionHidden(i)); + QVERIFY(!h4.isSectionHidden(2)); + QVERIFY(h4.isSectionHidden(3)); + QCOMPARE(h4.hiddenSectionCount(), 1); + QCOMPARE(h4.sortIndicatorSection(), 2); + QCOMPARE(h4.sortIndicatorOrder(), Qt::DescendingOrder); +} + +void tst_QHeaderView::restoreBeforeSetModel() +{ + QHeaderView h2(Qt::Horizontal); + const QByteArray s1 = savedState(); + // First restore + QVERIFY(h2.restoreState(s1)); + // Then setModel + QStandardItemModel model(4, 4); + h2.setModel(&model); + + // Check the result + QCOMPARE(h2.logicalIndex(0), 2); + QCOMPARE(h2.logicalIndex(2), 0); + QCOMPARE(h2.sectionSize(1), 10); + QCOMPARE(h2.sortIndicatorSection(), 2); + QCOMPARE(h2.sortIndicatorOrder(), Qt::DescendingOrder); + QCOMPARE(h2.isSortIndicatorShown(), true); + QVERIFY(!h2.isSectionHidden(2)); + QVERIFY(h2.isSectionHidden(3)); + QCOMPARE(h2.hiddenSectionCount(), 1); +} + void tst_QHeaderView::defaultSectionSizeTest() { // Setup From 612f1f4668b029c41e4bac1038d42f4899740dd4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 15 Dec 2016 16:03:14 +0100 Subject: [PATCH 051/304] centralize QMAKE_COMPILER_DEFINES+=_WIN32 also for winrt specs this is mostly for appearances (as evidenced by everything working despite it being missing from some specs), as the variable is just a fallback for moc.prf's automatic detection. Change-Id: Ie4af24c02ec03aaa1810281d1bb6876ea38cedf8 Reviewed-by: Jake Petroules --- mkspecs/common/winrt_winphone/qmake.conf | 1 + mkspecs/winrt-x64-msvc2015/qmake.conf | 1 - mkspecs/winrt-x86-msvc2013/qmake.conf | 1 - mkspecs/winrt-x86-msvc2015/qmake.conf | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/mkspecs/common/winrt_winphone/qmake.conf b/mkspecs/common/winrt_winphone/qmake.conf index 27269176d0..5f87dc0be1 100644 --- a/mkspecs/common/winrt_winphone/qmake.conf +++ b/mkspecs/common/winrt_winphone/qmake.conf @@ -11,6 +11,7 @@ QMAKE_COMPILER = msvc QMAKE_PLATFORM = winrt win32 CONFIG = package_manifest $$CONFIG incremental flat precompile_header autogen_precompile_source debug_and_release debug_and_release_target rtti DEFINES += UNICODE WIN32 QT_LARGEFILE_SUPPORT Q_BYTE_ORDER=Q_LITTLE_ENDIAN +QMAKE_COMPILER_DEFINES += _WIN32 DEPLOYMENT_PLUGIN += qwinrt diff --git a/mkspecs/winrt-x64-msvc2015/qmake.conf b/mkspecs/winrt-x64-msvc2015/qmake.conf index d7e2fcf3c2..d503399e3c 100644 --- a/mkspecs/winrt-x64-msvc2015/qmake.conf +++ b/mkspecs/winrt-x64-msvc2015/qmake.conf @@ -5,7 +5,6 @@ # include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _WIN32 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X64 __X64__ __x64__ QMAKE_CFLAGS += -FS diff --git a/mkspecs/winrt-x86-msvc2013/qmake.conf b/mkspecs/winrt-x86-msvc2013/qmake.conf index cc125d3f0c..ae1d675b88 100644 --- a/mkspecs/winrt-x86-msvc2013/qmake.conf +++ b/mkspecs/winrt-x86-msvc2013/qmake.conf @@ -5,7 +5,6 @@ # include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _WIN32 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP X86 __X86__ __x86__ QMAKE_CFLAGS += -FS diff --git a/mkspecs/winrt-x86-msvc2015/qmake.conf b/mkspecs/winrt-x86-msvc2015/qmake.conf index 0983174ae2..37ce0e5525 100644 --- a/mkspecs/winrt-x86-msvc2015/qmake.conf +++ b/mkspecs/winrt-x86-msvc2015/qmake.conf @@ -5,7 +5,6 @@ # include(../common/winrt_winphone/qmake.conf) -QMAKE_COMPILER_DEFINES += _WIN32 DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X86 __X86__ __x86__ QMAKE_CFLAGS += -FS From bbf7fa136824f87259acd9d8954160e5e1fe8358 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 15:12:04 +0100 Subject: [PATCH 052/304] remove pointless conditionals uikit already implies !host_build, as host builds are executed with the host spec. and the only darwin alternative to uikit is macos. Change-Id: I6b47d68bad5d4427640901ff1e32dacf9a4e352b Reviewed-by: Jake Petroules --- mkspecs/features/mac/sdk.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf index 16a46a362c..654d487600 100644 --- a/mkspecs/features/mac/sdk.prf +++ b/mkspecs/features/mac/sdk.prf @@ -49,7 +49,7 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_ } !equals(MAKEFILE_GENERATOR, XCODE) { - uikit:!host_build { + uikit { ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET @@ -109,7 +109,7 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_ QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT} - } else: osx { + } else { version_identifier = macosx deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET version_min_flag = -m$${version_identifier}-version-min=$$deployment_target From afd82630c2da4369b95baf9930e3d00dce309d63 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 15:08:39 +0100 Subject: [PATCH 053/304] delay resolution of darwin deployment target and architectures there appears to be no particular reason why this ended up in sdk.prf, and it has become an actual problem now that the sdk is resolved from default_pre.prf already, making it impossible for projects to override the deployment target. Task-number: QTBUG-56965 Change-Id: I8e319d10cdfb95acc1da1f431c8b8d4f76d1168e Reviewed-by: Jake Petroules --- mkspecs/features/mac/default_post.prf | 85 +++++++++++++++++++++++++-- mkspecs/features/mac/sdk.prf | 75 ----------------------- 2 files changed, 80 insertions(+), 80 deletions(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 99c92d15f0..51b6e87fea 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -24,11 +24,86 @@ qt { } } -macx-xcode:!isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) { - debug_information_format.name = DEBUG_INFORMATION_FORMAT - debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT - debug_information_format.build = debug - QMAKE_MAC_XCODE_SETTINGS += debug_information_format +macx-xcode { + !isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) { + debug_information_format.name = DEBUG_INFORMATION_FORMAT + debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT + debug_information_format.build = debug + QMAKE_MAC_XCODE_SETTINGS += debug_information_format + } +} else { + uikit { + ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET + tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET + watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET + + device|!simulator: device_archs = $$QMAKE_APPLE_DEVICE_ARCHS + simulator: simulator_archs = $$QMAKE_APPLE_SIMULATOR_ARCHS + archs = $$device_archs $$simulator_archs + + isEmpty(archs): \ + error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture") + + QMAKE_XARCH_CFLAGS = + QMAKE_XARCH_LFLAGS = + QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS + + single_arch { + device_archs = $$first(device_archs) + simulator_archs = $$first(simulator_archs) + archs = $$first(archs) + } + + for (arch, archs) { + contains(simulator_archs, $$arch) { + sdk = $$simulator.sdk + version_identifier = $$simulator.deployment_identifier + } else { + sdk = $$device.sdk + version_identifier = $$device.deployment_identifier + } + + version_min_flags = \ + -Xarch_$${arch} \ + -m$${version_identifier}-version-min=$$deployment_target + QMAKE_XARCH_CFLAGS_$${arch} = $$version_min_flags \ + -Xarch_$${arch} \ + -isysroot$$xcodeSDKInfo(Path, $$sdk) + QMAKE_XARCH_LFLAGS_$${arch} = $$version_min_flags \ + -Xarch_$${arch} \ + -Wl,-syslibroot,$$xcodeSDKInfo(Path, $$sdk) + + QMAKE_XARCH_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch}) + QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS_$${arch}) + + QMAKE_EXTRA_VARIABLES += \ + QMAKE_XARCH_CFLAGS_$${arch} \ + QMAKE_XARCH_LFLAGS_$${arch} + } + + QMAKE_CFLAGS_USE_PRECOMPILE = + for (arch, archs) { + QMAKE_CFLAGS_USE_PRECOMPILE += \ + -Xarch_$${arch} \ + -include${QMAKE_PCH_OUTPUT_$${arch}} + } + QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + + QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT} + } else { + version_identifier = macosx + deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET + version_min_flag = -m$${version_identifier}-version-min=$$deployment_target + QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag + QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag + QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag + } + + QMAKE_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS) + QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS) + QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS) } cache(QMAKE_XCODE_DEVELOPER_PATH, stash) diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf index 654d487600..68ab7e4053 100644 --- a/mkspecs/features/mac/sdk.prf +++ b/mkspecs/features/mac/sdk.prf @@ -47,78 +47,3 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_ $$tool = $$sysrooted $$member(value, 1, -1) cache($$tool_variable, set stash, $$tool) } - -!equals(MAKEFILE_GENERATOR, XCODE) { - uikit { - ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET - tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET - watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET - - device|!simulator: device_archs = $$QMAKE_APPLE_DEVICE_ARCHS - simulator: simulator_archs = $$QMAKE_APPLE_SIMULATOR_ARCHS - archs = $$device_archs $$simulator_archs - - isEmpty(archs): \ - error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture") - - QMAKE_XARCH_CFLAGS = - QMAKE_XARCH_LFLAGS = - QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS - - single_arch { - device_archs = $$first(device_archs) - simulator_archs = $$first(simulator_archs) - archs = $$first(archs) - } - - for(arch, archs) { - contains(simulator_archs, $$arch) { - sdk = $$simulator.sdk - version_identifier = $$simulator.deployment_identifier - } else { - sdk = $$device.sdk - version_identifier = $$device.deployment_identifier - } - - version_min_flags = \ - -Xarch_$${arch} \ - -m$${version_identifier}-version-min=$$deployment_target - QMAKE_XARCH_CFLAGS_$${arch} = $$version_min_flags \ - -Xarch_$${arch} \ - -isysroot$$xcodeSDKInfo(Path, $$sdk) - QMAKE_XARCH_LFLAGS_$${arch} = $$version_min_flags \ - -Xarch_$${arch} \ - -Wl,-syslibroot,$$xcodeSDKInfo(Path, $$sdk) - - QMAKE_XARCH_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch}) - QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS_$${arch}) - - QMAKE_EXTRA_VARIABLES += \ - QMAKE_XARCH_CFLAGS_$${arch} \ - QMAKE_XARCH_LFLAGS_$${arch} - } - - QMAKE_CFLAGS_USE_PRECOMPILE = - for(arch, archs) { - QMAKE_CFLAGS_USE_PRECOMPILE += \ - -Xarch_$${arch} \ - -include${QMAKE_PCH_OUTPUT_$${arch}} - } - QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE - QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE - QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE - - QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT} - } else { - version_identifier = macosx - deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET - version_min_flag = -m$${version_identifier}-version-min=$$deployment_target - QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag - QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag - QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag - } - - QMAKE_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS) - QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS) - QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS) -} From b5c809eb96cc1348cee6083e7141fb1c505943f6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 15:18:31 +0100 Subject: [PATCH 054/304] remove redundant arch list truncation in single_arch case beyond this point, simulator_archs is only used to determine from which one of the lists the remaining arch came from (and device_archs is actually never used again). the lists are assumed to be mutually exclusive, so truncating them won't affect in which of them the first element of their concatenation is found. Change-Id: I4736ed7e51f6623efa6bd37892ab1fcf8c83ae8b Reviewed-by: Jake Petroules --- mkspecs/features/mac/default_post.prf | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 51b6e87fea..2ac4262129 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -48,11 +48,7 @@ macx-xcode { QMAKE_XARCH_LFLAGS = QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS - single_arch { - device_archs = $$first(device_archs) - simulator_archs = $$first(simulator_archs) - archs = $$first(archs) - } + single_arch: archs = $$first(archs) for (arch, archs) { contains(simulator_archs, $$arch) { From 70a72768409a89e770e1279cfb3e8b59df21a11c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 15:36:19 +0100 Subject: [PATCH 055/304] de-duplicate {mac,uikit}/default_post.prf re valid architectures Change-Id: Ie9d5a35a7f8578a2588ec004aab086d74986b0eb Reviewed-by: Jake Petroules --- mkspecs/features/mac/default_post.prf | 17 +++++++++-------- mkspecs/features/uikit/default_post.prf | 9 --------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 2ac4262129..d93c6ed27c 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -37,21 +37,22 @@ macx-xcode { tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET - device|!simulator: device_archs = $$QMAKE_APPLE_DEVICE_ARCHS - simulator: simulator_archs = $$QMAKE_APPLE_SIMULATOR_ARCHS - archs = $$device_archs $$simulator_archs + device|!simulator: VALID_DEVICE_ARCHS = $$QMAKE_APPLE_DEVICE_ARCHS + simulator: VALID_SIMULATOR_ARCHS = $$QMAKE_APPLE_SIMULATOR_ARCHS + # Note: uikit/default_post.prf relies on this variable as well. + VALID_ARCHS = $$VALID_DEVICE_ARCHS $$VALID_SIMULATOR_ARCHS - isEmpty(archs): \ + isEmpty(VALID_ARCHS): \ error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture") QMAKE_XARCH_CFLAGS = QMAKE_XARCH_LFLAGS = QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS - single_arch: archs = $$first(archs) + single_arch: VALID_ARCHS = $$first(VALID_ARCHS) - for (arch, archs) { - contains(simulator_archs, $$arch) { + for (arch, VALID_ARCHS) { + contains(VALID_SIMULATOR_ARCHS, $$arch) { sdk = $$simulator.sdk version_identifier = $$simulator.deployment_identifier } else { @@ -78,7 +79,7 @@ macx-xcode { } QMAKE_CFLAGS_USE_PRECOMPILE = - for (arch, archs) { + for (arch, VALID_ARCHS) { QMAKE_CFLAGS_USE_PRECOMPILE += \ -Xarch_$${arch} \ -include${QMAKE_PCH_OUTPUT_$${arch}} diff --git a/mkspecs/features/uikit/default_post.prf b/mkspecs/features/uikit/default_post.prf index 6e23e23a6a..dc4effd7f1 100644 --- a/mkspecs/features/uikit/default_post.prf +++ b/mkspecs/features/uikit/default_post.prf @@ -68,15 +68,6 @@ macx-xcode { only_active_arch.build = debug QMAKE_MAC_XCODE_SETTINGS += only_active_arch } else { - VALID_ARCHS = - device|!simulator: VALID_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS - simulator: VALID_ARCHS += $$QMAKE_APPLE_SIMULATOR_ARCHS - - isEmpty(VALID_ARCHS): \ - error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture") - - single_arch: VALID_ARCHS = $$first(VALID_ARCHS) - ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS)) ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ACTIVE_ARCHS), $(EXPORT_ACTIVE_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch)) From 8292326f1bc986f8d87b9f3c244a5e0eb06563f9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 15:48:54 +0100 Subject: [PATCH 056/304] configure: make library sources fail more verbosely log a message in all unsuccessful exit paths. Task-number: QTBUG-57217 Change-Id: I8b0f2685d327da583c3e42c8149327e05b2a66cc Reviewed-by: Lars Knoll --- mkspecs/features/qt_configure.prf | 13 +++++++++---- src/network/configure.pri | 1 + src/sql/configure.pri | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 41bd75c45d..c20a9672e4 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -503,12 +503,16 @@ defineTest(qtConfLibrary_makeSpec) { # the library is found via pkg-config. defineTest(qtConfLibrary_pkgConfig) { pkg_config = $$qtConfPkgConfig($$eval($${1}.host)) - isEmpty(pkg_config): \ + isEmpty(pkg_config) { + qtLog("pkg-config use disabled globally.") return(false) + } args = $$qtConfPrepareArgs($$eval($${1}.args)) - !qtConfPkgConfigPackageExists($$pkg_config, $$args): \ + !qtConfPkgConfigPackageExists($$pkg_config, $$args) { + qtLog("pkg-config did not find package.") return(false) + } qtRunLoggedCommand("$$pkg_config --modversion $$args", version)|return(false) qtRunLoggedCommand("$$pkg_config --libs-only-L --libs-only-l $$args", $${1}.libs)|return(false) @@ -619,8 +623,9 @@ defineTest(qtConfHandleLibrary) { qtLog("Trying source $$s (type $$t) of library $${1} ...") - !$$qtConfEvaluate($$eval($${spfx}.condition)) { - qtLog(" => source failed condition.") + cond = $$eval($${spfx}.condition) + !$$qtConfEvaluate($$cond) { + qtLog(" => source failed condition '$$cond'.") next() } diff --git a/src/network/configure.pri b/src/network/configure.pri index 57568902e4..f87b7f635f 100644 --- a/src/network/configure.pri +++ b/src/network/configure.pri @@ -7,6 +7,7 @@ defineTest(qtConfLibrary_openssl) { export($${1}.libs) return(true) } + qtLog("$OPENSSL_LIBS is not set.") return(false) } diff --git a/src/sql/configure.pri b/src/sql/configure.pri index 62d56e2186..a8bc09e524 100644 --- a/src/sql/configure.pri +++ b/src/sql/configure.pri @@ -26,6 +26,7 @@ defineTest(qtConfLibrary_psqlConfig) { export($${1}.includedir) return(true) } + qtLog("pg_config not found.") return(false) } @@ -74,6 +75,7 @@ defineTest(qtConfLibrary_mysqlConfig) { export($${1}.includedir) return(true) } + qtLog("mysql_config not found.") return(false) } From 7549bbbacbdadacb283ae73ccb8b415a3dbe0c7c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 16:26:50 +0100 Subject: [PATCH 057/304] fail early after command line parsing error we don't want to do the (possibly interactive) license check when the command line is not valid. Task-number: QTBUG-18459 Change-Id: I68c3b7ed4646e49865922ab5612f971930698356 Reviewed-by: Lars Knoll --- mkspecs/features/qt_configure.prf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index c20a9672e4..e8bddbf09f 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1772,6 +1772,7 @@ for (currentConfig, allConfigs): \ QMAKE_SAVED_ARGS = $$QMAKE_EXTRA_ARGS QMAKE_REDO_CONFIG = false qtConfParseCommandLine() +qtConfCheckErrors() for (currentConfig, allConfigs) { qtConfSetModuleName() From 7af6e9bbe6572dc7b692e5896d01e944ce63fa16 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 20:34:38 +0100 Subject: [PATCH 058/304] print help from all modules in top-level builds this is rather hacky. a proper solution would auto-generate help from the command line argument definitions, at the cost of needing to bootstrap qmake first. Change-Id: Iada6e25d5b31d7db0595309887f2d13295bbc1e3 Reviewed-by: Lars Knoll --- configure | 10 ++++++++++ configure.bat | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/configure b/configure index 82df73fb1b..7df10cec6a 100755 --- a/configure +++ b/configure @@ -522,6 +522,16 @@ done if [ "$OPT_HELP" = "yes" ]; then cat $relpath/config_help.txt + if [ -n "$CFG_TOPLEVEL" ]; then + IFS=' +' + for i in $relpathMangled/qt*/config_help.txt; do + if [ x"$i" != x"$relpath/config_help.txt" ]; then + echo + cat "$i" + fi + done + fi exit 0 fi diff --git a/configure.bat b/configure.bat index a5968e2ec7..c5daabfa65 100644 --- a/configure.bat +++ b/configure.bat @@ -84,6 +84,16 @@ goto doneargs :help type %QTSRC%\config_help.txt + if %TOPLEVEL% == true ( + for /d %%p in ("%TOPQTSRC%"\qt*) do ( + if not "%%p" == "%QTSRC%" ( + if exist "%%p\config_help.txt" ( + echo. + type "%%p\config_help.txt" + ) + ) + ) + ) exit /b 1 :redo From 47784b4352351f042d1e3b61e7151cdcc7c0bac1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 23 Dec 2016 21:11:40 +0100 Subject: [PATCH 059/304] re-introduce config.summary Task-number: QTBUG-56225 Change-Id: I954cc1055ab0168c06b6618d02b06f63b4122add Reviewed-by: Lars Knoll --- mkspecs/features/qt_configure.prf | 36 +++++++++++-------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index e8bddbf09f..ca66862abc 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1368,33 +1368,21 @@ defineTest(qtConfCreateSummary) { } defineTest(qtConfPrintReport) { - for (n, QT_CONFIGURE_REPORT): \ - logn($$n) - logn() - - for (n, QT_CONFIGURE_NOTES) { - logn($$n) - logn() - } - - for (w, QT_CONFIGURE_WARNINGS) { - logn($$w) - logn() - } + blocks = \ + "$$join(QT_CONFIGURE_REPORT, $$escape_expand(\\n))" \ + "$$join(QT_CONFIGURE_NOTES, $$escape_expand(\\n\\n))" \ + "$$join(QT_CONFIGURE_WARNINGS, $$escape_expand(\\n\\n))" !isEmpty(QT_CONFIGURE_ERRORS) { - for (e, QT_CONFIGURE_ERRORS) { - logn($$e) - logn() - } - mention_config_log:!$$QMAKE_CONFIG_VERBOSE { - logn("Check config.log for details.") - logn() - } - - !equals(config.input.continue, yes): \ - error() + blocks += "$$join(QT_CONFIGURE_ERRORS, $$escape_expand(\\n\\n))" + mention_config_log:!$$QMAKE_CONFIG_VERBOSE: \ + blocks += "Check config.log for details." } + blocks = "$$join(blocks, $$escape_expand(\\n\\n))" + logn($$blocks) + !isEmpty(QT_CONFIGURE_ERRORS):!equals(config.input.continue, yes): \ + error() + write_file($$OUT_PWD/config.summary, blocks)|error() } defineTest(qtConfCheckErrors) { From b29b9041b5109eb908ce5a7829b6c9c3182febb7 Mon Sep 17 00:00:00 2001 From: Jani Heikkinen Date: Wed, 30 Nov 2016 15:12:33 +0200 Subject: [PATCH 060/304] Add changes file for 5.8.0 Change-Id: Ie1185b165fc706f3fcc87014d4eefd1e2c6fb771 Done-with: Oswald Buddenhagen Done-with: Thiago Maciiera Reviewed-by: Kai Koehne Reviewed-by: Shawn Rutledge Reviewed-by: Lars Knoll --- dist/changes-5.8.0 | 497 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 497 insertions(+) create mode 100644 dist/changes-5.8.0 diff --git a/dist/changes-5.8.0 b/dist/changes-5.8.0 new file mode 100644 index 0000000000..8d93863087 --- /dev/null +++ b/dist/changes-5.8.0 @@ -0,0 +1,497 @@ +Qt 5.8 introduces many new features and improvements as well as bugfixes +over the 5.7.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://doc.qt.io/qt-5/index.html + +The Qt version 5.8 series is binary compatible with the 5.7.x series. +Applications compiled for 5.7 will continue to run with 5.8. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +This release contains all fixes included in the Qt 5.7.1 release. + +**************************************************************************** +* License Changes * +**************************************************************************** + + Static libraries that are linked into executables (winmain and + qopenglextensions) are now licensed under BSD _and_ commercial licenses. + +**************************************************************************** +* Deprecation Notice * +**************************************************************************** + + - The following platforms or toolchains are deprecated and will be + removed as of Qt 5.9: + * Apple OS X Mavericks (v10.9) + * Apple iOS 7.x + + Deprecated platforms and toolchains continue to work until removed. + + - The Q_OBJECT_CHECK macro is deprecated and will be removed in Qt 6. The + internal, template function qt_check_for_QOBJECT_macro that it created in + QObject-derived classes will be removed in Qt 5.9. + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + + - Support for the following platforms was removed in this version: + * Apple OS X Mountain Lion (v10.8) + * Apple iOS 6.x + +configure & build system +------------------------ + + - The configuration system has been rewritten almost from scratch. This + improved the consistency between builds on Unix and Windows, but some + subtle unintended behavior changes are also possible. Also, some + obsolete options have been entirely removed and will now cause errors. + - It is not permissible any more to manually #define QT_NO_ + anywhere. Instead, configure's -no-feature-* options must be used. + Note that this does not apply to defines which modify behavior rather + than entirely removing features. + - Configure test results are now cached. Use -recheck or -recheck-all + to discard them. + - [QTBUG-32530][QTBUG-42962] The Unix configure won't pick up CFLAGS and + related environment variables any more. Instead, it now accepts QMAKE_* + variable assignments on the command line. + - [QTBUG-52266] Configure won't pick up QMAKESPEC from the environment + any more. Use the -platform option instead. + - Device and simulator libraries are now combined on Apple device + platforms (iOS). This means that there will no longer be any + *_simulator.a libraries and the simulator architectures will simply + reside alongside the device architectures in a single Mach-O file. + - [Darwin] Project files may not override QMAKE_MAC_SDK any more. + +QtCore +------ + + - qFatal will now use std::abort to terminate the application on all + operating systems. Previously, ::abort() or ::exit(1) were called, + depending on the operating system. + - QLibraryInfo::licensee()/licensedProducts() were deprecated and + return empty strings now. + - Destroying a QThread which is still running will now result in + immediate and abnormal program termination. + +QtGui +----- + + - [QTBUG-54936] QFont::toString() and QFont::key() were modified to save + the font's style name if one is set, invalidating any stored font + identifiers. QFont::fromString() was also adjusted to accommodate the + change. + +QtNetwork +--------- + + - Proxies from system settings will now be used by default. Configure + with -no-system-proxies to disable. + - [QTBUG-53649] libproxy is now turned off by default. Configure with + -libproxy in order to enable it again. + +**************************************************************************** +* Library * +**************************************************************************** + +QtCore +------ + + - Disambiguated the relational operators comparing QByteArray with + QStringRef (and vice versa). + - Added qHash() overloads for QHash, QMultiHash. + - Added QDeadlineTimer, a counterpart to QElapsedTimer, used to mark a + time point in the future (a deadline) and determine whether such a + deadline has passed. + - Qt now relies on type traits from the C++11 standard library. + - [QTBUG-54981] Added Q_NAMESPACE, which can be used to add Q_ENUM_NS/ + Q_ENUMS, Q_FLAG_NS/Q_FLAGS and Q_CLASSINFO to a namespace. + - Q_IS_ENUM was deprecated. Use std::is_enum<>::value instead. + + - QChar: + * Added missing operator{<,>,<=,>=} comparing against QLatin1String and + QStringRef. + * Added missing operator{==,!=} comparing against QLatin1String. + + - QCommandLineOption: + * Added flags() and setFlags() methods. Added ShortOptionStyle and + HiddenFromHelp flags. + + - QDateTime: + * Introduced toSecsSinceEpoch, fromSecsSinceEpoch and setSecsSinceEpoch + functions, which use 64-bit integers to represent the number of + seconds. + * The toTime_t, fromTime_t and setTime_t functions are deprecated and + will be removed in Qt 6.0. For new code, use the equivalent functions + with "SecsSinceEpoch" in the name, or the equivalent ones with + millisecond accurancy that have existed since Qt 4.7. + * Added string formatting type Qt::ISODateWithMs. + + - QFileInfo: + * QFileInfo now reports file times with millisecond precision on Unix + systems. + + - QFileSystemWatcher: + * [QTBUG-55896] Fixed a bug that caused QFileSystemWatcher to mis-handle + file paths that contained non-US-ASCII characters on Apple platforms. + + - QJsonDocument: + * [QTBUG-39751] fromVariant can now take a QVariantHash argument. + * Fixed a number of bugs that could cause crashes when loading corrupt + binary JSON data. + + - QJsonValue: + * [QTBUG-43077] QJsonValue(Null).toVariant() now returns a QVariant of + type QMetaType::Nullptr instead of an invalid QVariant. + + - QLatin1String: + * Added at(), operator[](), mid(), right(), left(). + + - QLibraryInfo: + * Added QLibraryInfo::version(), which returns the current version of + the Qt library as a QVersionNumber object. + + - QLine/QLineF: + * Added center(). + + - QLockFile: + * Fixed a bug that caused QLockFile to over-sleep while waiting for the + lock file to become available. + + - QMetaType: + * std::nullptr_t is now a built-in Qt metatype. + + - QModelIndex: + * QModelIndex::child has been deprecated due to its lack of generality. + Use model->index(row, column, index) instead. + + - QMutex: + * QMutex now fully models the TimedLockable concept by providing the + try_lock, try_lock_for and try_lock_until functions, therefore making + it usable in Standard Library lock management classes and functions. + + - QObject: + * The QT_NO_NARROWING_CONVERSIONS_IN_CONNECT macro has been added. When + using the new connection syntax (PMF-based) this macro makes it + illegal to narrow the arguments carried by the signal, and/or to + perform floating point to integral implicit conversions on them. When + the macro is defined, depending on your compiler a QObject::connect() + statement triggering such conversions will now fail to compile. + + - QPersistentModelIndex: + * QPersistentModelIndex::child has been deprecated due to its lack of + generality. Use model->index(row, column, index) instead. + + - QStringList: + * Added join(QLatin1String) overload. + + - QStringRef: + * Added missing operator{<,>,<=,>=} comparing against QLatin1String and + QString. + + - QSysInfo: + * The output of QSysInfo::prettyProductName now includes the Windows + OS/kernel version number. In case of future versions of Windows, a + valid string is now returned. + + - QSettings: + * [QTBUG-56124] Fixed a bug that caused QSettings to fail on Apple + platforms when strings with embedded null (\0) bytes were present + + - QSharedPointer: + * [QTBUG-52369] Fixed a bug that caused QSharedPointer to fail to compile + if it was initialized with a nullptr literal. + * Fixed a bug that made QSharedPointer delete the pointer it held with the + wrong destructor if the type of the QSharedPointer and that of the object + passed on the constructor were different. Its behavior is now the same as + std::shared_ptr. + + - QStandardPaths: + * [QTBUG-55507] Fixed the QStandardPaths::FontsLocation on XDG systems to + be $XDG_DATA_DIR/fonts. + * Fixed handling of potential paths that do not exist on Windows. Now, + QStandardPaths may return storage locations that may not exist on all + platforms. + + - QTimer: + * Added support for std::chrono duration objects for QTimer methods, + like QTimer::singleShot and QTimer::setInterval. + + - QWaitCondition: + * Added notify_one() and notify_all() to make QWaitCondition be usable from + algorithms that use the Standard Library naming convention. + +QtDBus +------ + + - QDBusConnection: + * Fixed a bug that would cause QDBusConnection::connect() to return true + if a slot was already connected to the same D-Bus signal. QtDBus does + not support multiple connections. + +QtGui +----- + + - [QFileDialogOptions/QFontDialogOptions/QMessageDialogOptions/ + QColorDialogOptions] These classes no longer have value semantics, but + need to be held in QSharedPointer (as they always were). To copy an + instance, use the clone() method. + - QOpenGLTextureBlitter, a utility class to draw textured quads, has been + made public. + - [QTBUG-38825] Fixed QTextEdit to match undo functionality of QLineEdit + to group two sequential inserts into one undo action. + - [QTBUG-51844] Added rotation and uniqueId properties to + QTouchEvent::TouchPoint. This is mainly for the benefit of the TUIO + plugin so far: it now supports tracking physical objects (fiducials) + on the touchscreen surface, as long as the object's ID can fit in a + 64-bit integer. QPointingDeviceUniqueId is a wrapper for the ID, + designed to be extensible to support other types of IDs in the future. + - [QTBUG-52510] A stationary touchpoint event is delivered if its + velocity changes. This is to ensure that the application will be + notified when a TUIO fiducial object comes to rest. + - [QTBUG-53076] Add QGuiApplication::applicationDisplayNameChanged() + signal. + + - QAbstractTextDocumentLayout: + * Added imageAt() and formatAt() methods, which respectively can be used + to retrieve the source link of the image under the cursor, or the + QTextFormat of the text under the cursor. + + - QFont: + * [QTBUG-48043] The default value of QFont::stretch() is now 0 to + indicate any default stretch is acceptable. + + - QRegion: + * Is now iterable as a container of QRects: added {c,}{r,}{begin,end}(). + + - Text handling: + * [QTBUG-51411] Fixed performance hit from showing large QTextDocuments + in a QTextEdit or QTextBrowser. (Regression introduced in Qt 5.3.0) + * [QTBUG-50090] Fixed line spacing with some scalable fonts containing + bitmaps with the Freetype font engine. + * [QTBUG-56346] Fixed QStaticText when manually breaking lines and no + text width was set. + * [QTBUG-56659] Fixed a regression where raster fonts on Windows were + detected as smoothly scalable and thus rendering with said fonts in Qt + Quick would break. + * [QTBUG-51223] Fixed synthesized oblique for non-latin text on + platforms using the basic font database, such as Android. + * [QTBUG-56672] Fixed list of supported sizes for bitmap fonts on + Windows. + * [QTBUG-56714] Fixed a bug where a no-break space would sometimes cause + the first character of the containing line to not be displayed. + * [QTBUG-55856] Fixed rendering of large fonts when a device pixel ratio + is set and the Freetype engine is used. + +QtNetwork +--------- + + - Added QNetworkDatagram class, along with new function receiveDatagram() + in QUdpSocket that returns it, and an overload to writeDatagram() that + can accept it. + - Added QSctpServer and QSctpSocket classes. Note that these need to be + explicitly enabled via a configure option. + - [QTBUG-50956] Added support for HTTP/2 protocol + + - QSslSocket: + * [QTBUG-39077] TLS PSK ciphers are possible in server sockets. + * It is now possible to set custom Diffie-Hellman parameters for + QSslSocket-based servers. + + - QTcpServer: + * [QTBUG-51288] It is now possible to use QTcpServer with an externally + created QTcpSocket. + +QtSql +----- + + - QSqlDatabase: + * When connecting to a MySQL server whose version is 5.5.3 or higher, + the default connection charset is now utf8mb4 instead of utf8 to allow + 4-byte UTF-8 encodings. + + - SQLite: + * Added notification feature to SQLite driver + +QTestLib +-------- + + - [QTBUG-44030] Added QTest::createTouchDevice() for use in autotests + which generate touch events. + - Added ref-cycles perf counter. + - QFETCH variables can now be declared const (QFETCH(const T, name)). + - It is now possible to use variables of types with an explicit operator + bool in the QVERIFY macro. + +QtWidgets +--------- + + - QFormLayout: + * [QTBUG-15990] Added removeRow(), takeRow(). + + - QMainWindow: + * [QTBUG-56628] Fixed crash using takeCentralWidget when the central + widget was not set. + +**************************************************************************** +* Platform-specific Changes * +**************************************************************************** + + - Added technology preview support for Apple tvOS and Apple watchOS. + - Added initial support for Microsoft Visual Studio 2017, which uses the + mkspec "win32-msvc2017". Full support will happen after the final release + of that compiler. + +Android +------- + + - [QTBUG-48948] Show password while typing is now supported + - [QTBUG-55035][QTBUG-50759] Introduced a mechanism to forward + permission related callbacks on Activity objects to interested + parties. + +Apple platforms +--------------- + + - Added QImage::toCGImage() that returns a CGImage. + - Added functions that convert Qt types QPoint/QPointF, QRect/QRectF and + QSize/QSizeF to and from CGPoint, CGRect and CGSize. Note that QPoint, + QRect and QSize do not provide fromCGXxx functions since that would + silently lose precision. + +iOS +--- + + - Precompiled headers are now supported on iOS. + - Starting from iOS 10, Apple requires all apps that need access to photos + to have the key 'NSPhotoLibraryUsageDescription' in the Info.plist. + Therefore, to get the same support in Qt (when, e.g., using a file + dialog), the Info.plist assigned to QMAKE_INFO_PLIST will need this key + as well. + +macOS +----- + + - Speech to text dictation now works for Qt text input. + - [QTBUG-33708] Fixed underline position in font rendering. + +Linux +----- + + - [QTBUG-39959] QWidget-based applications running on the eglfs platform + plugin can now request 180 or 90 degrees rotated output by setting the + QT_QPA_EGLFS_ROTATION environment variable. + - KDE/Gnome themes now implement QPlatformTheme::fileIconPixmap(), showing + file icons. + +Windows +------- + + - [QTBUG-31476] QFactoryLoader now filters potential plugins by the + ".dll" suffix. + - [QTBUG-56239] 'What's this' button is now shown by default only for + QWidget dialogs. + - [QTBUG-53833] QProcess::startDetached() changed behavior on Windows: + it no longer creates a new console window unconditionally, instead it + passes the same creation flags to CreateProcess as QProcess::start(). + + - Text handling: + * [QTBUG-54740] Fixed embedding fonts in PDF when dpi scaling is active + or when the hinting preference was none or vertical hinting. + * [QTBUG-47485] Fix selecting non-regular fonts when using the Freetype + engine. + * [QTBUG-49346] Fixed rendering error when using the MingLiU fonts at + certain combinations of pixel size and scale. + +**************************************************************************** +* Tools * +**************************************************************************** + +configure & build system +------------------------ + + - The -no-feature-* option family was integrated with the rest of the + configuration system. Numerous existing features were made optional, + and build problems in various reduced configurations were fixed. + This is an ongoing effort known as "Qt Lite". + - Numerous Qt modules outside qtbase now support configure options. + In a module-by-module build, these can be passed to qmake itself, + after a -- option. + - Introduced the qtConfig() qmake function to replace the + patterns contains(QT_CONFIG, ) and load(qfeatures)+ + contains(QT_DISABLED_FEATURES, ). + Likewise, the C++ macro QT_CONFIG() was introduced to + replace the pattern !defined(QT_NO_). + The old methods are effectively deprecated and will stop working at + some point in the near future. + - Use of -sysroot will now trigger a cross-build even if -platform and + -xplatform are the same. + - The JPEG & GIF handlers and the SQL drivers are now always built as + plugins, even in static builds (static "plugins" in this case). + - [GCC] Include paths from system libraries are now marked as such, + resulting in fewer warnings the user cannot do anything about. + - [Windows] config.status.bat is now created, like on Unix. + - [QTBUG-46974] Fixed location of config.status in top-level builds. + - [QTBUG-38792][Unix] The -redo option is now accepted, like on Windows. + - It's now possible to add more arguments when -redo is used. Note that + these arguments are not saved in turn. Likewise for config.status. + - [QTBUG-32896][iOS/clang] Added missing CFBundleIdentifier to library + template. + - [QTBUG-47624] Fixed abort when some, but not all, XCB dependencies + are met. The feature is now disabled instead, as expected. + - [QTBUG-50838] The Raspberry Pi EGL detection now uses pkg-config. + - [QTBUG-52112][Android] Plugins now have a SONAME, as required by + Android 6+. + - [QTBUG-54438] Fixed launching tests, examples, and build tools in + some configurations. + - [QTBUG-56289][GCC@Windows] Fixed -separate-debug-info. + - [QTBUG-57086] Added support for Visual Studio 2017. + +qdbusxml2cpp +------------ + + - [QTBUG-34126] qdbusxml2cpp now supports the --verbose switch, which + provides more details when parsing invalid XML sources. + +qmake +----- + + - Added the $$take_first(), $$take_last(), $$num_add(), $$str_size(), + $$str_member(), and $$sorted() functions. + - The error() function can now be called without arguments to exit + silently. Use after write_file() and similar functions which already + print an error message. + - The $$system() function can return the command's exit code now. + - The $$prompt() function can now print the prompt verbatim. + - QMAKE_EXTRA_TARGETS will now consistently treat the target as a file + name (separator adjustment and quoting). + - [QTBUG-16904][VS] Fixed warning about circular dependencies when + Q_OBJECT is used in .cpp files. + - [QTBUG-36256] packageExists() and PKGCONFIG can now be used + regardless of whether Qt itself was built with pkg-config support. + - [QTBUG-43468][WinRT] Added option to use verbatim manifest files. + - [QTBUG-53905] Fixed OBJECTIVE_SOURCES being moc'd twice. + - [QTBUG-55591][VS2015] Added support for the /DEBUG:FASTLINK option. + - [QTBUG-56507] Fixed parallel builds when a lex source refers to a + file generated from a yacc source. + - [QTBUG-56594][MSVC] Fixed PDB files not being installed for static + libraries. + +moc +--- + + - [MSVC] qmake and moc now cooperate to use the Visual Studio environment + variables (set by the VCVARSALL.BAT script) to find system include + files. A possible consequence is that moc parses application headers + slightly differently, depending on #if conditions that depended on + macros that previous versions had not seen #define'd. Implementers of + other buildsystems are advised to pass the --compiler-flavor=msvc option + to moc. From f55db6738bb5a14ba6ebcfe840225fe9d2ae98c2 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Thu, 22 Dec 2016 03:59:08 +0100 Subject: [PATCH 061/304] Silence bogus whitespace "errors" from the DBus XML parser Any amount of whitespace between elements is now reported as an error starting with 5.8. This is (a) wrong and (b) very confusing for users. Change-Id: I2530b2138f95912e5be07e94b7d7fdab49dedbb1 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/dbus/qdbusxmlparser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dbus/qdbusxmlparser.cpp b/src/dbus/qdbusxmlparser.cpp index 3618c76a1d..94223e1574 100644 --- a/src/dbus/qdbusxmlparser.cpp +++ b/src/dbus/qdbusxmlparser.cpp @@ -385,6 +385,11 @@ QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path, case QXmlStreamReader::Comment: // ignore comments and processing instructions break; + case QXmlStreamReader::Characters: + // ignore whitespace + if (xml.isWhitespace()) + break; + Q_FALLTHROUGH(); default: qDBusParserError() << "unknown token" << xml.name() << xml.tokenString(); break; From 3986be6d98a09fa7854744253864a9e57486bbcf Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 2 Jan 2017 12:47:31 +0100 Subject: [PATCH 062/304] Improve reliability of network bearer tests May of the tests initiate a scan / update of the network configuration and expect the API to deliver exactly one update. This turns out to be a race condition as the update may be emitted multiple times, as QNetworkConfigurationManagerPrivate::updateConfigurations() is called via posted events (queued signal emissions) from the bearer thread, and so after creating the spy we may receive an update from _before_ and end up emitting the signal multiple times. Task-number: QTQAINFRA-1040 Change-Id: I931e2907f0cb86d48b4ab1a8795d75206035ea11 Reviewed-by: Thiago Macieira --- .../tst_qnetworkconfiguration.cpp | 4 ++-- .../tst_qnetworkconfigurationmanager.cpp | 10 +++++----- .../qnetworksession/test/tst_qnetworksession.cpp | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp index 0a52dd0388..82fa5cab9c 100644 --- a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp @@ -114,7 +114,7 @@ void tst_QNetworkConfiguration::comparison() QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete + QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete QList configs = manager.allConfigurations(QNetworkConfiguration::Discovered); QVERIFY(configs.count()); @@ -161,7 +161,7 @@ void tst_QNetworkConfiguration::isRoamingAvailable() //force update to get maximum list QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete + QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete foreach(QNetworkConfiguration c, configs) { diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 838612f638..b251a65420 100644 --- a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -68,7 +68,7 @@ void tst_QNetworkConfigurationManager::allConfigurations() QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete + QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete QList configs = manager.allConfigurations(); @@ -145,7 +145,7 @@ void tst_QNetworkConfigurationManager::defaultConfiguration() QNetworkConfigurationManager manager; QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete + QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete QList configs = manager.allConfigurations(); QNetworkConfiguration defaultConfig = manager.defaultConfiguration(); @@ -175,7 +175,7 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier() //force an update to get maximum number of configs QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete + QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete QList configs = manager.allConfigurations(); @@ -203,7 +203,7 @@ protected: preScanConfigs = manager.allConfigurations(); QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete + QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete configs = manager.allConfigurations(); } public: @@ -229,7 +229,7 @@ void tst_QNetworkConfigurationManager::usedInThread() QList preScanConfigs = manager.allConfigurations(); QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete + QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete QList configs = manager.allConfigurations(); QCOMPARE(thread.configs, configs); //Don't compare pre scan configs, because these may be cached and therefore give different results diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp index 4ae511cf54..138a0859cd 100644 --- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp @@ -106,7 +106,7 @@ void tst_QNetworkSession::initTestCase() QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); - QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); + QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); lackeyDir = QFINDTESTDATA("lackey"); QVERIFY2(!lackeyDir.isEmpty(), qPrintable( @@ -1007,7 +1007,7 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted())); mgr.updateConfigurations(); - QTRY_NOOP(updateSpy.count() == 1); + QTRY_NOOP(updateSpy.count() >= 1); if (updateSpy.count() != 1) { qDebug("tst_QNetworkSession::suitableConfiguration() failure: unable to update configurations"); return QNetworkConfiguration(); @@ -1052,7 +1052,7 @@ void updateConfigurations() QNetworkConfigurationManager mgr; QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted())); mgr.updateConfigurations(); - QTRY_NOOP(updateSpy.count() == 1); + QTRY_NOOP(updateSpy.count() >= 1); } // A convenience-function: updates and prints all available confiurations and their states From e2ab9322769856fb03ca1f0f24408a3abb8bd38a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 13:25:46 +0100 Subject: [PATCH 063/304] Bump version Change-Id: Ie05effe65812e0df13a14e641a026f0b15ff511e --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 8c302d7039..6e554b5503 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ CONFIG += warning_clean QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.8.0 +MODULE_VERSION = 5.8.1 From 9449325f2b234981a2ecc1b0a0bd6ec74f30ff6c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Dec 2016 14:23:39 -0200 Subject: [PATCH 064/304] Partially revert "Windows: stop using _beginthreadex on regular builds" This pertially reverts commit 3ec57107cedb154f256e3ad001ea5475cc64fa94 and brings back the hack to prevent the DLL from being unloaded. It should have been enough, but we've got reports that it's still causing trouble. Since it causes not much harm to keep the DLL loaded (worst case scenario is that QtDBus and QtCore remain loaded after a plugin gets unloaded), we'll keep it. Note: Microsoft is aware that their way of killing threads on process exit is a flaw. See https://blogs.msdn.microsoft.com/oldnewthing/20070502-00/?p=27023/ Task-number: QTBUG-53031 Change-Id: I2962773739e34633b033fffd1493dce695b008c0 Reviewed-by: Friedemann Kleint Reviewed-by: Maurice Kalinowski --- src/dbus/qdbusconnection.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index f95cc3a15d..da7557d7e8 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -69,6 +69,10 @@ QT_BEGIN_NAMESPACE +#ifdef Q_OS_WIN +static void preventDllUnload(); +#endif + Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager) struct QDBusConnectionManager::ConnectionRequestData @@ -139,6 +143,10 @@ QDBusConnectionManager::QDBusConnectionManager() this, &QDBusConnectionManager::createServer, Qt::BlockingQueuedConnection); moveToThread(this); // ugly, don't do this in other projects +#ifdef Q_OS_WIN + // prevent the library from being unloaded on Windows. See comments in the function. + preventDllUnload(); +#endif defaultBuses[0] = defaultBuses[1] = Q_NULLPTR; start(); } @@ -1262,4 +1270,31 @@ QByteArray QDBusConnection::localMachineId() QT_END_NAMESPACE +#ifdef Q_OS_WIN +# include + +QT_BEGIN_NAMESPACE +static void preventDllUnload() +{ + // Thread termination is really wacky on Windows. For some reason we don't + // understand, exiting from the thread may try to unload the DLL. Since the + // QDBusConnectionManager thread runs until the DLL is unloaded, we've got + // a deadlock: the main thread is waiting for the manager thread to exit, + // but the manager thread is attempting to acquire a lock to unload the DLL. + // + // We work around the issue by preventing the unload from happening in the + // first place. + // + // For this trick, see + // https://blogs.msdn.microsoft.com/oldnewthing/20131105-00/?p=2733 + + static HMODULE self; + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_PIN, + reinterpret_cast(&self), // any address in this DLL + &self); +} +QT_END_NAMESPACE +#endif + #endif // QT_NO_DBUS From a8ae8e3130fe4953ebfd54bce15648f58cd3f5be Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 3 Mar 2017 14:06:49 +0100 Subject: [PATCH 065/304] QDateTime::fromString(): improve performance by 33% getMaximum() and getMinimum(), called during parsing, create new QDateTime instances, which on Linux end up calling mktime(). Making these static (for the common case of LocalTime spec) improves performance dramatically, when parsing several date/times. tests/benchmarks/corelib/tools/qdatetime/ (after fixing it to actually parse a valid date/time) says: RESULT : tst_QDateTime::fromString(): - 36,742,060 instruction reads per iteration (total: 36,742,060, iterations: 1) + 24,230,060 instruction reads per iteration (total: 24,230,060, iterations: 1) Change-Id: I0c3931285475bf19a5be8cba1486ed07cbf5e134 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetimeparser.cpp | 20 ++++++++++++++----- .../corelib/tools/qdatetime/main.cpp | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 621c877174..ae429950c8 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1216,15 +1216,15 @@ end: } else { if (context == FromString) { // optimization - Q_ASSERT(getMaximum().date().toJulianDay() == 4642999); + Q_ASSERT(maximum.date().toJulianDay() == 4642999); if (newCurrentValue.date().toJulianDay() > 4642999) state = Invalid; } else { - if (newCurrentValue > getMaximum()) + if (newCurrentValue > maximum) state = Invalid; } - QDTPDEBUG << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum(); + QDTPDEBUG << "not checking intermediate because newCurrentValue is" << newCurrentValue << minimum << maximum; } } StateNode node; @@ -1607,13 +1607,13 @@ bool QDateTimeParser::potentialValue(const QStringRef &str, int min, int max, in bool QDateTimeParser::skipToNextSection(int index, const QDateTime ¤t, const QStringRef &text) const { - Q_ASSERT(current >= getMinimum() && current <= getMaximum()); - const SectionNode &node = sectionNode(index); Q_ASSERT(text.size() < sectionMaxSize(index)); const QDateTime maximum = getMaximum(); const QDateTime minimum = getMinimum(); + Q_ASSERT(current >= minimum && current <= maximum); + QDateTime tmp = current; int min = absoluteMin(index); setDigit(tmp, index, min); @@ -1713,11 +1713,21 @@ bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) con QDateTime QDateTimeParser::getMinimum() const { + // Cache the most common case + if (spec == Qt::LocalTime) { + static const QDateTime localTimeMin(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN, Qt::LocalTime); + return localTimeMin; + } return QDateTime(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN, spec); } QDateTime QDateTimeParser::getMaximum() const { + // Cache the most common case + if (spec == Qt::LocalTime) { + static const QDateTime localTimeMax(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX, Qt::LocalTime); + return localTimeMax; + } return QDateTime(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX, spec); } diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/tools/qdatetime/main.cpp index 8f43a412b7..2c1e3d97ae 100644 --- a/tests/benchmarks/corelib/tools/qdatetime/main.cpp +++ b/tests/benchmarks/corelib/tools/qdatetime/main.cpp @@ -547,8 +547,9 @@ void tst_QDateTime::currentMSecsSinceEpoch() void tst_QDateTime::fromString() { - QString format = "yyy-MM-dd hh:mm:ss.zzz t"; - QString input = "2010-01-01 13:12:11.999 UTC"; + QString format = "yyyy-MM-dd hh:mm:ss.zzz"; + QString input = "2010-01-01 13:12:11.999"; + QVERIFY(QDateTime::fromString(input, format).isValid()); QBENCHMARK { for (int i = 0; i < 1000; ++i) QDateTime::fromString(input, format); From 39e80062d0cf0c25b456bd89be827e50a6077efa Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 16 Dec 2016 12:48:18 -0800 Subject: [PATCH 066/304] Work around MSVC ABI stupidity in exporting inline members of base class In this case, the issue was ICC, when compiling QtQml: qv4sequenceobject.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QList::replace(int,class QItemSelectionRange const &)" (__imp_?replace@?$QList@VQItemSelectionRange@@@@QEAAXHAEBVQItemSelectionRange@@@Z) referenced in function "public: static bool __cdecl QV4::QQmlSequence::deleteIndexedProperty(struct QV4::Managed *,unsigned int)" (?deleteIndexedProperty@?$QQmlSequence@VQItemSelection@@@QV4@@SA_NPEAUManaged@2@I@Z) This applies the same fix as qvector.h has had for ages due to QPolygon. Change-Id: I15b62e0f9cec482fbb40fffd1490d791db5056bc Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- src/corelib/itemmodels/qitemselectionmodel.h | 18 ++++++++++++++++++ src/corelib/tools/qvector.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index 3d3cb00750..c22ac6dbe5 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -251,6 +251,24 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags) // dummy implentation of qHash() necessary for instantiating QList::toSet() with MSVC inline uint qHash(const QItemSelectionRange &) { return 0; } +#ifdef Q_CC_MSVC + +/* + ### Qt 6: + ### This needs to be removed for next releases of Qt. It is a workaround for vc++ because + ### Qt exports QItemSelection that inherits QList. +*/ + +# ifndef Q_TEMPLATE_EXTERN +# if defined(QT_BUILD_CORE_LIB) +# define Q_TEMPLATE_EXTERN +# else +# define Q_TEMPLATE_EXTERN extern +# endif +# endif +Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QList; +#endif // Q_CC_MSVC + class Q_CORE_EXPORT QItemSelection : public QList { public: diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 4dbf95c315..5225b68d40 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -982,11 +982,13 @@ QT_BEGIN_INCLUDE_NAMESPACE #include QT_END_INCLUDE_NAMESPACE +#ifndef Q_TEMPLATE_EXTERN #if defined(QT_BUILD_CORE_LIB) #define Q_TEMPLATE_EXTERN #else #define Q_TEMPLATE_EXTERN extern #endif +#endif Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector; Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector; #endif From 1c3c2486c63de620abc70cb57be2908ed56a4d89 Mon Sep 17 00:00:00 2001 From: Frederik Schwarzer Date: Mon, 19 Dec 2016 17:39:18 +0100 Subject: [PATCH 067/304] Fix broken link in documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-57530 Change-Id: Iecb1a26f6b8a7e8a506d768668cde1c277d15dde Reviewed-by: Topi Reiniö Reviewed-by: Martin Smith --- src/corelib/doc/src/filestorage.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/doc/src/filestorage.qdoc b/src/corelib/doc/src/filestorage.qdoc index c6a4a85646..e291ba1375 100644 --- a/src/corelib/doc/src/filestorage.qdoc +++ b/src/corelib/doc/src/filestorage.qdoc @@ -75,7 +75,7 @@ by a Sun SPARC running Solaris. You can also use a data stream to read/write raw unencoded binary data. For more details on the datatypes that QDataStream can serialize, see -{Serializing Qt Data Types}. +\l{Serializing Qt Data Types}. The QTextStream class provides a convenient interface for reading and writing text. QTextStream can operate on a QIODevice, a QByteArray or From c96a4058f1d8979279c249e4ecd96e2bb4945ddb Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 29 Dec 2016 17:13:59 +0100 Subject: [PATCH 068/304] Avoid compile warnings in qabstractanimation.cpp Change-Id: I57f90fc335b50231fb2093f096ad38168d476145 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/animation/qabstractanimation.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 662774b484..8c189e9288 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -242,6 +242,7 @@ QUnifiedTimer *QUnifiedTimer::instance(bool create) inst = unifiedTimer() ? unifiedTimer()->localData() : 0; } #else + Q_UNUSED(create); static QUnifiedTimer unifiedTimer; inst = &unifiedTimer; #endif @@ -576,6 +577,7 @@ QAnimationTimer *QAnimationTimer::instance(bool create) inst = animationTimer() ? animationTimer()->localData() : 0; } #else + Q_UNUSED(create); static QAnimationTimer animationTimer; inst = &animationTimer; #endif From 1b82a9aea5e2385c08543f3a9ebbed71a0bae3cc Mon Sep 17 00:00:00 2001 From: Aleksey Lysenko Date: Tue, 3 Jan 2017 22:41:20 +0200 Subject: [PATCH 069/304] Doc: add note about unsupported platforms for QProcess Task-number: QTBUG-57840 Change-Id: I46a26a9c4c6ad0aa6994945091a2904c3b51080f Reviewed-by: Martin Smith Reviewed-by: Jake Petroules --- src/corelib/io/qprocess.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 23a3cc1a16..c7d6cb426d 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -509,6 +509,9 @@ void QProcessPrivate::Channel::clear() You can also call error() to find the type of error that occurred last, and state() to find the current process state. + \note QProcess is not supported on VxWorks, iOS, tvOS, watchOS, + or the Universal Windows Platform. + \section1 Communicating via Channels Processes have two predefined output channels: The standard From 86abf43122c0b41371d1f6eee7311079ed7cf2bb Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 3 Jan 2017 16:53:35 -0800 Subject: [PATCH 070/304] QMacCGContext: Take paint device pixel ratio into account This seems to have been omitted in c52bb0309071bed9e040c79d87f764bac6a396b8. Change-Id: If8cde889af75934c85d9b21bd22095b7e5a4bf32 Task-number: QTBUG-57894 Reviewed-by: Jake Petroules --- src/gui/painting/qcoregraphics.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index 466b18d59b..803328c10f 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -495,6 +495,8 @@ QMacCGContext::QMacCGContext(QPaintDevice *paintDevice) : context(0) context = CGBitmapContextCreate(image->bits(), image->width(), image->height(), 8, image->bytesPerLine(), colorspace, flags); CGContextTranslateCTM(context, 0, image->height()); + const qreal devicePixelRatio = paintDevice->devicePixelRatioF(); + CGContextScaleCTM(context, devicePixelRatio, devicePixelRatio); CGContextScaleCTM(context, 1, -1); } From 99245e9576c28777fa1b1fc639c1c24e4aed3789 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 29 Dec 2016 17:39:13 +0100 Subject: [PATCH 071/304] Avoid zero-as-nullpointer warnings in QThread Change-Id: I3fd557a54d63c2dcabe58fab65326538896d02a2 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/thread/qthread.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 410f642ca7..45786537e2 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -140,10 +140,10 @@ public: static QThread* currentThread(); protected: - QThread(QThreadPrivate &dd, QObject *parent = 0); + QThread(QThreadPrivate &dd, QObject *parent = nullptr); private: - explicit QThread(QObject *parent = 0); + explicit QThread(QObject *parent = nullptr); static QThread *instance; friend class QCoreApplication; From 9ba39c4b05ccfbfbafe3d9e6546d4e5514a892ea Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 29 Dec 2016 18:42:07 +0100 Subject: [PATCH 072/304] Remove pointless QT_NO_THREAD ifdefs from qpropertyanimation.cpp Change-Id: I7b7e80abbddf4d43c6135775136d993196d708b3 Reviewed-by: Thiago Macieira --- src/corelib/animation/qpropertyanimation.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 6e5b08c295..9fd845bb93 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -269,10 +269,8 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState, QPropertyAnimation *animToStop = 0; { -#ifndef QT_NO_THREAD static QBasicMutex mutex; QMutexLocker locker(&mutex); -#endif typedef QPair QPropertyAnimationPair; typedef QHash QPropertyAnimationHash; static QPropertyAnimationHash hash; From b49660bba4df13b88defbd5c3c789da0f93110c9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 29 Dec 2016 17:19:14 +0100 Subject: [PATCH 073/304] Make filesystemmodel feature depend on itemmodel QFileSystemModel inherits from QAbstractItemModel, so it has to be disabled if the latter is not available. Change-Id: Ifc56f7e311d84bd15e8b4ed95d67bf9ad9aba888 Reviewed-by: Lars Knoll --- src/widgets/configure.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 1e72b61886..8acbffef6a 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -86,6 +86,7 @@ "label": "QFileSystemModel", "purpose": "Provides a data model for the local filesystem.", "section": "File I/O", + "condition": "features.itemmodel", "output": [ "publicFeature", "feature" ] }, "itemviews": { From 2ed9a52ebf1dfb1a16ad65413bea01314010720d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 30 Nov 2016 16:37:15 +0100 Subject: [PATCH 074/304] Fix compilation without sharedmemory We have to enable qt_safe_ftok with either sharedmemory or systemsemaphore. In order to make the resulting QT_CONFIG work with the bootstrap library we switch the features off for bootstrapping. Some tests and examples have to be excluded when sharedmemory is not available. Change-Id: I3fc3926d160202b378be2293fba40201a4bf50c5 Reviewed-by: Thiago Macieira --- examples/corelib/ipc/ipc.pro | 4 ++-- src/corelib/global/qconfig-bootstrapped.h | 2 ++ src/corelib/kernel/qcore_unix_p.h | 4 ++-- tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro | 7 ++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/corelib/ipc/ipc.pro b/examples/corelib/ipc/ipc.pro index 4cc5f3be56..101552cea9 100644 --- a/examples/corelib/ipc/ipc.pro +++ b/examples/corelib/ipc/ipc.pro @@ -1,6 +1,6 @@ requires(qtHaveModule(widgets)) TEMPLATE = subdirs -# no QSharedMemory -!vxworks:!integrity: SUBDIRS = sharedmemory + +qtConfig(sharedmemory): SUBDIRS = sharedmemory qtHaveModule(network): SUBDIRS += localfortuneserver localfortuneclient diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 2bca82535f..d7849d4699 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -83,6 +83,8 @@ #define QT_NO_TRANSLATION #define QT_FEATURE_translation -1 #define QT_NO_GEOM_VARIANT +#define QT_FEATURE_sharedmemory -1 +#define QT_FEATURE_systemsemaphore -1 #ifdef QT_BUILD_QMAKE #define QT_FEATURE_commandlineparser -1 diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index b5756af994..80058d9115 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -370,7 +370,7 @@ union qt_semun { }; #ifndef QT_POSIX_IPC -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) #ifndef Q_OS_ANDROID static inline key_t qt_safe_ftok(const QByteArray &filename, int proj_id) { @@ -379,7 +379,7 @@ static inline key_t qt_safe_ftok(const QByteArray &filename, int proj_id) return ::ftok(filename.constData(), qHash(filename, proj_id)); } #endif // !Q_OS_ANDROID -#endif // !QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) #endif // !QT_POSIX_IPC QT_END_NAMESPACE diff --git a/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro b/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro index 69062a9741..3a4697750e 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro +++ b/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs -!winrt: SUBDIRS = sharedmemoryhelper - -SUBDIRS += test +qtConfig(sharedmemory) { + !winrt: SUBDIRS = sharedmemoryhelper + SUBDIRS += test +} From af5c8d04fb0c9ddda58925e4862e857c78a5e563 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 2 Jan 2017 08:10:57 +0100 Subject: [PATCH 075/304] Win: Account for windows which are WindowTransparentForInput Task-number: QTBUG-57864 Change-Id: I8793aaa3719fbcf97f95ae462135cbf6b5823097 Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowscontext.cpp | 11 ++++++++-- .../windows/qwindowsmousehandler.cpp | 21 +++++-------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 1a03df6ac2..bb9ed730a3 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -990,11 +990,18 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::MouseWheelEvent: case QtWindows::MouseEvent: case QtWindows::LeaveEvent: + { + QWindow *window = platformWindow->window(); + while (window->flags() & Qt::WindowTransparentForInput) + window = window->parent(); + if (!window) + return false; #if !defined(QT_NO_SESSIONMANAGER) - return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result); + return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(window, hwnd, et, msg, result); #else - return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result); + return d->m_mouseHandler.translateMouseEvent(window, hwnd, et, msg, result); #endif + } case QtWindows::TouchEvent: #if !defined(QT_NO_SESSIONMANAGER) return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result); diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 3f6230172e..e4025fe60d 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -313,7 +313,8 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, // events, "click-through") can be considered as the window under mouse. QWindow *currentWindowUnderMouse = platformWindow->hasMouseCapture() ? QWindowsScreen::windowAt(globalPosition, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT) : window; - + while (currentWindowUnderMouse && currentWindowUnderMouse->flags() & Qt::WindowTransparentForInput) + currentWindowUnderMouse = currentWindowUnderMouse->parent(); // QTBUG-44332: When Qt is running at low integrity level and // a Qt Window is parented on a Window of a higher integrity process // using QWindow::fromWinId() (for example, Qt running in a browser plugin) @@ -432,22 +433,10 @@ static bool isValidWheelReceiver(QWindow *candidate) static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta, Qt::Orientation orientation, Qt::KeyboardModifiers mods) { - // Redirect wheel event to one of the following, in order of preference: - // 1) The window under mouse - // 2) The window receiving the event // If a window is blocked by modality, it can't get the event. - - QWindow *receiver = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE); - bool handleEvent = true; - if (!isValidWheelReceiver(receiver)) { - receiver = window; - if (!isValidWheelReceiver(receiver)) - handleEvent = false; - } - - if (handleEvent) { - QWindowSystemInterface::handleWheelEvent(receiver, - QWindowsGeometryHint::mapFromGlobal(receiver, globalPos), + if (isValidWheelReceiver(window)) { + QWindowSystemInterface::handleWheelEvent(window, + QWindowsGeometryHint::mapFromGlobal(window, globalPos), globalPos, delta, orientation, mods); } } From 47de2ef27f9d68d5c1f2f935380e1517f99c9721 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 21 Dec 2016 14:02:14 +0100 Subject: [PATCH 076/304] QOCIDriver: Ensure the where clause is correctly setup Commit 88e043a8 introduced two bugs: 1. When constructing the WHERE clause, the closing ' around the owner name was dropped. 2. When constructing QLatin1Strings for comparison with system owners, a size of -1 was passed, with the comment "force strlen call". But, unlike QString, QLatin1String does not invoke strlen(), but stores the negative length unchanged, making the comparisons always fail. Change-Id: Ie2835b76877c31ee32c900f67eb0853df7110dbb Reviewed-by: Marc Mutz --- src/plugins/sqldrivers/oci/qsql_oci.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/sqldrivers/oci/qsql_oci.cpp b/src/plugins/sqldrivers/oci/qsql_oci.cpp index 47d6db7ea4..32d3681a17 100644 --- a/src/plugins/sqldrivers/oci/qsql_oci.cpp +++ b/src/plugins/sqldrivers/oci/qsql_oci.cpp @@ -2405,16 +2405,16 @@ static QString make_where_clause(const QString &user, Expression e) static const char joinC[][4] = { "or" , "and" }; static Q_CONSTEXPR QLatin1Char bang[] = { QLatin1Char(' '), QLatin1Char('!') }; - const QLatin1String join(joinC[e], -1); // -1: force strlen call + const QLatin1String join(joinC[e]); QString result; result.reserve(sizeof sysUsers / sizeof *sysUsers * // max-sizeof(owner != and ) (9 + sizeof *sysUsers + 5)); for (const auto &sysUser : sysUsers) { - const QLatin1String l1(sysUser, -1); // -1: force strlen call + const QLatin1String l1(sysUser); if (l1 != user) - result += QLatin1String("owner ") + bang[e] + QLatin1String("= '") + l1 + QLatin1Char(' ') + join + QLatin1Char(' '); + result += QLatin1String("owner ") + bang[e] + QLatin1String("= '") + l1 + QLatin1String("' ") + join + QLatin1Char(' '); } result.chop(join.size() + 2); // remove final " " From 04b095b24bb335c5e1d28f3470c2c8033df26634 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 2 Dec 2016 16:25:54 +0100 Subject: [PATCH 077/304] Doc: Properly mention valgrind & callgrind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Julian Seward is the author mentioned in valgrind_p.h. Also call the whole thing valgrind, since callgrind is part of valgrind. Change-Id: Iaf5958c520b919c1acf93ce368b0839bd06ccd46 Reviewed-by: Friedemann Kleint Reviewed-by: hjk Reviewed-by: Topi Reiniö --- .../{CALLGRIND_LICENSE.txt => VALGRIND_LICENSE.txt} | 4 +--- src/testlib/3rdparty/qt_attribution.json | 11 ++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) rename src/testlib/3rdparty/{CALLGRIND_LICENSE.txt => VALGRIND_LICENSE.txt} (94%) diff --git a/src/testlib/3rdparty/CALLGRIND_LICENSE.txt b/src/testlib/3rdparty/VALGRIND_LICENSE.txt similarity index 94% rename from src/testlib/3rdparty/CALLGRIND_LICENSE.txt rename to src/testlib/3rdparty/VALGRIND_LICENSE.txt index 0a6a793422..714b75e6d1 100644 --- a/src/testlib/3rdparty/CALLGRIND_LICENSE.txt +++ b/src/testlib/3rdparty/VALGRIND_LICENSE.txt @@ -1,6 +1,4 @@ - This file is part of callgrind, a valgrind tool for cache simulation - and call tree tracing. - + Copyright (C) 2000-2007 Julian Seward Copyright (C) 2003-2007 Josef Weidendorfer. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/testlib/3rdparty/qt_attribution.json b/src/testlib/3rdparty/qt_attribution.json index d8b0ad1fc7..49d12580bd 100644 --- a/src/testlib/3rdparty/qt_attribution.json +++ b/src/testlib/3rdparty/qt_attribution.json @@ -1,17 +1,18 @@ [ { - "Id": "callgrind", - "Name": "Callgrind", + "Id": "valgrind", + "Name": "Valgrind", "QDocModule": "qttestlib", "QtUsage": "Used on Linux ond MacOS in the Qt Test module.", "Files": "valgrind_p.h callgrind_p.h", - "Description": "Part of Valgrind: an instrumentation framework for building dynamic analysis tools.", + "Description": "An instrumentation framework for building dynamic analysis tools.", "Homepage": "http://valgrind.org/", "License": "BSD 4-clause \"Original\" or \"Old\" License", "LicenseId": "BSD-4-Clause", - "LicenseFile": "CALLGRIND_LICENSE.txt", - "Copyright": "Copyright (C) 2003-2007 Josef Weidendorfer. All rights reserved." + "LicenseFile": "VALGRIND_LICENSE.txt", + "Copyright": "Copyright (C) 2000-2007 Julian Seward +Copyright (C) 2003-2007 Josef Weidendorfer." }, { "Id": "cycle", From fafdb171e0c317ee8f871dc7b504d3713d5860eb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 3 Jan 2017 18:00:05 +0100 Subject: [PATCH 078/304] Accessibility macOS: fix parentElement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try to return the immediate parent first, nothing else makes sense. The original code relied on the window pointer usually being nullptr, which is not reliable. Make sure to check the validity of the handle returned, since it's possible to have the platform window being nullptr. It's not quite clear to me how to end up with a null window though. Task-number: QTBUG-52304 Change-Id: Id3e70cdab980fb0a86cebbb7c10d824d8a7dd80b Reviewed-by: Jan Arve Sæther --- .../cocoa/qcocoaaccessibilityelement.mm | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 97bd402b73..982c98976b 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -235,19 +235,19 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of if (!iface || !iface->isValid()) return nil; + if (QAccessibleInterface *parent = iface->parent()) { + QAccessible::Id parentId = QAccessible::uniqueId(parent); + return [QMacAccessibilityElement elementWithId: parentId]; + } + if (QWindow *window = iface->window()) { - QCocoaWindow *win = static_cast(window->handle()); - return qnsview_cast(win->view()); + QPlatformWindow *platformWindow = window->handle(); + if (platformWindow) { + QCocoaWindow *win = static_cast(platformWindow); + return qnsview_cast(win->view()); + } } - - QAccessibleInterface *parent = iface->parent(); - if (!parent) { - qWarning() << "INVALID PARENT FOR INTERFACE: " << iface; - return nil; - } - - QAccessible::Id parentId = QAccessible::uniqueId(parent); - return [QMacAccessibilityElement elementWithId: parentId]; + return nil; } From d330ae0da27f54ede10dabdc937bfb570ac244cb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 4 Jan 2017 23:23:42 +0100 Subject: [PATCH 079/304] Accessibility macOS: check for valid interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are a few places that did not check if the returned interface is valid. Task-number: QTBUG-52536 Change-Id: I56ca0952fec0b44dfd4b3991aa94554e9c829642 Reviewed-by: Jan Arve Sæther --- .../platforms/cocoa/qcocoaaccessibilityelement.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 982c98976b..e743dd56bf 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -537,7 +537,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of - (void)accessibilityPerformAction:(NSString *)action { QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); - if (iface) { + if (iface && iface->isValid()) { const QString qtAction = QCocoaAccessible::translateAction(action, iface); QAccessibleBridgeUtils::performEffectiveAction(iface, qtAction); } @@ -562,16 +562,16 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of int y = qt_mac_flipYCoordinate(point.y); QAccessibleInterface *childInterface = iface->childAt(point.x, y); // No child found, meaning we hit this element. - if (!childInterface) + if (!childInterface || !childInterface->isValid()) return NSAccessibilityUnignoredAncestor(self); // find the deepest child at the point QAccessibleInterface *childOfChildInterface = 0; do { childOfChildInterface = childInterface->childAt(point.x, y); - if (childOfChildInterface) + if (childOfChildInterface && childOfChildInterface->isValid()) childInterface = childOfChildInterface; - } while (childOfChildInterface); + } while (childOfChildInterface && childOfChildInterface->isValid()); QAccessible::Id childId = QAccessible::uniqueId(childInterface); // hit a child, forward to child accessible interface. @@ -590,7 +590,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of } QAccessibleInterface *childInterface = iface->focusChild(); - if (childInterface) { + if (childInterface && childInterface->isValid()) { QAccessible::Id childAxid = QAccessible::uniqueId(childInterface); QMacAccessibilityElement *accessibleElement = [QMacAccessibilityElement elementWithId:childAxid]; return NSAccessibilityUnignoredAncestor(accessibleElement); From 7e3e5b2dcf2e2576065ca9f9850cd1f2126f397f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 5 Jan 2017 11:28:45 +0100 Subject: [PATCH 080/304] Fix regression in handling Chinese system default font Register font's english name as alias when populating font families. This was incorrectly undone when support for subfamilies was added. Task-number: QTBUG-57856 Change-Id: Ib71f905bb00db86d44fa0921ec56c8c76c332e06 Reviewed-by: Friedemann Kleint Reviewed-by: Liang Qi Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/windows/qwindowsfontdatabase.cpp | 13 +++++++++++-- .../windows/qwindowsfontdatabase_ft.cpp | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 1c615e06ed..887123083a 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1159,7 +1159,7 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName) ReleaseDC(0, dummy); } -static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *, +static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric, DWORD, LPARAM) { // the "@family" fonts are just the same as "family". Ignore them. @@ -1168,6 +1168,13 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) { const QString faceName = QString::fromWCharArray(faceNameW); QPlatformFontDatabase::registerFontFamily(faceName); + // Register current font's english name as alias + const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE); + if (ttf && qt_localizedName(faceName)) { + const QString englishName = qt_getEnglishName(faceName); + if (!englishName.isEmpty()) + QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName); + } } return 1; // continue } @@ -1183,7 +1190,9 @@ void QWindowsFontDatabase::populateFontDatabase() EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0); ReleaseDC(0, dummy); // Work around EnumFontFamiliesEx() not listing the system font. - QPlatformFontDatabase::registerFontFamily(QWindowsFontDatabase::systemDefaultFont().family()); + QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family(); + if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily).isEmpty()) + QPlatformFontDatabase::registerFontFamily(systemDefaultFamily); } typedef QSharedPointer QWindowsFontEngineDataPtr; diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp index df84198862..ebb82baf6f 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp @@ -362,8 +362,15 @@ static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TE if (!key && ttf && qt_localizedName(faceName)) key = findFontKey(qt_getEnglishName(faceName)); } - if (key) + if (key) { QPlatformFontDatabase::registerFontFamily(faceName); + // Register current font's english name as alias + if (ttf && qt_localizedName(faceName)) { + const QString englishName = qt_getEnglishName(faceName); + if (!englishName.isEmpty()) + QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName); + } + } } return 1; // continue } @@ -378,7 +385,9 @@ void QWindowsFontDatabaseFT::populateFontDatabase() EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0); ReleaseDC(0, dummy); // Work around EnumFontFamiliesEx() not listing the system font - QPlatformFontDatabase::registerFontFamily(QWindowsFontDatabase::systemDefaultFont().family()); + QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family(); + if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily).isEmpty()) + QPlatformFontDatabase::registerFontFamily(systemDefaultFamily); } QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, void *handle) From afbdf20fed389fe56a948d166c7c62693f04ba6c Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Tue, 3 Jan 2017 21:31:22 +0100 Subject: [PATCH 081/304] Fixed docs explaining the Frameworks usage Used the correct variable Task-number: QTBUG-48941 Change-Id: I832fa40d27ebba8e1787d5a8e819b9f5c17cf721 Reviewed-by: Oswald Buddenhagen --- qmake/doc/snippets/code/doc_src_qmake-manual.pro | 2 +- qmake/doc/src/qmake-manual.qdoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qmake/doc/snippets/code/doc_src_qmake-manual.pro b/qmake/doc/snippets/code/doc_src_qmake-manual.pro index 1710826f2d..8ba0aa0713 100644 --- a/qmake/doc/snippets/code/doc_src_qmake-manual.pro +++ b/qmake/doc/snippets/code/doc_src_qmake-manual.pro @@ -120,7 +120,7 @@ qmake -spec macx-g++ #! [14] -QMAKE_LFLAGS += -F/path/to/framework/directory/ +LIBS += -F/path/to/framework/directory/ #! [14] diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 4ff64f59d6..34e86b94c5 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -685,7 +685,7 @@ Directories other than the standard framework directory need to be specified to the build system, and this is achieved by appending linker options to the - \l{QMAKE_LFLAGS} variable, as shown in the following example: + \l{LIBS} variable, as shown in the following example: \snippet code/doc_src_qmake-manual.pro 14 From fb85a72325d7954592ac88bbe82c913ae6124424 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 26 Dec 2016 18:37:47 +0100 Subject: [PATCH 082/304] Fix deleting of QOpenGLVersionFunctionsBackend Since the destructor is not virtual we need to cast to the proper class when deleting otherwise the wrong destructor is called and the object memory is not entirely freed. Change-Id: Ie4e0e91bfa6e802c7d72fd1f137f5c7f3f31c8a0 Reviewed-by: Simon Hausmann Reviewed-by: Marc Mutz --- src/gui/opengl/qopenglversionfunctions.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp index 54df2e5734..a3d3bb6bd1 100644 --- a/src/gui/opengl/qopenglversionfunctions.cpp +++ b/src/gui/opengl/qopenglversionfunctions.cpp @@ -74,15 +74,21 @@ QOpenGLVersionFunctionsStorage::QOpenGLVersionFunctionsStorage() QOpenGLVersionFunctionsStorage::~QOpenGLVersionFunctionsStorage() { +#ifndef QT_OPENGL_ES if (backends) { - for (int i = 0; i < QOpenGLVersionFunctionsBackend::OpenGLVersionBackendCount; ++i) { - if (backends[i] && !--backends[i]->refs) { - // deleting the base class is ok, as the derived classes don't have a destructor - delete backends[i]; - } - } + + int i = 0; + +#define DELETE_BACKEND(X) \ + if (backends[i] && !--backends[i]->refs) \ + delete static_cast(backends[i]); \ + ++i; + + QT_OPENGL_VERSIONS(DELETE_BACKEND) +#undef DELETE_BACKEND delete[] backends; } +#endif } QOpenGLVersionFunctionsBackend *QOpenGLVersionFunctionsStorage::backend(QOpenGLContext *context, QOpenGLVersionFunctionsBackend::Version v) From f4d3c87f0caab71f15e12f0f376f94a3e90a8adf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 4 Jan 2017 13:43:44 +0100 Subject: [PATCH 083/304] Fix UB (signed integer overflows) in QProgressBar The expression 'minimum - 1' invokes UB when 'minimum == INT_MIN'. Likewise, the expression 'maximum - minimum' invokes UB when 'qint64(maximum) - minimum > INT_MAX'. Fix by restructuring the code or else by using 64-bit arithmetic. Change-Id: I352eafa72f28ae907f41c8f88abcf0a81705c718 Task-number: QTBUG-57857 Reviewed-by: David Faure --- src/widgets/widgets/qprogressbar.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 10f005e6d3..2893849c42 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -144,16 +144,17 @@ bool QProgressBarPrivate::repaintRequired() const if (value == lastPaintedValue) return false; - int valueDifference = qAbs(value - lastPaintedValue); - + const auto valueDifference = qAbs(qint64(value) - lastPaintedValue); // Check if the text needs to be repainted if (value == minimum || value == maximum) return true; + + const auto totalSteps = qint64(maximum) - minimum; if (textVisible) { if ((format.contains(QLatin1String("%v")))) return true; if ((format.contains(QLatin1String("%p")) - && valueDifference >= qAbs((maximum - minimum) / 100))) + && valueDifference >= qAbs(totalSteps / 100))) return true; } @@ -166,7 +167,7 @@ bool QProgressBarPrivate::repaintRequired() const // (valueDifference / (maximum - minimum) > cw / groove.width()) // transformed to avoid integer division. int grooveBlock = (q->orientation() == Qt::Horizontal) ? groove.width() : groove.height(); - return (valueDifference * grooveBlock > cw * (maximum - minimum)); + return valueDifference * grooveBlock > cw * totalSteps; } /*! @@ -260,9 +261,10 @@ QProgressBar::~QProgressBar() void QProgressBar::reset() { Q_D(QProgressBar); - d->value = d->minimum - 1; if (d->minimum == INT_MIN) d->value = INT_MIN; + else + d->value = d->minimum - 1; repaint(); } @@ -358,7 +360,7 @@ void QProgressBar::setRange(int minimum, int maximum) d->minimum = minimum; d->maximum = qMax(minimum, maximum); - if (d->value < (d->minimum - 1) || d->value > d->maximum) + if (d->value < qint64(d->minimum) - 1 || d->value > d->maximum) reset(); else update(); From afefed06952d5edd5c6be4376469b022975930cf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 6 Jan 2017 07:38:50 +0100 Subject: [PATCH 084/304] QAndroidStyle: fix UB (signed integer overflow) in AndroidProgressBarControl::drawControl() The expression 'maximum - minimum' has undefined behavior when 'qint64(maximum) - minimum > INT_MAX'. Use 64-bit arithmetic instead. Also fix calculation of the progress when minimum != 0. Rename QStyleOptionProgressBar* variable to avoid line wraps. Change-Id: I1d48a7930e7f6d69798c2e878bb0045d55c2f057 Reviewed-by: David Faure --- src/widgets/styles/qandroidstyle.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp index b37dffbe80..110153d0f6 100644 --- a/src/widgets/styles/qandroidstyle.cpp +++ b/src/widgets/styles/qandroidstyle.cpp @@ -1606,15 +1606,14 @@ void QAndroidStyle::AndroidProgressBarControl::drawControl(const QStyleOption *o if (!m_progressDrawable) return; - if (const QStyleOptionProgressBar *progressBarOption = - qstyleoption_cast(option)) { + if (const QStyleOptionProgressBar *pb = qstyleoption_cast(option)) { if (m_progressDrawable->type() == QAndroidStyle::Layer) { - const double fraction = progressBarOption->progress / double(progressBarOption->maximum - progressBarOption->minimum); + const double fraction = double(qint64(pb->progress) - pb->minimum) / (qint64(pb->maximum) - pb->minimum); QAndroidStyle::AndroidDrawable *clipDrawable = static_cast(m_progressDrawable)->layer(m_progressId); if (clipDrawable->type() == QAndroidStyle::Clip) - static_cast(clipDrawable)->setFactor(fraction, progressBarOption->orientation); + static_cast(clipDrawable)->setFactor(fraction, pb->orientation); else - static_cast(m_progressDrawable)->setFactor(m_progressId, fraction, progressBarOption->orientation); + static_cast(m_progressDrawable)->setFactor(m_progressId, fraction, pb->orientation); } m_progressDrawable->draw(p, option); } From 5c207c6c792b016635d0ca79ea1b832037c32c08 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 21 Nov 2016 18:21:47 +0100 Subject: [PATCH 085/304] Add a feature for Qt Network This way you can disable support for QtNetwork by specifying -no-feature-network on the configure line. Change-Id: I46217ccc525a9e2c85394ed4eb6db0e2b60b6d86 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- configure.json | 5 +++++ src/src.pro | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.json b/configure.json index 7d675c02be..5b09e97bd2 100644 --- a/configure.json +++ b/configure.json @@ -930,6 +930,10 @@ { "type": "publicQtConfig", "negative": true } ] }, + "network": { + "label": "Qt Network", + "output": [ "privateFeature" ] + }, "widgets": { "label": "Qt Widgets", "condition": "features.gui", @@ -1123,6 +1127,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 "dbus", "dbus-linked", "gui", + "network", "widgets" ] }, { diff --git a/src/src.pro b/src/src.pro index 90d7e2b76c..7c7eb7c34a 100644 --- a/src/src.pro +++ b/src/src.pro @@ -124,7 +124,7 @@ src_printsupport.depends = src_corelib src_gui src_widgets src_tools_uic src_plugins.subdir = $$PWD/plugins src_plugins.target = sub-plugins -src_plugins.depends = src_sql src_xml src_network +src_plugins.depends = src_sql src_xml src_android.subdir = $$PWD/android @@ -144,7 +144,11 @@ qtConfig(regularexpression):pcre { SUBDIRS += src_corelib src_tools_qlalr TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain -SUBDIRS += src_network src_sql src_xml src_testlib +SUBDIRS += src_sql src_xml src_testlib +qtConfig(network) { + SUBDIRS += src_network + src_plugins.depends += src_network +} qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ SUBDIRS += src_tools_bootstrap_dbus From 3b609fc76fd6bf72faa52884c039bb0a074b4e72 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 10:12:16 +0100 Subject: [PATCH 086/304] Add a feature for Qt Sql This way we can disable it by passing -no-feature-sql to configure. Change-Id: Ia47d72101de0788478997fa1854cedcd1742f6fd Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- configure.json | 5 +++++ src/src.pro | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.json b/configure.json index 5b09e97bd2..052aeac30c 100644 --- a/configure.json +++ b/configure.json @@ -934,6 +934,10 @@ "label": "Qt Network", "output": [ "privateFeature" ] }, + "sql": { + "label": "Qt Sql", + "output": [ "privateFeature" ] + }, "widgets": { "label": "Qt Widgets", "condition": "features.gui", @@ -1128,6 +1132,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 "dbus-linked", "gui", "network", + "sql", "widgets" ] }, { diff --git a/src/src.pro b/src/src.pro index 7c7eb7c34a..fa408d4787 100644 --- a/src/src.pro +++ b/src/src.pro @@ -124,7 +124,7 @@ src_printsupport.depends = src_corelib src_gui src_widgets src_tools_uic src_plugins.subdir = $$PWD/plugins src_plugins.target = sub-plugins -src_plugins.depends = src_sql src_xml +src_plugins.depends = src_xml src_android.subdir = $$PWD/android @@ -144,11 +144,15 @@ qtConfig(regularexpression):pcre { SUBDIRS += src_corelib src_tools_qlalr TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain -SUBDIRS += src_sql src_xml src_testlib +SUBDIRS += src_xml src_testlib qtConfig(network) { SUBDIRS += src_network src_plugins.depends += src_network } +qtConfig(sql) { + SUBDIRS += src_sql + src_plugins.depends += src_sql +} qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ SUBDIRS += src_tools_bootstrap_dbus From f704aba7fc73b75f7bc3a1be962b28859d83e3aa Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 10:14:48 +0100 Subject: [PATCH 087/304] Add a feature for Qt Testlib ... so that we can turn it off if we don't want to build it. Change-Id: Ib27386da4754d843d4e4cbb05f9542852efefb88 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- configure.json | 5 +++++ src/src.pro | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.json b/configure.json index 052aeac30c..c505c6ab91 100644 --- a/configure.json +++ b/configure.json @@ -938,6 +938,10 @@ "label": "Qt Sql", "output": [ "privateFeature" ] }, + "testlib": { + "label": "Qt Testlib", + "output": [ "privateFeature" ] + }, "widgets": { "label": "Qt Widgets", "condition": "features.gui", @@ -1133,6 +1137,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 "gui", "network", "sql", + "testlib", "widgets" ] }, { diff --git a/src/src.pro b/src/src.pro index fa408d4787..5b353fde09 100644 --- a/src/src.pro +++ b/src/src.pro @@ -144,7 +144,7 @@ qtConfig(regularexpression):pcre { SUBDIRS += src_corelib src_tools_qlalr TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain -SUBDIRS += src_xml src_testlib +SUBDIRS += src_xml qtConfig(network) { SUBDIRS += src_network src_plugins.depends += src_network @@ -153,6 +153,7 @@ qtConfig(sql) { SUBDIRS += src_sql src_plugins.depends += src_sql } +qtConfig(testlib): SUBDIRS += src_testlib qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ SUBDIRS += src_tools_bootstrap_dbus From 20e0bca834a1cae1816f17ef0dbfe8b74192d8dd Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 10:43:47 +0100 Subject: [PATCH 088/304] Add a feature for Qt Xml ... so that we can turn it off if we don't want to build it. Change-Id: Ia330dfa1477bcd2dc8e24eb55400e100fca156b5 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- configure.json | 7 ++++++- src/src.pro | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure.json b/configure.json index c505c6ab91..6dffa33289 100644 --- a/configure.json +++ b/configure.json @@ -951,6 +951,10 @@ { "type": "publicQtConfig", "negative": true } ] }, + "xml": { + "label": "Qt Xml", + "output": [ "privateFeature" ] + }, "libudev": { "label": "udev", "condition": "libs.libudev", @@ -1138,7 +1142,8 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 "network", "sql", "testlib", - "widgets" + "widgets", + "xml" ] }, { "section": "Support enabled for", diff --git a/src/src.pro b/src/src.pro index 5b353fde09..c0366f32b6 100644 --- a/src/src.pro +++ b/src/src.pro @@ -124,7 +124,6 @@ src_printsupport.depends = src_corelib src_gui src_widgets src_tools_uic src_plugins.subdir = $$PWD/plugins src_plugins.target = sub-plugins -src_plugins.depends = src_xml src_android.subdir = $$PWD/android @@ -144,7 +143,6 @@ qtConfig(regularexpression):pcre { SUBDIRS += src_corelib src_tools_qlalr TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain -SUBDIRS += src_xml qtConfig(network) { SUBDIRS += src_network src_plugins.depends += src_network @@ -153,6 +151,7 @@ qtConfig(sql) { SUBDIRS += src_sql src_plugins.depends += src_sql } +qtConfig(xml): SUBDIRS += src_xml qtConfig(testlib): SUBDIRS += src_testlib qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ From 4a738424aaef7958917b92bd64a08eb6208d9c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 5 Jan 2017 15:01:02 +0100 Subject: [PATCH 089/304] Fall back to platform theme in QPlatformSystemTrayIcon::createMenu() Commit 824f08046 introduced QPlatformSystemTrayIcon::createMenu() as a way for platforms to provide a system tray menu independently of the menu created by QPlatformTheme::createPlatformMenu(), which would on some platforms be null. Commit 063997f44ffc then made menu creation lazy, which meant that the logic in QSystemTrayIconPrivate::addPlatformMenu() to create the menu turned from "create menu via QPSTI::createMenu() if QPT::createPlatformMenu() returned null", to "create menu via QPSTI::createMenu() if menu was not created yet". The latter logic relied on each platform having implementations of QPlatformSystemTrayIcon::createMenu() which they didn't, resulting in missing menus for system trays on e.g. macOS. With the new lazy logic, the reasonable approach is for the default implementation of createMenu() to use createPlatformMenu(), which will ensure system tray menus on platforms that implement createPlatformMenu(), while still allowing platforms that don't to override createMenu() for special-casing system tray menus. Task-number: QTBUG-57365 Change-Id: Id393e802ac0435200fc885a7f4436b744962f27f Reviewed-by: J-P Nurmi --- src/gui/kernel/qplatformsystemtrayicon.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qplatformsystemtrayicon.cpp b/src/gui/kernel/qplatformsystemtrayicon.cpp index 30db966df7..973b998059 100644 --- a/src/gui/kernel/qplatformsystemtrayicon.cpp +++ b/src/gui/kernel/qplatformsystemtrayicon.cpp @@ -40,6 +40,9 @@ #include "qplatformsystemtrayicon.h" +#include +#include + #ifndef QT_NO_SYSTEMTRAYICON QT_BEGIN_NAMESPACE @@ -158,11 +161,10 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() */ /*! - This method is called in case there is no QPlatformMenu available when - updating the menu. This allows the abstraction to provide a menu for the - system tray icon even if normally a non-native menu is used. - - The default implementation returns a null pointer. + This method allows platforms to use a different QPlatformMenu for system + tray menus than what would normally be used for e.g. menu bars. The default + implementation falls back to a platform menu created by the platform theme, + which may be null on platforms without native menus. \sa updateMenu() \since 5.3 @@ -170,7 +172,7 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() QPlatformMenu *QPlatformSystemTrayIcon::createMenu() const { - return Q_NULLPTR; + return QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); } QT_END_NAMESPACE From cfba3fff052b0af411d21727a68e78ea3e6a21d0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 16:59:36 +0100 Subject: [PATCH 090/304] move emission of final messages to qmake-based configure now qmake is the last command called by the unix configure script. as it happens, this was already the case in the windows script, but only because it didn't print these messages at all, which it implicitly does now. another effect of this is that repositories outside qtbase will now also get the installation note in modular builds, which makes sense. Change-Id: I567146936b216185a8e0f61e445222215608bf13 Reviewed-by: Lars Knoll --- configure | 97 ++++++----------------------- configure.pri | 4 ++ mkspecs/features/configure_base.prf | 1 + mkspecs/features/qt_configure.prf | 16 +++++ 4 files changed, 41 insertions(+), 77 deletions(-) diff --git a/configure b/configure index 7df10cec6a..d6a263dc8e 100755 --- a/configure +++ b/configure @@ -539,8 +539,8 @@ fi # platform detection #------------------------------------------------------------------------------- +PLATFORM_NOTES= if [ -z "$PLATFORM" ]; then - PLATFORM_NOTES= case "$UNAME_SYSTEM:$UNAME_RELEASE" in Darwin:*) PLATFORM=macx-clang @@ -550,9 +550,7 @@ if [ -z "$PLATFORM" ]; then #PLATFORM=aix-g++-64 PLATFORM=aix-xlc #PLATFORM=aix-xlc-64 - PLATFORM_NOTES=" - - Also available for AIX: aix-g++ aix-g++-64 aix-xlc-64 - " + PLATFORM_NOTES="AIX: aix-g++ aix-g++-64 aix-xlc-64" ;; GNU:*) PLATFORM=hurd-g++ @@ -569,14 +567,10 @@ if [ -z "$PLATFORM" ]; then FreeBSD:*) if [ "$(uname -r | cut -d. -f1)" -ge 10 ]; then PLATFORM=freebsd-clang - PLATFORM_NOTES=" - - Also available for FreeBSD: freebsd-g++ - " + PLATFORM_NOTES="FreeBSD: freebsd-g++" else PLATFORM=freebsd-g++ - PLATFORM_NOTES=" - - Also available for FreeBSD: freebsd-clang - " + PLATFORM_NOTES="FreeBSD: freebsd-clang" fi ;; OpenBSD:*) @@ -592,18 +586,14 @@ if [ -z "$PLATFORM" ]; then #PLATFORM=irix-g++ PLATFORM=irix-cc #PLATFORM=irix-cc-64 - PLATFORM_NOTES=" - - Also available for IRIX: irix-g++ irix-cc-64 - " + PLATFORM_NOTES="IRIX: irix-g++ irix-cc-64" ;; HP-UX:*) case "$UNAME_MACHINE" in ia64) #PLATFORM=hpuxi-acc-32 PLATFORM=hpuxi-acc-64 - PLATFORM_NOTES=" - - Also available for HP-UXi: hpuxi-acc-32 - " + PLATFORM_NOTES="HP-UXi: hpuxi-acc-32" ;; *) #PLATFORM=hpux-g++ @@ -611,39 +601,29 @@ if [ -z "$PLATFORM" ]; then #PLATFORM=hpux-acc-64 #PLATFORM=hpux-cc #PLATFORM=hpux-acc-o64 - PLATFORM_NOTES=" - - Also available for HP-UX: hpux-g++ hpux-acc-64 hpux-acc-o64 - " + PLATFORM_NOTES="HP-UX: hpux-g++ hpux-acc-64 hpux-acc-o64" ;; esac ;; OSF1:*) #PLATFORM=tru64-g++ PLATFORM=tru64-cxx - PLATFORM_NOTES=" - - Also available for Tru64: tru64-g++ - " + PLATFORM_NOTES="Tru64: tru64-g++" ;; Linux:*) PLATFORM=linux-g++ - PLATFORM_NOTES=" - - Also available for Linux: linux-clang linux-kcc linux-icc linux-cxx - " + PLATFORM_NOTES="Linux: linux-clang linux-kcc linux-icc linux-cxx" ;; SunOS:5*) #PLATFORM=solaris-g++ PLATFORM=solaris-cc #PLATFORM=solaris-cc64 - PLATFORM_NOTES=" - - Also available for Solaris: solaris-g++ solaris-cc-64 - " + PLATFORM_NOTES="Solaris: solaris-g++ solaris-cc-64" ;; ReliantUNIX-*:*|SINIX-*:*) PLATFORM=reliant-cds #PLATFORM=reliant-cds-64 - PLATFORM_NOTES=" - - Also available for Reliant UNIX: reliant-cds-64 - " + PLATFORM_NOTES="Reliant UNIX: reliant-cds-64" ;; CYGWIN*:*) PLATFORM=cygwin-g++ @@ -654,23 +634,17 @@ if [ -z "$PLATFORM" ]; then OpenUNIX:*) #PLATFORM=unixware-g++ PLATFORM=unixware-cc - PLATFORM_NOTES=" - - Also available for OpenUNIX: unixware-g++ - " + PLATFORM_NOTES="OpenUNIX: unixware-g++" ;; UnixWare:*) #PLATFORM=unixware-g++ PLATFORM=unixware-cc - PLATFORM_NOTES=" - - Also available for UnixWare: unixware-g++ - " + PLATFORM_NOTES="UnixWare: unixware-g++" ;; SCO_SV:*) #PLATFORM=sco-g++ PLATFORM=sco-cc - PLATFORM_NOTES=" - - Also available for SCO OpenServer: sco-g++ - " + PLATFORM_NOTES="SCO OpenServer: sco-g++" ;; UNIX_SV:*) PLATFORM=unixware-g++ @@ -688,6 +662,7 @@ if [ -z "$PLATFORM" ]; then exit 2 esac fi +echo "$PLATFORM_NOTES" > "${outpathPrefix}.config.notes" #------------------------------------------------------------------------------- # command line and environment validation @@ -905,13 +880,13 @@ Prefix=$relpath EOF fi +#------------------------------------------------------------------------------- +# configure and build top-level makefile +#------------------------------------------------------------------------------- + [ -z "$CFG_HOST_QT_TOOLS_PATH" ] && CFG_HOST_QT_TOOLS_PATH="$outpath/bin" CFG_QMAKE_PATH="$CFG_HOST_QT_TOOLS_PATH/qmake" -#------------------------------------------------------------------------------- -# run configure tests -#------------------------------------------------------------------------------- - # recreate command line for qmake set -f SAVED_IFS=$IFS @@ -923,40 +898,8 @@ done set +f IFS=$SAVED_IFS -#------------------------------------------------------------------------------- -# configure and build top-level makefile -#------------------------------------------------------------------------------- - if [ -n "$CFG_TOPLEVEL" ]; then cd .. fi -"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@" || exit - -#------------------------------------------------------------------------------- -# final notes for the user -#------------------------------------------------------------------------------- - -if [ -n "$PLATFORM_NOTES" ]; then - echo - echo "Platform notes:" - echo "$PLATFORM_NOTES" -else - echo -fi - -QT_INSTALL_PREFIX=`sed -ne 's/^Prefix=//p' < "$outpath/qmake/builtin-qt.conf"` -MAKE=`basename "$MAKE"` -echo -echo Qt is now configured for building. Just run \'$MAKE\'. -if [ "$outpath" = "$QT_INSTALL_PREFIX" ]; then - echo Once everything is built, Qt is installed. - echo You should not run \'$MAKE install\'. -else - echo Once everything is built, you must run \'$MAKE install\'. - echo Qt will be installed into $QT_INSTALL_PREFIX -fi -echo -echo Prior to reconfiguration, make sure you remove any leftovers from -echo the previous build. -echo +"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@" diff --git a/configure.pri b/configure.pri index 1744972f92..3f9a7e208c 100644 --- a/configure.pri +++ b/configure.pri @@ -458,6 +458,10 @@ defineTest(qtConfOutput_prepareSpec) { QMAKESPEC = $$[QT_HOST_DATA/src]/mkspecs/$$XSPEC export(QMAKESPEC) + notes = $$cat($$OUT_PWD/.config.notes, lines) + !isEmpty(notes): \ + qtConfAddNote("Also available for $$notes") + # deviceOptions() below contains conditionals coming form the spec, # so this cannot be delayed for a batch reload. reloadSpec() diff --git a/mkspecs/features/configure_base.prf b/mkspecs/features/configure_base.prf index 41f429e204..a4464528b4 100644 --- a/mkspecs/features/configure_base.prf +++ b/mkspecs/features/configure_base.prf @@ -19,6 +19,7 @@ QMAKE_MAKE = $$(MAKE) } else { error("Configure tests are not supported with the $$MAKEFILE_GENERATOR Makefile generator.") } +QMAKE_MAKE_NAME = $$basename(QMAKE_MAKE) # Make sure we don't inherit MAKEFLAGS - -i in particular is fatal. QMAKE_MAKE = "$${SETENV_PFX}MAKEFLAGS=$$SETENV_SFX $$QMAKE_MAKE" diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index ca66862abc..8eb8f22347 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1851,3 +1851,19 @@ for (p, QMAKE_POST_CONFIGURE): \ logn("Configure summary:") logn() qtConfPrintReport() + +# final notes for the user +logn() +logn("Qt is now configured for building. Just run '$$QMAKE_MAKE_NAME'.") +pfx = $$[QT_INSTALL_PREFIX] +equals(pfx, $$[QT_INSTALL_PREFIX/get]) { + logn("Once everything is built, Qt is installed.") + logn("You should NOT run '$$QMAKE_MAKE_NAME install'.") +} else { + logn("Once everything is built, you must run '$$QMAKE_MAKE_NAME install'.") + logn("Qt will be installed into '$$system_path($$pfx)'.") +} +logn() +logn("Prior to reconfiguration, make sure you remove any leftovers from") +logn("the previous build.") +logn() From 17b6967f6811cb3adeb8c7eb79a422d2c10ee0d1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 17:44:15 +0100 Subject: [PATCH 091/304] don't unnecessarily pass -qtconf to qmake it makes the call more noisy for no particular reason. and the new code is even easier to read ... Change-Id: Ib4dfd373f351eeaca99e6bfc42b631f931ec987d Reviewed-by: Lars Knoll Reviewed-by: Joerg Bornemann --- configure | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure b/configure index d6a263dc8e..074606dfe9 100755 --- a/configure +++ b/configure @@ -884,9 +884,6 @@ fi # configure and build top-level makefile #------------------------------------------------------------------------------- -[ -z "$CFG_HOST_QT_TOOLS_PATH" ] && CFG_HOST_QT_TOOLS_PATH="$outpath/bin" -CFG_QMAKE_PATH="$CFG_HOST_QT_TOOLS_PATH/qmake" - # recreate command line for qmake set -f SAVED_IFS=$IFS @@ -902,4 +899,8 @@ if [ -n "$CFG_TOPLEVEL" ]; then cd .. fi -"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@" +if [ -n "$CFG_HOST_QT_TOOLS_PATH" ]; then + "$CFG_HOST_QT_TOOLS_PATH/qmake" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@" +else + "$outpath/bin/qmake" "$relpathMangled" -- "$@" +fi From 52d64fca662d0e488801fc40dffdc0a732cfdbd5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 16:40:30 +0100 Subject: [PATCH 092/304] revert to building qmake with qconfig.cpp turns out that just appending builtin-qt.conf isn't a good idea: executable-editing tools (objcopy, prelink, etc.) will happily drop the "attachment". a safe method would be adding a proper section to the executable, but there doesn't appear to be an objcopy equivalent in msvc, and using entirely different methods of embedding the file with different toolchains seems like a rather bad idea. so instead go back to the old method of building qmake with a generated qconfig.cpp. of course, as said file is now created by qmake itself, we have to compile qlibraryinfo.cpp a second time, and link a second qmake executable. Task-number: QTBUG-57803 Change-Id: I9e232693550aa870cec154e49cc06add13017cc2 Reviewed-by: Lars Knoll --- configure.json | 1 - configure.pri | 48 ++++++++----- qmake/Makefile.unix | 16 +++-- qmake/Makefile.win32 | 21 ++++-- qmake/option.cpp | 5 -- qmake/qmake-aux.pro | 8 +-- src/corelib/global/qlibraryinfo.cpp | 100 +++++----------------------- src/corelib/global/qlibraryinfo.h | 1 - 8 files changed, 79 insertions(+), 121 deletions(-) diff --git a/configure.json b/configure.json index 6dffa33289..f9abdae8ca 100644 --- a/configure.json +++ b/configure.json @@ -1,6 +1,5 @@ { "files": { - "builtinQtConf": "qmake/builtin-qt.conf", "qconfigSource": "src/corelib/global/qconfig.cpp", "publicHeader": "src/corelib/global/qconfig.h", "privateHeader": "src/corelib/global/qconfig_p.h", diff --git a/configure.pri b/configure.pri index 3f9a7e208c..b184ceff5b 100644 --- a/configure.pri +++ b/configure.pri @@ -748,40 +748,56 @@ defineTest(qtConfOutput_preparePaths) { addConfStr($$config.rel_input.examplesdir) addConfStr($$config.rel_input.testsdir) + QT_CONFIGURE_STR_OFFSETS_ALL = $$QT_CONFIGURE_STR_OFFSETS + QT_CONFIGURE_STRS_ALL = $$QT_CONFIGURE_STRS + QT_CONFIGURE_STR_OFFSETS = + QT_CONFIGURE_STRS = + + addConfStr($$config.input.sysroot) + addConfStr($$qmake_sysrootify) + addConfStr($$config.rel_input.hostbindir) + addConfStr($$config.rel_input.hostlibdir) + addConfStr($$config.rel_input.hostdatadir) + addConfStr($$XSPEC) + addConfStr($$[QMAKE_SPEC]) + $${currentConfig}.output.qconfigSource = \ "/* Installation date */" \ "static const char qt_configure_installation [12+11] = \"qt_instdate=2012-12-20\";" \ "" \ "/* Installation Info */" \ "static const char qt_configure_prefix_path_str [12+256] = \"qt_prfxpath=$$config.input.prefix\";" \ + "$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \ + "static const char qt_configure_ext_prefix_path_str [12+256] = \"qt_epfxpath=$$config.input.extprefix\";" \ + "static const char qt_configure_host_prefix_path_str [12+256] = \"qt_hpfxpath=$$config.input.hostprefix\";" \ + "$${LITERAL_HASH}endif" \ "" \ "static const short qt_configure_str_offsets[] = {" \ + $$QT_CONFIGURE_STR_OFFSETS_ALL \ + "$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \ $$QT_CONFIGURE_STR_OFFSETS \ + "$${LITERAL_HASH}endif" \ "};" \ "static const char qt_configure_strs[] =" \ + $$QT_CONFIGURE_STRS_ALL \ + "$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \ $$QT_CONFIGURE_STRS \ + "$${LITERAL_HASH}endif" \ ";" \ "" \ "$${LITERAL_HASH}define QT_CONFIGURE_SETTINGS_PATH \"$$config.rel_input.sysconfdir\"" \ "" \ - "$${LITERAL_HASH}define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12" + "$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \ + "$${LITERAL_HASH} define QT_CONFIGURE_SYSROOTIFY_PREFIX $$qmake_sysrootify" \ + "$${LITERAL_HASH}endif" \ + "" \ + "$${LITERAL_HASH}define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12" \ + "$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \ + "$${LITERAL_HASH} define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12" \ + "$${LITERAL_HASH} define QT_CONFIGURE_HOST_PREFIX_PATH qt_configure_host_prefix_path_str + 12" \ + "$${LITERAL_HASH}endif" export($${currentConfig}.output.qconfigSource) - # populate qmake/builtin-qt.conf - - $${currentConfig}.output.builtinQtConf = \ - " " \ - "===========================================================" \ - "==================== qt.conf beginning ====================" \ - "===========================================================" \ - "[Paths]" \ - "ExtPrefix=$$config.input.extprefix" \ - "Prefix=$$config.input.prefix" \ - $$printInstallPaths() \ - "Settings=$$config.rel_input.sysconfdir" \ - $$printHostPaths() - export($${currentConfig}.output.builtinQtConf) - # create bin/qt.conf. this doesn't use the regular file output # mechanism, as the file is relied upon by configure tests. diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 72431f51ea..8eb54f554e 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -16,7 +16,7 @@ QOBJS=qtextcodec.o qutfcodec.o qstring.o qstring_compat.o qstringbuilder.o qtext qarraydata.o qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfiledevice.o qfile.o \ qfilesystementry.o qfilesystemengine.o qfsfileengine.o qfsfileengine_iterator.o qregexp.o qvector.o \ qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o qfileinfo.o qdatetime.o qstringlist.o \ - qabstractfileengine.o qtemporaryfile.o qmap.o qmetatype.o qsettings.o qsystemerror.o qlibraryinfo.o \ + qabstractfileengine.o qtemporaryfile.o qmap.o qmetatype.o qsettings.o qsystemerror.o \ qvariant.o qvsnprintf.o qlocale.o qlocale_tools.o qlinkedlist.o qnumeric.o \ qcryptographichash.o qxmlstream.o qxmlutils.o qlogging.o \ qjson.o qjsondocument.o qjsonparser.o qjsonarray.o qjsonobject.o qjsonvalue.o \ @@ -109,19 +109,24 @@ LFLAGS = $(EXTRA_LFLAGS) $(CONFIG_LFLAGS) first all: $(BUILD_PATH)/bin/qmake$(EXEEXT) qmake: $(BUILD_PATH)/bin/qmake$(EXEEXT) +binary: $(BUILD_PATH)/qmake/qmake$(EXEEXT) -$(BUILD_PATH)/bin/qmake$(EXEEXT): $(OBJS) $(QOBJS) - $(CXX) -o "$@" $(OBJS) $(QOBJS) $(LFLAGS) +$(BUILD_PATH)/bin/qmake$(EXEEXT): $(OBJS) $(QOBJS) qlibraryinfo.o + $(CXX) -o "$@" $(OBJS) $(QOBJS) qlibraryinfo.o $(LFLAGS) + +$(BUILD_PATH)/qmake/qmake$(EXEEXT): $(OBJS) $(QOBJS) qlibraryinfo_final.o + $(CXX) -o "$@" $(OBJS) $(QOBJS) qlibraryinfo_final.o $(LFLAGS) Makefile: $(SOURCE_PATH)/qmake/Makefile.unix @echo "Out of date, please rerun configure" clean:: - $(RM_F) $(OBJS) $(QOBJS) + $(RM_F) $(OBJS) $(QOBJS) qlibraryinfo.o qlibraryinfo_final.o distclean:: clean $(RM_RF) .deps $(RM_F) $(BUILD_PATH)/bin/qmake$(EXEEXT) + $(RM_F) $(BUILD_PATH)/qmake/qmake$(EXEEXT) $(RM_F) Makefile depend: @@ -227,6 +232,9 @@ qsystemerror.o: $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp qlibraryinfo.o: $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp + $(CXX) -c -o $@ $(CXXFLAGS) -DQT_BUILD_QMAKE_BOOTSTRAP $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp + +qlibraryinfo_final.o: $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp $(BUILD_PATH)/src/corelib/global/qconfig.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp qnumeric.o: $(SOURCE_PATH)/src/corelib/global/qnumeric.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 9e1f5136ef..c2e32dfc20 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -108,7 +108,6 @@ QTOBJS= \ quuid.obj \ qvector.obj \ qsettings.obj \ - qlibraryinfo.obj \ qvariant.obj \ qsettings_win.obj \ qmetatype.obj \ @@ -124,12 +123,16 @@ QTOBJS= \ qjsonvalue.obj first all: $(BUILD_PATH)\bin\qmake.exe +binary: $(BUILD_PATH)\qmake\qmake.exe -$(BUILD_PATH)\bin\qmake.exe: $(OBJS) $(QTOBJS) - $(LINKER) $(LFLAGS) /OUT:$(BUILD_PATH)\bin\qmake.exe $(OBJS) $(QTOBJS) $(PCH_OBJECT) $(LIBS) +$(BUILD_PATH)\bin\qmake.exe: $(OBJS) $(QTOBJS) qlibraryinfo.obj + $(LINKER) $(LFLAGS) /OUT:$(BUILD_PATH)\bin\qmake.exe $(OBJS) $(QTOBJS) qlibraryinfo.obj $(PCH_OBJECT) $(LIBS) + +$(BUILD_PATH)\qmake\qmake.exe: $(OBJS) $(QTOBJS) qlibraryinfo_final.obj + $(LINKER) $(LFLAGS) /OUT:$(BUILD_PATH)\qmake\qmake.exe $(OBJS) $(QTOBJS) qlibraryinfo_final.obj $(PCH_OBJECT) $(LIBS) clean:: - -del $(QTOBJS) + -del $(QTOBJS) qlibraryinfo.obj qlibraryinfo_final.obj -del $(OBJS) -del qmake_pch.obj -del qmake_pch.pch @@ -139,6 +142,7 @@ clean:: distclean:: clean -del $(BUILD_PATH)\bin\qmake.exe + -del $(BUILD_PATH)\qmake\qmake.exe -del Makefile .cpp.obj: @@ -148,6 +152,9 @@ $(OBJS): $(PCH_OBJECT) $(QTOBJS): $(PCH_OBJECT) +qlibraryinfo.obj: $(PCH_OBJECT) +qlibraryinfo_final.obj: $(PCH_OBJECT) + qmake_pch.obj: $(CXX) $(CXXFLAGS_BARE) -c -Yc -Fpqmake_pch.pch -TP $(QMKSRC)\qmake_pch.h @@ -199,3 +206,9 @@ qmake_pch.obj: # Make sure qstring_compat.obj isn't compiled with PCH enabled qstring_compat.obj: $(SOURCE_PATH)\src\corelib\tools\qstring_compat.cpp $(CXX) -c $(CXXFLAGS_BARE) $(SOURCE_PATH)\src\corelib\tools\qstring_compat.cpp + +qlibraryinfo.obj: $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp + $(CXX) $(CXXFLAGS) -DQT_BUILD_QMAKE_BOOTSTRAP $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp + +qlibraryinfo_final.obj: $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp $(BUILD_PATH)\src\corelib\global\qconfig.cpp + $(CXX) $(CXXFLAGS) -Foqlibraryinfo_final.obj $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp diff --git a/qmake/option.cpp b/qmake/option.cpp index b8102ecf06..fb49f5a100 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -638,11 +638,6 @@ qmakeAddCacheClear(qmakeCacheClearFunc func, void **data) cache_items.append(new QMakeCacheClearItem(func, data)); } -QString qmake_absoluteLocation() -{ - return Option::globals->qmake_abslocation; -} - QString qmake_libraryInfoFile() { if (!Option::globals->qtconf.isEmpty()) diff --git a/qmake/qmake-aux.pro b/qmake/qmake-aux.pro index 357ebc7367..f432fab05d 100644 --- a/qmake/qmake-aux.pro +++ b/qmake/qmake-aux.pro @@ -9,14 +9,10 @@ win32: EXTENSION = .exe !build_pass { qmake_exe.target = $$OUT_PWD/qmake$$EXTENSION - qmake_exe.depends = ../bin/qmake$$EXTENSION builtin-qt.conf - equals(QMAKE_DIR_SEP, /): \ - qmake_exe.commands = cat ../bin/qmake$$EXTENSION builtin-qt.conf > qmake$$EXTENSION && chmod +x qmake$$EXTENSION - else: \ - qmake_exe.commands = copy /B ..\bin\qmake$$EXTENSION + builtin-qt.conf qmake$$EXTENSION + qmake_exe.commands = $(MAKE) binary + qmake_exe.CONFIG = phony QMAKE_EXTRA_TARGETS += qmake_exe - QMAKE_CLEAN += builtin-qt.conf QMAKE_DISTCLEAN += qmake$$EXTENSION first.depends += qmake_exe diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 3ff37a5818..0de8b50900 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -41,18 +41,15 @@ #include "qdir.h" #include "qstringlist.h" #include "qfile.h" -#include "qtemporaryfile.h" #include "qsettings.h" #include "qlibraryinfo.h" #include "qscopedpointer.h" #ifdef QT_BUILD_QMAKE QT_BEGIN_NAMESPACE -extern QString qmake_absoluteLocation(); extern QString qmake_libraryInfoFile(); QT_END_NAMESPACE #else -# include "qconfig.cpp" # include "qcoreapplication.h" #endif @@ -60,6 +57,10 @@ QT_END_NAMESPACE # include "private/qcore_mac_p.h" #endif +#ifndef QT_BUILD_QMAKE_BOOTSTRAP +# include "qconfig.cpp" +#endif + #include "archdetect.cpp" QT_BEGIN_NAMESPACE @@ -72,16 +73,9 @@ struct QLibrarySettings { QLibrarySettings(); void load(); -#ifdef QT_BUILD_QMAKE - void loadBuiltinValues(QSettings *config); -#endif QScopedPointer settings; #ifdef QT_BUILD_QMAKE - QString builtinValues[QLibraryInfo::LastHostPath + 1]; -# ifndef Q_OS_WIN - QString builtinSettingsPath; -# endif bool haveDevicePaths; bool haveEffectiveSourcePaths; bool haveEffectivePaths; @@ -113,18 +107,6 @@ public: ? ls->haveDevicePaths : ls->havePaths) : false; } - static QString builtinValue(int loc) - { - QLibrarySettings *ls = qt_library_settings(); - return ls ? ls->builtinValues[loc] : QString(); - } -# ifndef Q_OS_WIN - static QString builtinSettingsPath() - { - QLibrarySettings *ls = qt_library_settings(); - return ls ? ls->builtinSettingsPath : QString(); - } -# endif #endif static QSettings *configuration() { @@ -148,20 +130,6 @@ QLibrarySettings::QLibrarySettings() load(); } -#ifdef QT_BUILD_QMAKE -static QByteArray qtconfSeparator() -{ -# ifdef Q_OS_WIN - QByteArray header = QByteArrayLiteral("\r\n===========================================================\r\n"); -# else - QByteArray header = QByteArrayLiteral("\n===========================================================\n"); -# endif - QByteArray content = QByteArrayLiteral("==================== qt.conf beginning ===================="); - // Assemble from pieces to avoid that the string appears in a raw executable - return header + content + header; -} -#endif - void QLibrarySettings::load() { // If we get any settings here, those won't change when the application shows up. @@ -199,27 +167,6 @@ void QLibrarySettings::load() havePaths = false; #endif } - -#ifdef QT_BUILD_QMAKE - // Try to use an embedded qt.conf appended to the QMake executable. - QFile qmakeFile(qmake_absoluteLocation()); - if (!qmakeFile.open(QIODevice::ReadOnly)) - return; - qmakeFile.seek(qmakeFile.size() - 10000); - QByteArray tail = qmakeFile.read(10000); - QByteArray separator = qtconfSeparator(); - int qtconfOffset = tail.lastIndexOf(separator); - if (qtconfOffset < 0) - return; - tail.remove(0, qtconfOffset + separator.size()); - // If QSettings had a c'tor taking a QIODevice, we'd pass a QBuffer ... - QTemporaryFile tmpFile; - tmpFile.open(); - tmpFile.write(tail); - tmpFile.close(); - QSettings builtinSettings(tmpFile.fileName(), QSettings::IniFormat); - loadBuiltinValues(&builtinSettings); -#endif } QSettings *QLibraryInfoPrivate::findConfiguration() @@ -482,24 +429,11 @@ static const struct { { "HostData", "." }, { "TargetSpec", "" }, { "HostSpec", "" }, - { "ExtPrefix", "" }, { "HostPrefix", "" }, #endif }; #ifdef QT_BUILD_QMAKE -void QLibrarySettings::loadBuiltinValues(QSettings *config) -{ - config->beginGroup(QLatin1String("Paths")); - for (int i = 0; i <= QLibraryInfo::LastHostPath; i++) - builtinValues[i] = config->value(QLatin1String(qtConfEntries[i].key), - QLatin1String(qtConfEntries[i].value)).toString(); -# ifndef Q_OS_WIN - builtinSettingsPath = config->value(QLatin1String("Settings")).toString(); -# endif - config->endGroup(); -} - void QLibraryInfo::reload() { QLibraryInfoPrivate::reload(); @@ -613,34 +547,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) } #endif // QT_NO_SETTINGS +#ifndef QT_BUILD_QMAKE_BOOTSTRAP if (!fromConf) { -#ifdef QT_BUILD_QMAKE - if ((unsigned)loc <= (unsigned)LastHostPath) { - if (loc == PrefixPath && group != DevicePaths) - ret = QLibraryInfoPrivate::builtinValue(ExtPrefixPath); - else - ret = QLibraryInfoPrivate::builtinValue(loc); -# ifndef Q_OS_WIN // On Windows we use the registry - } else if (loc == SettingsPath) { - ret = QLibraryInfoPrivate::builtinSettingsPath(); -# endif - } -#else // QT_BUILD_QMAKE const char * volatile path = 0; if (loc == PrefixPath) { - path = QT_CONFIGURE_PREFIX_PATH; + path = +# ifdef QT_BUILD_QMAKE + (group != DevicePaths) ? + QT_CONFIGURE_EXT_PREFIX_PATH : +# endif + QT_CONFIGURE_PREFIX_PATH; } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) { path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; #ifndef Q_OS_WIN // On Windows we use the registry } else if (loc == SettingsPath) { path = QT_CONFIGURE_SETTINGS_PATH; #endif +# ifdef QT_BUILD_QMAKE + } else if (loc == HostPrefixPath) { + path = QT_CONFIGURE_HOST_PREFIX_PATH; +# endif } if (path) ret = QString::fromLocal8Bit(path); -#endif } +#endif #ifdef QT_BUILD_QMAKE // These values aren't actually paths and thus need to be returned verbatim. diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 812ab9a263..809813d99d 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -97,7 +97,6 @@ public: HostDataPath, TargetSpecPath, HostSpecPath, - ExtPrefixPath, HostPrefixPath, LastHostPath = HostPrefixPath, #endif From 34cc41d8a17e6e30f01f22c5d382c28d49ae37e1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 19:10:14 +0100 Subject: [PATCH 093/304] don't pass qmake configure arguments to sub-projects the arguments after '--' are by definition meant only for the top-level project, as that's where configure is invoked from. passing them to sub-projects just adds noise to the make output and misleads users. note that this specifically does not support qmake -r, which will break if the subprojects rely on the arguments being absent. this isn't a problem, because the qt build doesn't support qmake -r anyway. Change-Id: I7ecff6212ce3137526005fc324a4a7ae45e3345e Reviewed-by: Joerg Bornemann --- qmake/generators/makefile.cpp | 15 ++++++++++----- qmake/generators/makefile.h | 2 +- qmake/generators/unix/unixmake2.cpp | 2 +- qmake/library/qmakeglobals.cpp | 2 +- qmake/library/qmakeglobals.h | 2 +- qmake/option.cpp | 1 + 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 1ba2587bd0..2845888dde 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2254,12 +2254,17 @@ MakefileGenerator::writeDefaultVariables(QTextStream &t) t << "MOVE = " << var("QMAKE_MOVE") << endl; } -QString MakefileGenerator::buildArgs() +QString MakefileGenerator::buildArgs(bool withExtra) { QString ret; for (const QString &arg : qAsConst(Option::globals->qmake_args)) ret += " " + shellQuote(arg); + if (withExtra && !Option::globals->qmake_extra_args.isEmpty()) { + ret += " --"; + for (const QString &arg : qAsConst(Option::globals->qmake_extra_args)) + ret += " " + shellQuote(arg); + } return ret; } @@ -2278,7 +2283,7 @@ QString MakefileGenerator::build_args() ret += " " + escapeFilePath(fileFixify(project->projectFile())); // general options and arguments - ret += buildArgs(); + ret += buildArgs(true); return ret; } @@ -2442,7 +2447,7 @@ MakefileGenerator::writeSubTargetCall(QTextStream &t, if (!in_directory.isEmpty()) t << "\n\t" << mkdir_p_asstring(out_directory); pfx = "( " + chkexists.arg(out) + - + " $(QMAKE) -o " + out + ' ' + in + buildArgs() + + " $(QMAKE) -o " + out + ' ' + in + buildArgs(false) + " ) && "; } writeSubMakeCall(t, out_directory_cdin + pfx, makefilein); @@ -2513,7 +2518,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QListisEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { QStringList files = escapeFilePaths(fileFixify(Option::mkfile::project_files)); t << escapeDependencyPath(project->first("QMAKE_INTERNAL_PRL_FILE").toQString()) << ": \n\t" - << "@$(QMAKE) -prl " << files.join(' ') << ' ' << buildArgs() << endl; + << "@$(QMAKE) -prl " << files.join(' ') << ' ' << buildArgs(true) << endl; } QString qmake = build_args(); diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h index 86fec748eb..4ced3bd121 100644 --- a/qmake/generators/makefile.h +++ b/qmake/generators/makefile.h @@ -178,7 +178,7 @@ protected: QString specdir(); //subclasses can use these to query information about how the generator was "run" - QString buildArgs(); + QString buildArgs(bool withExtra); virtual QStringList &findDependencies(const QString &file); virtual bool doDepends() const { return Option::mkfile::do_deps; } diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 6fa355390f..946906ba65 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -731,7 +731,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } if(!meta_files.isEmpty()) t << escapeDependencyPaths(meta_files).join(" ") << ": \n\t" - << "@$(QMAKE) -prl " << escapeFilePath(project->projectFile()) << ' ' << buildArgs() << endl; + << "@$(QMAKE) -prl " << escapeFilePath(project->projectFile()) << ' ' << buildArgs(true) << endl; } if (!project->isEmpty("QMAKE_BUNDLE")) { diff --git a/qmake/library/qmakeglobals.cpp b/qmake/library/qmakeglobals.cpp index b02bf4aaf8..b282b08d5c 100644 --- a/qmake/library/qmakeglobals.cpp +++ b/qmake/library/qmakeglobals.cpp @@ -138,7 +138,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( if (arg.startsWith(QLatin1Char('-'))) { if (arg == QLatin1String("--")) { state.extraargs = args.mid(*pos + 1); - *pos = args.size(); + args.erase(args.begin() + *pos, args.end()); return ArgumentsOk; } if (arg == QLatin1String("-after")) diff --git a/qmake/library/qmakeglobals.h b/qmake/library/qmakeglobals.h index 1bb8632883..86b1d28da4 100644 --- a/qmake/library/qmakeglobals.h +++ b/qmake/library/qmakeglobals.h @@ -105,7 +105,7 @@ public: QProcessEnvironment environment; #endif QString qmake_abslocation; - QStringList qmake_args; + QStringList qmake_args, qmake_extra_args; QString qtconf; QString qmakespec, xqmakespec; diff --git a/qmake/option.cpp b/qmake/option.cpp index fb49f5a100..9dcd343c8a 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -427,6 +427,7 @@ Option::init(int argc, char **argv) //return ret == QMAKE_CMDLINE_SHOW_USAGE ? usage(argv[0]) : false; } globals->qmake_args = args; + globals->qmake_extra_args = cmdstate.extraargs; } globals->commitCommandLineArguments(cmdstate); globals->debugLevel = Option::debug_level; From d6778c3597a6e06b866c5b7a994cac4d71aaead3 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 19:47:03 +0100 Subject: [PATCH 094/304] make skipping of configure in sub-repos less arcane this was introduced in 60e5a1c8 for no apparent reason. Change-Id: Idcbc6df3df4e4846c76b3e4215d753a1c97e2eec Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_configure.prf | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 8eb8f22347..7e2e5cfecc 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1698,16 +1698,18 @@ defineTest(qtConfProcessOutput) { # tie it all together # -cfgs = -isEmpty(_QMAKE_SUPER_CACHE_)|equals(OUT_PWD, $$dirname(_QMAKE_SUPER_CACHE_)) { - c = $$basename(_PRO_FILE_PWD_) - config.$${c}.dir = $$_PRO_FILE_PWD_ - cfgs += $$c - !isEmpty(_QMAKE_SUPER_CACHE_) { - for (s, SUBDIRS) { - config.$${s}.dir = $$_PRO_FILE_PWD_/$${s} - cfgs += $$s - } +!isEmpty(_QMAKE_SUPER_CACHE_):!equals(OUT_PWD, $$dirname(_QMAKE_SUPER_CACHE_)) { + # sub-repo within a top-level build; no need to configure anything. + return() +} + +c = $$basename(_PRO_FILE_PWD_) +config.$${c}.dir = $$_PRO_FILE_PWD_ +cfgs = $$c +!isEmpty(_QMAKE_SUPER_CACHE_) { + for (s, SUBDIRS) { + config.$${s}.dir = $$_PRO_FILE_PWD_/$${s} + cfgs += $$s } } configsToProcess = From 44a68aff6626d8e7beb040fe0d6dc52740e2a210 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 19:51:52 +0100 Subject: [PATCH 095/304] name top-level configure scope after the project file ... instead of the directory it resides in, to make it independent of the user's fs layout. this makes logs more comparable, and little else. Change-Id: I0ab3e968dad74ef86577f388c8ca1557e3c17ce4 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_configure.prf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 7e2e5cfecc..f517e69496 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1703,9 +1703,8 @@ defineTest(qtConfProcessOutput) { return() } -c = $$basename(_PRO_FILE_PWD_) -config.$${c}.dir = $$_PRO_FILE_PWD_ -cfgs = $$c +config.$${TARGET}.dir = $$_PRO_FILE_PWD_ +cfgs = $$TARGET !isEmpty(_QMAKE_SUPER_CACHE_) { for (s, SUBDIRS) { config.$${s}.dir = $$_PRO_FILE_PWD_/$${s} From 696c3f9af852537897aa754dc269833ead9fcf41 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 20:23:19 +0100 Subject: [PATCH 096/304] complain about various invalid configuration attempts Task-number: QTBUG-56049 Change-Id: Id5eeb014c2b88195d2d14566a62dcb9185206b37 Reviewed-by: Jake Petroules Reviewed-by: Joerg Bornemann --- configure | 5 +++++ configure.bat | 5 +++++ mkspecs/features/qt_configure.prf | 13 ++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 074606dfe9..8827e63a78 100755 --- a/configure +++ b/configure @@ -82,6 +82,11 @@ if [ x"$1" = x"-top-level" ]; then relpathMangled=`dirname "$relpath"` outpathPrefix=../ shift +else + if [ -f ../.qmake.super ]; then + echo >&2 "ERROR: You cannot configure qtbase separately within a top-level build." + exit 1 + fi fi OPT_CMDLINE= # expanded version for the script diff --git a/configure.bat b/configure.bat index c5daabfa65..47f1889277 100644 --- a/configure.bat +++ b/configure.bat @@ -46,7 +46,12 @@ for %%P in ("%TOPQTSRC%") do set TOPQTSRC=%%~dpP set TOPQTSRC=%TOPQTSRC:~0,-1% for %%P in ("%QTDIR%") do set TOPQTDIR=%%~dpP set TOPQTDIR=%TOPQTDIR:~0,-1% +goto wastoplevel :notoplevel +if not exist ..\.qmake.super goto wastoplevel +echo ERROR: You cannot configure qtbase separately within a top-level build. >&2 +exit /b 1 +:wastoplevel set SYNCQT= set PLATFORM= diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index f517e69496..3adefb743e 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1700,6 +1700,14 @@ defineTest(qtConfProcessOutput) { !isEmpty(_QMAKE_SUPER_CACHE_):!equals(OUT_PWD, $$dirname(_QMAKE_SUPER_CACHE_)) { # sub-repo within a top-level build; no need to configure anything. + !isEmpty(QMAKE_EXTRA_ARGS) { + # sub-projects don't get the extra args passed down automatically, + # so we can use their presence to detect misguided attempts to + # configure the repositories separately. + # caveat: a plain qmake call is indistinguishable from a recursion + # (by design), so we cannot detect this case. + error("You cannot configure $$TARGET separately within a top-level build.") + } return() } @@ -1717,8 +1725,11 @@ for (c, cfgs) { exists($$s/configure.json): \ configsToProcess += $$c } -isEmpty(configsToProcess): \ +isEmpty(configsToProcess) { + !isEmpty(QMAKE_EXTRA_ARGS): \ + error("This module does not accept configure command line arguments.") return() +} load(configure_base) From 9576b71fe8c0dea978f4bcbe15526e0e3e643cfd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 6 Dec 2016 17:27:50 +0100 Subject: [PATCH 097/304] import static plugins also into dlls static plugins must be actually linked into the target whenever it is not a static library itself. apart from fixing qml plugin linkage, this also provides a more generic fix for the already fixed linking of activeqt controls. Task-number: QTBUG-28215 Task-number: QTBUG-55279 Change-Id: I9661369bf3dfc6bcf3a5ed563e6716eb3ef6e76e Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index bfa6c7988d..a4e3b0247d 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -45,6 +45,9 @@ qaxserver { QT += axserver } +!force_import_plugins:!contains(TEMPLATE, ".*app"):!if(contains(TEMPLATE, ".*lib"):dll): \ + CONFIG -= import_plugins + # target variable, flag source variable defineTest(qtProcessModuleFlags) { for(flag, $$2) { @@ -191,9 +194,9 @@ qt_module_deps = $$resolve_depends(qt_module_deps, "QT.") QMAKE_RPATHLINKDIR *= $$unique(rpaths) } -# static builds: link qml import plugins into the app. +# static builds: link qml import plugins into the target. contains(qt_module_deps, qml): \ - qtConfig(static):contains(TEMPLATE, .*app):!host_build:!no_import_scan { + qtConfig(static):import_plugins:!host_build:!no_import_scan { exists($$[QT_INSTALL_QML/get]): \ QMLPATHS *= $$[QT_INSTALL_QML/get] @@ -249,7 +252,7 @@ contains(qt_module_deps, qml): \ QTPLUGIN.platforms = qminimal } -contains(TEMPLATE, .*app) { +import_plugins { autoplugs = for (qtmod, qt_module_deps) { for (ptype, QT.$${qtmod}.plugin_types) { @@ -282,7 +285,6 @@ contains(TEMPLATE, .*app) { } qtConfig(static) { - force_import_plugins|contains(TEMPLATE, .*app) { import_plugins:!isEmpty(QTPLUGIN) { IMPORT_FILE_CONT = \ "// This file is autogenerated by qmake. It imports static plugin classes for" \ @@ -300,7 +302,6 @@ qtConfig(static) { GENERATED_SOURCES += $$IMPORT_CPP QMAKE_DISTCLEAN += $$IMPORT_CPP } - } for (QTPLUG, $$list($$lower($$unique(QTPLUGIN)))) { # Check if the plugin is known to Qt. We can use this to determine From ac740d9d285a73e98c99495769782a0d5b934d7a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 18:43:00 +0100 Subject: [PATCH 098/304] statically link plugins for transitive deps' private deps as well while we already linked the plugins for our own private deps, we failed to do so for our transitive deps. this also fixes linking qml plugins if qml is linked only indirectly and privately. the code for setting up rpath-link is slightly refactored as a side effect, with no functional change. the code for setting up rpath now also sees the longer list of dependencies, but that's irrelevant, as qtcore always ends up among the direct deps anyway iff any non-bootstrapped modules are used. Change-Id: I90dca81a2836c6191ce5d092e16bf7660ee820bc Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index a4e3b0247d..564f3d774d 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -168,10 +168,10 @@ for(ever) { } qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE -qt_module_deps = $$resolve_depends(qt_module_deps, "QT.") +all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends") !no_qt_rpath:!static:qtConfig(rpath):!qtConfig(static):\ - contains(qt_module_deps, core) { + contains(all_qt_module_deps, core) { relative_qt_rpath:!isEmpty(QMAKE_REL_RPATH_BASE):contains(INSTALLS, target):\ isEmpty(target.files):isEmpty(target.commands):isEmpty(target.extra) { # NOT the /dev property, as INSTALLS use host paths @@ -186,8 +186,8 @@ qt_module_deps = $$resolve_depends(qt_module_deps, "QT.") # libraries which were NOT specified on the command line. # This means that paths of direct dependencies (QT & QT_PRIVATE) # don't need to be listed, unlike their private dependencies' paths. - privdep = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends") - privdep -= $$qt_module_deps + privdep = $$all_qt_module_deps + privdep -= $$resolve_depends(qt_module_deps, "QT.") rpaths = for(dep, privdep): \ rpaths += $$eval(QT.$${dep}.libs) @@ -195,7 +195,7 @@ qt_module_deps = $$resolve_depends(qt_module_deps, "QT.") } # static builds: link qml import plugins into the target. -contains(qt_module_deps, qml): \ +contains(all_qt_module_deps, qml): \ qtConfig(static):import_plugins:!host_build:!no_import_scan { exists($$[QT_INSTALL_QML/get]): \ QMLPATHS *= $$[QT_INSTALL_QML/get] @@ -254,14 +254,14 @@ contains(qt_module_deps, qml): \ import_plugins { autoplugs = - for (qtmod, qt_module_deps) { + for (qtmod, all_qt_module_deps) { for (ptype, QT.$${qtmod}.plugin_types) { nptype = $$replace(ptype, [-/], _) isEmpty(QTPLUGIN.$$nptype) { for (plug, QT_PLUGINS) { equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) { for (dep, QT_PLUGIN.$${plug}.EXTENDS) { - !contains(qt_module_deps, $$dep) { + !contains(all_qt_module_deps, $$dep) { plug = break() } From 623b191c10ad36a82e31b8af794b6e04ae18775f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 20:20:35 +0100 Subject: [PATCH 099/304] track plugins' qt dependencies plugins may pull in additional qt modules which may require additional plugins in turn. Change-Id: I22264b39c1397666b2dc9079048ed1fc64aa84d9 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 148 +++++++++++++++++++-------------- mkspecs/features/qt_plugin.prf | 4 + 2 files changed, 88 insertions(+), 64 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 564f3d774d..626cf9c809 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -45,9 +45,93 @@ qaxserver { QT += axserver } +!import_qpa_plugin { + warning("CONFIG-=import_qpa_plugin is deprecated. Use QTPLUGIN.platforms=- instead.") + QTPLUGIN.platforms = - +} else: qpa_minimal_plugin { + warning("CONFIG+=qpa_minimal_plugin is deprecated. Use QTPLUGIN.platforms=qminimal instead.") + QTPLUGIN.platforms = qminimal +} + !force_import_plugins:!contains(TEMPLATE, ".*app"):!if(contains(TEMPLATE, ".*lib"):dll): \ CONFIG -= import_plugins +# qmake variables cannot contain dashes, so normalize the names first +CLEAN_QT = $$replace(QT, -private$, _private) +CLEAN_QT_PRIVATE = $$replace(QT_PRIVATE, -private$, _private) + +qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE +all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends") + +import_plugins:qtConfig(static) { + manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy. + autoplugs = # Auto-added plugins. + # First round: explicitly specified modules. + plugin_deps = $$all_qt_module_deps + for(ever) { + # Automatically link the default plugins for the linked Qt modules. + for (qtmod, plugin_deps) { + for (ptype, QT.$${qtmod}.plugin_types) { + nptype = $$replace(ptype, [-/], _) + isEmpty(QTPLUGIN.$$nptype) { + for (plug, QT_PLUGINS) { + equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) { + for (dep, QT_PLUGIN.$${plug}.EXTENDS) { + !contains(all_qt_module_deps, $$dep) { + plug = + break() + } + } + autoplugs += $$plug + } + } + } else { + plug = $$eval(QTPLUGIN.$$nptype) + !equals(plug, -): \ + autoplugs += $$plug + } + } + } + QTPLUGIN = $$manualplugs $$autoplugs + QTPLUGIN = $$unique(QTPLUGIN) + + # Obtain the plugins' Qt dependencies ... + plugin_deps = + for (plug, QTPLUGIN): \ + plugin_deps += $$eval(QT_PLUGIN.$${plug}.DEPENDS) + plugin_deps = $$resolve_depends(plugin_deps, "QT.", ".depends" ".run_depends") + plugin_deps -= $$all_qt_module_deps + isEmpty(plugin_deps): \ + break() + # ... and start over if any new Qt modules appeared, + # as these may want to load plugins in turn. + all_qt_module_deps += $$plugin_deps + } + extraplugs = $$manualplugs + manualplugs -= $$autoplugs + extraplugs -= $$manualplugs + !isEmpty(extraplugs): \ + warning("Redundant entries in QTPLUGIN: $$extraplugs") + + !isEmpty(QTPLUGIN) { + IMPORT_FILE_CONT = \ + "// This file is autogenerated by qmake. It imports static plugin classes for" \ + "// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS. variables." \ + "$${LITERAL_HASH}include " + for (plug, QTPLUGIN) { + plug_class = $$eval(QT_PLUGIN.$${plug}.CLASS_NAME) + !isEmpty(plug_class): \ + IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$plug_class)" + else: \ + warning("Plugin class name could not be determined for plugin '$$plug'.") + } + IMPORT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_plugin_import.cpp + write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error() + GENERATED_SOURCES += $$IMPORT_CPP + QMAKE_DISTCLEAN += $$IMPORT_CPP + } +} + # target variable, flag source variable defineTest(qtProcessModuleFlags) { for(flag, $$2) { @@ -62,8 +146,6 @@ defineTest(qtProcessModuleFlags) { unset(using_privates) var_sfx = for(ever) { - # qmake variables cannot contain dashes, so normalize the names first - CLEAN_QT$$var_sfx = $$replace(QT$$var_sfx, -private$, _private) # Topological resolution of modules based on their QT..depends variable FULL_QT$$var_sfx = $$resolve_depends(CLEAN_QT$$var_sfx, "QT.") # Finally actually add the modules @@ -167,9 +249,6 @@ for(ever) { message("This is not a bug, but a result of using Qt internals. You have been warned!") } -qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE -all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends") - !no_qt_rpath:!static:qtConfig(rpath):!qtConfig(static):\ contains(all_qt_module_deps, core) { relative_qt_rpath:!isEmpty(QMAKE_REL_RPATH_BASE):contains(INSTALLS, target):\ @@ -243,66 +322,7 @@ contains(all_qt_module_deps, qml): \ QMAKE_DISTCLEAN += $$QML_IMPORT_CPP } } - -!import_qpa_plugin { - warning("CONFIG-=import_qpa_plugin is deprecated. Use QTPLUGIN.platforms=- instead.") - QTPLUGIN.platforms = - -} else: qpa_minimal_plugin { - warning("CONFIG+=qpa_minimal_plugin is deprecated. Use QTPLUGIN.platforms=qminimal instead.") - QTPLUGIN.platforms = qminimal -} - -import_plugins { - autoplugs = - for (qtmod, all_qt_module_deps) { - for (ptype, QT.$${qtmod}.plugin_types) { - nptype = $$replace(ptype, [-/], _) - isEmpty(QTPLUGIN.$$nptype) { - for (plug, QT_PLUGINS) { - equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) { - for (dep, QT_PLUGIN.$${plug}.EXTENDS) { - !contains(all_qt_module_deps, $$dep) { - plug = - break() - } - } - autoplugs += $$plug - } - } - } else { - plug = $$eval(QTPLUGIN.$$nptype) - !equals(plug, -): \ - autoplugs += $$plug - } - } - } - manualplugs = $$QTPLUGIN - manualplugs -= $$autoplugs - QTPLUGIN -= $$manualplugs - !isEmpty(QTPLUGIN): \ - warning("Redundant entries in QTPLUGIN: $$QTPLUGIN") - QTPLUGIN = $$manualplugs $$autoplugs -} - qtConfig(static) { - import_plugins:!isEmpty(QTPLUGIN) { - IMPORT_FILE_CONT = \ - "// This file is autogenerated by qmake. It imports static plugin classes for" \ - "// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS. variables." \ - "$${LITERAL_HASH}include " - for(IMPORT_PLUG, $$list($$unique(QTPLUGIN))) { - PLUG_CLASS = $$eval(QT_PLUGIN.$${IMPORT_PLUG}.CLASS_NAME) - !isEmpty(PLUG_CLASS): \ - IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$PLUG_CLASS)" - else: \ - warning("Plugin class name could not be determined for $$IMPORT_PLUG plugin.") - } - IMPORT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_plugin_import.cpp - write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error() - GENERATED_SOURCES += $$IMPORT_CPP - QMAKE_DISTCLEAN += $$IMPORT_CPP - } - for (QTPLUG, $$list($$lower($$unique(QTPLUGIN)))) { # Check if the plugin is known to Qt. We can use this to determine # the plugin path. Unknown plugins must rely on the default link path. diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf index 265b4ea8a2..80d9c87e05 100644 --- a/mkspecs/features/qt_plugin.prf +++ b/mkspecs/features/qt_plugin.prf @@ -44,9 +44,13 @@ CONFIG(static, static|shared)|prefix_build { MODULE_FWD_PRI = $$mod_work_pfx/qt_plugin_$${MODULE}.pri !build_pass { + qt_plugin_deps = $$QT $$QT_PRIVATE + qt_plugin_deps = s,-private$,_private,g + MODULE_PRI_CONT = \ "QT_PLUGIN.$${MODULE}.TYPE = $$PLUGIN_TYPE" \ "QT_PLUGIN.$${MODULE}.EXTENDS =$$join(PLUGIN_EXTENDS, " ", " ")" \ + "QT_PLUGIN.$${MODULE}.DEPENDS = $$qt_plugin_deps" \ "QT_PLUGIN.$${MODULE}.CLASS_NAME = $$PLUGIN_CLASS_NAME" \ "QT_PLUGINS += $$MODULE" write_file($$MODULE_PRI, MODULE_PRI_CONT)|error() From 342691b80294f8096dd383f9a0a7b4488f40728e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 5 Jan 2017 14:28:41 +0100 Subject: [PATCH 100/304] fix configure --opt=val syntax the second dash would end up in the option name, which made it obviously unrecognizable. but the second dash isn't optional in the first place (as evidenced one line up), so remove the question marks. Task-number: QTBUG-57908 Change-Id: I6622fef7d11d7b3c485f16698349d1912037a41e Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_configure.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 3adefb743e..a0948dad86 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -241,8 +241,8 @@ defineTest(qtConfParseCommandLine) { opt = $$replace(c, "^--?(disable|no)-(.*)", "\\2") val = no } else: contains(c, "^--([^=]+)=(.*)") { - opt = $$replace(c, "^--?([^=]+)=(.*)", "\\1") - val = $$replace(c, "^--?([^=]+)=(.*)", "\\2") + opt = $$replace(c, "^--([^=]+)=(.*)", "\\1") + val = $$replace(c, "^--([^=]+)=(.*)", "\\2") } else: contains(c, "^--(.*)") { opt = $$replace(c, "^--(.*)", "\\1") val = yes From e35c993020228fc2f173d116bc8ba34d419ae7c9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 10:00:18 +0100 Subject: [PATCH 101/304] QProgressBar: remove unneeded ctor-style no-op cast The expression '100' already has type int, so the cast is not necessary, and confusing. Remove it. Change-Id: Id63f56645b1b13532f73e481547c2a606dfc9c9a Reviewed-by: David Faure --- src/widgets/widgets/qprogressbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 2893849c42..be6091f499 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -481,7 +481,7 @@ QString QProgressBar::text() const // progress bar has one step and that we are on that step. Return // 100% here in order to avoid division by zero further down. if (totalSteps == 0) { - result.replace(QLatin1String("%p"), locale.toString(int(100))); + result.replace(QLatin1String("%p"), locale.toString(100)); return result; } From a3d0983f5909c37205cf0bdd4c4eba15d26d58c9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 08:10:53 +0100 Subject: [PATCH 102/304] QProgressBar: don't lose precision in text() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When qreal is float, it cannot represent all values an int can take, so we may lose precision in the expression qreal(d->value) - d->minimum as opposed to the exact result qint64(d->value) - d->minimum' For lack of trying, I do not know of a value where this would change the resulting 'progress' value, but better be safe than sorry, and use the 64-bit integer expression instead. Found while reviewing integer arithmetic in QProgressBar as part of the fix for QTBUG-57857. While touching the line, make the (intended) double → int truncation explicit, by using a static_cast. Change-Id: I03dbfce24c709310c3bbad9487a2bf0d1d78137a Reviewed-by: David Faure --- src/widgets/widgets/qprogressbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index be6091f499..64f19047b6 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -485,7 +485,7 @@ QString QProgressBar::text() const return result; } - int progress = (qreal(d->value) - d->minimum) * 100.0 / totalSteps; + const auto progress = static_cast((qint64(d->value) - d->minimum) * 100.0 / totalSteps); result.replace(QLatin1String("%p"), locale.toString(progress)); return result; } From 3f996edbb69a575267a4ff816f09510f14729149 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 09:12:10 +0100 Subject: [PATCH 103/304] QPixmapStyle: do not assume minimum == 0 when painting progress bars The arithmetic used to calculate the size of the progress bar fill in QPixmapStyle assumed minimum == 0, but that does not necessarily hold, since the minimum value is user-defined. So, fix the arithmetic to take the minimum into account, taking care, as done elsewhere, to avoid signed integer and qreal=float overflows, by using qint64 and double, respectively. [ChangeLog][QtWidgets][QPixmapStyle] Now handles progress bars with minimum != 0 correctly. Change-Id: I738ded56e8234716c36a5e9fde15bae691c43a35 Reviewed-by: David Faure --- src/widgets/styles/qpixmapstyle.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index e973a96a91..ce37065fb6 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -819,11 +819,14 @@ void QPixmapStyle::drawProgressBarFill(const QStyleOption *option, drawCachedPixmap(vertical ? PB_VComplete : PB_HComplete, option->rect, painter); } else { - if (pbar->progress == 0) + if (pbar->progress == pbar->minimum) return; - const int maximum = pbar->maximum; - const qreal ratio = qreal(vertical?option->rect.height():option->rect.width())/maximum; - const int progress = pbar->progress*ratio; + const auto totalSteps = qint64(pbar->maximum) - pbar->minimum; + const auto progressSteps = qint64(pbar->progress) - pbar->minimum; + const auto availablePixels = vertical ? option->rect.height() : option->rect.width(); + const auto pixelsPerStep = double(availablePixels) / totalSteps; + + const auto progress = static_cast(progressSteps * pixelsPerStep); // width in pixels QRect optRect = option->rect; if (vertical) { From 894cd9bcfc041ee3064b7f7b4215415fe99cd6b8 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Fri, 6 Jan 2017 23:56:22 +0100 Subject: [PATCH 104/304] Remove strange, incoherent sentences in QColor docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There were some strange sentences that did not add to the documentation of HSL vs. HSV. Task-number: QTBUG-52483 Change-Id: I5f2b8c3bd420fe9cabc74a94af4b78945723b6cf Reviewed-by: Tor Arne Vestbø Reviewed-by: Mitch Curtis --- src/gui/painting/qcolor.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 6a8091bf8b..9e1785c11d 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -545,12 +545,8 @@ static QStringList get_colornames() \section1 The HSL Color Model - HSL is similar to HSV. Instead of value parameter from HSV, - HSL has the lightness parameter. - The lightness parameter goes from black to color and from color to white. - If you go outside at the night its black or dark gray. At day its colorful but - if you look in a really strong light a things they are going to white and - wash out. + HSL is similar to HSV, however instead of the Value parameter, HSL + specifies a Lightness parameter. \section1 The CMYK Color Model From 555a0f3c511368eff51cd0f8e52f0abc7a0ff28c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 08:10:53 +0100 Subject: [PATCH 105/304] QFusionStyle: don't lose precision when drawing a progress bar When qreal is float, it cannot represent all values an int can take, so we may lose precision in the expression qreal(value) - minimum as opposed to the exact result qint64(value) - minimum' For lack of trying, I do not know of a value where this would change the resulting 'progressBarWidth' value, but better be safe than sorry, and use the 64-bit integer expression instead of floating-point. Found while reviewing integer arithmetic in QProgressBar as part of the fix for QTBUG-57857. Change-Id: I0240c143bb75af6986910489b34042ce9b3a8caa Reviewed-by: David Faure --- src/widgets/styles/qfusionstyle.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 74e4d53dca..c2b4ef382b 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1352,10 +1352,11 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } int maxWidth = rect.width(); - int minWidth = 0; - qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar - int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); - int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth); + const auto progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar + const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum); + const auto progressSteps = qint64(progress) - bar->minimum; + const auto progressBarWidth = progressSteps * maxWidth / totalSteps; + int width = indeterminate ? maxWidth : progressBarWidth; bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; if (inverted) @@ -1450,8 +1451,9 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio inverted = bar->invertedAppearance; if (vertical) rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() / - qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); + const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum); + const auto progressSteps = qint64(bar->progress) - bar->minimum; + const auto progressIndicatorPos = progressSteps * rect.width() / totalSteps; if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); if (vertical) From 1d1b60dee40de3b8d67be46399b58d4b1ecddab1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Jan 2017 08:10:53 +0100 Subject: [PATCH 106/304] QStylesheetStyle: don't lose precision when drawing a progress bar When qreal is float, it cannot represent all values an int can take, so we may lose precision in the expression qreal(a) / b as opposed to the double result double(a) / b For lack of trying, I do not know of a value where this would change the resulting 'fillWidth' value, but better be safe than sorry, and use double instead of qreal arithmetic. Also, when calculating fillRatio, we were converting values back and forth between qreal and double. Using double everywhere avoids that. Found while reviewing integer arithmetic in QProgressBar as part of the fix for QTBUG-57857. Change-Id: I054cb11d35e3ecf5bf79b5c8ee39029bd23bcf49 Reviewed-by: David Faure --- src/widgets/styles/qstylesheetstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index d63c96bf0e..68ee8c22d3 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3903,8 +3903,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (inverted) reverse = !reverse; const bool indeterminate = pb->minimum == pb->maximum; - qreal fillRatio = indeterminate ? 0.50 : qreal(progress - minimum)/(maximum - minimum); - int fillWidth = int(rect.width() * fillRatio); + const auto fillRatio = indeterminate ? 0.50 : double(progress - minimum) / (maximum - minimum); + const auto fillWidth = static_cast(rect.width() * fillRatio); int chunkWidth = fillWidth; if (subRule.hasContentsSize()) { QSize sz = subRule.size(); From 389165dd25a30a0ff9ea368555ecb84d40ceacfa Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 8 Jan 2017 10:32:52 +0100 Subject: [PATCH 107/304] Clarify StripTrailingSlash behavior StripTrailingSlash removes trailing slashes from the path, but not the entire URL. Task-number: QTBUG-47607 Change-Id: Id62b971e563e290b7ca000576bcc328616a3f1a2 Reviewed-by: David Faure --- src/corelib/io/qurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 066052ade9..38f2a708b5 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -240,7 +240,7 @@ Only valid if RemovePath is not set. \value PreferLocalFile If the URL is a local file according to isLocalFile() and contains no query or fragment, a local file path is returned. - \value StripTrailingSlash The trailing slash is removed if one is present. + \value StripTrailingSlash The trailing slash is removed from the path, if one is present. \value NormalizePathSegments Modifies the path to remove redundant directory separators, and to resolve "."s and ".."s (as far as possible). From 9e0837bd6ef7f9d5d4c219e2a17fdbde43243aaa Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 9 Jan 2017 15:28:04 +0100 Subject: [PATCH 108/304] Doc: removed reference to non-existing snippet Command \snippet (//! [3])' failed at end of file ../widgets/widgets/charactermap/mainwindow.cpp Change-Id: Ib095053bd4ff3901d7a9cd91aae3d83ec5f60807 Reviewed-by: Friedemann Kleint --- src/gui/doc/src/dnd.qdoc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/doc/src/dnd.qdoc b/src/gui/doc/src/dnd.qdoc index 03b3cbfa24..945c485705 100644 --- a/src/gui/doc/src/dnd.qdoc +++ b/src/gui/doc/src/dnd.qdoc @@ -343,9 +343,7 @@ Applications can also communicate with each other by putting data on the clipboard. To access this, you need to obtain a QClipboard object - from the QApplication object: - - \snippet ../widgets/widgets/charactermap/mainwindow.cpp 3 + from the QApplication object. The QMimeData class is used to represent data that is transferred to and from the clipboard. To put data on the clipboard, you can use the From 6650d65b0baac23ffc2db352437ba501b2b4511a Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 9 Jan 2017 15:45:38 +0100 Subject: [PATCH 109/304] Doc: corrected qdoc syntax parameter description qxcbwindowfunctions.qdoc: 109: warning - Unknown command '\role' [Maybe you meant '\row'?] Change-Id: I1f6f8e449921bd415432ebd06e6169b3d8757e22 Reviewed-by: Venugopal Shivashankar --- src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc index f0ef5ee2a7..fab473b91b 100644 --- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc +++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc @@ -106,7 +106,7 @@ \fn void QXcbWindowFunctions::setWmWindowRole(QWindow *window, const QByteArray &role) \since 5.6.2 - Sets the WM_WINDOW_ROLE property from \role on the corresponding + Sets the WM_WINDOW_ROLE property from \a role on the corresponding X11 window. This is a convenience function that can be used directly instead From 280f067fe0c5a11a38e60d42d6cc74152515793a Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 9 Jan 2017 16:27:44 +0100 Subject: [PATCH 110/304] Doc: corrected qdoc list syntax qundostack.cpp: Command '\li' outside of '\list' and '\table' Change-Id: Ic162e246c754e125f6ae82a2a66312e925b231c2 Reviewed-by: Martin Smith --- src/widgets/util/qundostack.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index 59d517e77b..033d4e9e05 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -654,10 +654,12 @@ void QUndoStack::setClean() This method resets the clean index to -1. This is typically called in the following cases, when a document has been: + \list \li created basing on some template and has not been saved, so no filename has been associated with the document yet. \li restored from a backup file. \li changed outside of the editor and the user did not reload it. + \endlist \sa isClean(), setClean(), cleanIndex() */ From e7b8df6349c059c7ae16ca954e62d503d36c70fb Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 9 Jan 2017 15:40:32 +0300 Subject: [PATCH 111/304] examples: Use lambdas instead of functor classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iee2cc22a9239ab5a351cb5ecb2c8ce10ed019b2c Reviewed-by: Friedemann Kleint Reviewed-by: Topi Reiniö --- .../widgets/mainwindows/mainwindow/mainwindow.cpp | 15 +-------------- examples/widgets/mainwindows/mdi/mainwindow.cpp | 14 +++----------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp index a21a64bdd4..10e3dd045a 100644 --- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp +++ b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp @@ -282,23 +282,10 @@ void MainWindow::loadLayout() } } -class DockWidgetAreaCornerFunctor { -public: - explicit DockWidgetAreaCornerFunctor(QMainWindow *mw, Qt::Corner c, Qt::DockWidgetArea a) - : m_mainWindow(mw), m_area(a), m_corner(c) {} - - void operator()() const { m_mainWindow->setCorner(m_corner, m_area); } - -private: - QMainWindow *m_mainWindow; - Qt::DockWidgetArea m_area; - Qt::Corner m_corner; -}; - static QAction *addCornerAction(const QString &text, QMainWindow *mw, QMenu *menu, QActionGroup *group, Qt::Corner c, Qt::DockWidgetArea a) { - QAction *result = menu->addAction(text, mw, DockWidgetAreaCornerFunctor(mw, c, a)); + QAction *result = menu->addAction(text, mw, [=]() { mw->setCorner(c, a); }); result->setCheckable(true); group->addAction(result); return result; diff --git a/examples/widgets/mainwindows/mdi/mainwindow.cpp b/examples/widgets/mainwindows/mdi/mainwindow.cpp index 76b1c308cb..188de1893e 100644 --- a/examples/widgets/mainwindows/mdi/mainwindow.cpp +++ b/examples/widgets/mainwindows/mdi/mainwindow.cpp @@ -264,16 +264,6 @@ void MainWindow::updateMenus() #endif } -class ActiveMdiSubWindowFunctor { -public: - explicit ActiveMdiSubWindowFunctor(QMdiArea *mdiArea, QMdiSubWindow *activeWindow) : m_mdiArea(mdiArea), m_activeWindow(activeWindow) {} - void operator()() const { m_mdiArea->setActiveSubWindow(m_activeWindow); } - -private: - QMdiArea *m_mdiArea; - QMdiSubWindow *m_activeWindow; -}; - void MainWindow::updateWindowMenu() { windowMenu->clear(); @@ -302,7 +292,9 @@ void MainWindow::updateWindowMenu() text = tr("%1 %2").arg(i + 1) .arg(child->userFriendlyCurrentFile()); } - QAction *action = windowMenu->addAction(text, mdiSubWindow, ActiveMdiSubWindowFunctor(mdiArea, mdiSubWindow)); + QAction *action = windowMenu->addAction(text, mdiSubWindow, [this, mdiSubWindow]() { + mdiArea->setActiveSubWindow(mdiSubWindow); + }); action->setCheckable(true); action ->setChecked(child == activeMdiChild()); } From b0a9b9ab87aedab65888f8d71f3a33da06ba9c7d Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Wed, 7 Dec 2016 11:10:51 -0500 Subject: [PATCH 112/304] Adjust QNX choices Don't use Dinkum choices when the C++ library is libC++ (QNX 7.0). Change-Id: I18c3f716ccfb0c02dbfdc01eac4b707d3ae9aab6 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 4142c17b42..77ce488ca0 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -999,7 +999,7 @@ // Older versions (QNX 650) do not support C++11 features // _HAS_* macros are set to 1 by toolchains that actually include // Dinkum C++11 libcpp. -# if !defined(__GLIBCXX__) +# if !defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION) # if !defined(_HAS_CPP0X) || !_HAS_CPP0X // Disable C++11 features that depend on library support # undef Q_COMPILER_INITIALIZER_LISTS From dfa08d65a55dbc54d2573fd179e1197f4fdd5a90 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 8 Jan 2017 10:22:55 +0100 Subject: [PATCH 113/304] Replace non-existent signals with the correct ones activated() is actually triggered(), highlighted() is actually hovered() Task-number: QTBUG-50315 Change-Id: Ieefdc8376102d80d0885a6c7ca47a9380945afef Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 36a8a96b79..2917083415 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1507,7 +1507,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) When inserting action items you usually specify a receiver and a slot. The receiver will be notifed whenever the item is \l{QAction::triggered()}{triggered()}. In addition, QMenu provides - two signals, activated() and highlighted(), which signal the + two signals, triggered() and hovered(), which signal the QAction that was triggered from the menu. You clear a menu with clear() and remove individual action items From 41d1785e130e5ab43b24635c890ee501971de18b Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 8 Jan 2017 12:37:03 +0100 Subject: [PATCH 114/304] Clarify that QString::toDouble does not have a fallback QString::toDouble always uses the 'C' locale. Task-number: QTBUG-44045 Change-Id: Ifb0c2f11c83c209907dd35bb39d1450022c8e85c Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index f499681ca9..20a984fafe 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1305,8 +1305,8 @@ float QLocale::toFloat(const QString &s, bool *ok) const If \a ok is not 0, reports failure by setting *ok to false and success by setting *ok to true. - Unlike QString::toDouble(), this function does not fall back to - the "C" locale if the string cannot be interpreted in this + Unlike QString::toDouble(), this function does not use + the 'C' locale if the string cannot be interpreted in this locale. \snippet code/src_corelib_tools_qlocale.cpp 3 From ecb025e346b662548a5dec51eda61f0c812a4f57 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 9 Jan 2017 20:11:25 +0100 Subject: [PATCH 115/304] reduce nesting in configure.bat for some inexplicable reason, configure.bat went into an endless loop on win 8.1+ while attempting to parse the command line; this is clearly a bug in cmd, so work around it. amends 7af6e9bb. Task-number: QTBUG-58019 Change-Id: I698a2a51891a4e7af75836c075888f70df865409 Reviewed-by: Jake Petroules --- configure.bat | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/configure.bat b/configure.bat index 47f1889277..7ce39e7ecf 100644 --- a/configure.bat +++ b/configure.bat @@ -89,13 +89,12 @@ goto doneargs :help type %QTSRC%\config_help.txt - if %TOPLEVEL% == true ( - for /d %%p in ("%TOPQTSRC%"\qt*) do ( - if not "%%p" == "%QTSRC%" ( - if exist "%%p\config_help.txt" ( - echo. - type "%%p\config_help.txt" - ) + if %TOPLEVEL% == false exit /b 1 + for /d %%p in ("%TOPQTSRC%"\qt*) do ( + if not "%%p" == "%QTSRC%" ( + if exist "%%p\config_help.txt" ( + echo. + type "%%p\config_help.txt" ) ) ) From 7f12f94e481d4908ee7b68e2cab8263b7476b054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Thu, 21 Jul 2016 11:26:21 +0200 Subject: [PATCH 116/304] Restore binary compatibility with pre-5.6 qt_handleMouseEvent An internal, private symbol was changed in beef975f92e42143c464d68afa6b8cd4f7ef7389. However, this symbol was being used by some inline functions in QtTest, and this therefore introduced a BIC. This change simple adds back a symbol with the original signature. I recall seeing this in my own work, and the KDE CI system hits this as well: libKF5KDELibs4Support.so.5.25.0: undefined reference to `qt_handleMouseEvent(QWindow*, QPointF const&, QPointF const&, QFlags, QFlags)' Task-number: QTBUG-52205 Change-Id: I4e85996850cc436b6a31addca3a8f9829c0c5edd Reviewed-by: Lars Knoll --- src/gui/kernel/qwindowsysteminterface.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 667304859e..8e86ce0b5c 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -924,6 +924,13 @@ Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QP QWindowSystemInterface::handleMouseEvent(w, timestamp, local * factor, global * factor, b, mods); } +// Wrapper for compatibility with Qt < 5.6 +// ### Qt6: Remove +Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) +{ + qt_handleMouseEvent(w, local, global, b, mods, QWindowSystemInterfacePrivate::eventTime.elapsed()); +} + Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { QWindowSystemInterface::handleKeyEvent(w, t, k, mods, text, autorep, count); From 2005b9fae12b19a4d087035789fa3bc9730d303a Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Mon, 2 Jan 2017 11:34:44 +0100 Subject: [PATCH 117/304] Remove unreachable code The unknown types are treated as strings by default. Coverity-Id: 59489 Change-Id: Ib0eaf5c27d3afaf694c8a2acca42bef6808c8a9f Reviewed-by: Timur Pocheptsov --- src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 0bea9ebfa1..7cfa554418 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -699,10 +699,8 @@ QVariant QMYSQLResult::data(int field) } if(ok) return v; - else - return QVariant(); + return QVariant(); } - return QVariant(val.toDouble()); case QVariant::Date: return qDateFromString(val); case QVariant::Time: @@ -719,12 +717,11 @@ QVariant QMYSQLResult::data(int field) } return QVariant(ba); } - default: case QVariant::String: + default: return QVariant(val); } - qWarning("QMYSQLResult::data: unknown data type"); - return QVariant(); + Q_UNREACHABLE(); } bool QMYSQLResult::isNull(int field) From 25b00c88b6fda2eecd9ff566ab44974136dabf51 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Jan 2017 10:56:34 +0100 Subject: [PATCH 118/304] cocoa: Account for getting a keyboard using input methods correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a keyboard is using an input method then the layout for it needs to be retrieved with TISCopyInputMethodKeyboardLayoutOverride(). For cases where it is not using an input method this will return null and in that case we can use the original approach as before. Task-number: QTBUG-53804 Task-number: QTBUG-57934 Change-Id: I6283785bf002602113e208bb38d5eb2a9a7ceb36 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoakeymapper.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm index e7952ae1f6..1ef7f11011 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm @@ -366,7 +366,9 @@ Qt::KeyboardModifiers QCocoaKeyMapper::queryKeyboardModifiers() bool QCocoaKeyMapper::updateKeyboard() { const UCKeyboardLayout *uchrData = 0; - QCFType source = TISCopyCurrentKeyboardInputSource(); + QCFType source = TISCopyInputMethodKeyboardLayoutOverride(); + if (!source) + source = TISCopyCurrentKeyboardInputSource(); if (keyboard_mode != NullMode && source == currentInputSource) { return false; } From 0dc85f78083f4e2777697d998a5bc3ffdf13a6a1 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 9 Jan 2017 11:20:20 +0100 Subject: [PATCH 119/304] Don't build SQL driver plugins if we are not building Qt SQL Change-Id: I60fb0d7c05652fbad9884b19e612cfef6156d9ae Reviewed-by: Oswald Buddenhagen --- src/plugins/plugins.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 941c25361f..620d9cb8c9 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,7 +1,7 @@ TEMPLATE = subdirs QT_FOR_CONFIG += network -SUBDIRS *= sqldrivers +qtHaveModule(sql): SUBDIRS += sqldrivers qtHaveModule(network):qtConfig(bearermanagement): SUBDIRS += bearer qtHaveModule(gui) { SUBDIRS *= platforms platforminputcontexts platformthemes From 0979c5304c32cdb868b22a021ce505d12d6b1967 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 9 Jan 2017 11:24:50 +0100 Subject: [PATCH 120/304] Drop unnecessary dependencies from some tests The future tests don't need QtConcurrent as QFuture and friends are in QtCore. The printdevice test doesn't use QtNetwork and the lancelot as well as the testlib tests don't use QtXml. Change-Id: I150ac99b36682aa23ad22ba943266eb0f0952838 Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/thread/qfuture/qfuture.pro | 2 +- .../corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro | 2 +- tests/auto/corelib/thread/qresultstore/qresultstore.pro | 2 +- tests/auto/other/lancelot/lancelot.pro | 2 +- tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro | 2 +- tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro | 2 +- tests/auto/testlib/selftests/test/test.pro | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/auto/corelib/thread/qfuture/qfuture.pro b/tests/auto/corelib/thread/qfuture/qfuture.pro index ed9e189668..b1667760d6 100644 --- a/tests/auto/corelib/thread/qfuture/qfuture.pro +++ b/tests/auto/corelib/thread/qfuture/qfuture.pro @@ -1,5 +1,5 @@ CONFIG += testcase TARGET = tst_qfuture -QT = core core-private testlib concurrent +QT = core core-private testlib SOURCES = tst_qfuture.cpp DEFINES += QT_STRICT_ITERATORS diff --git a/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro b/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro index 5eebd12deb..0d20117ed0 100644 --- a/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro +++ b/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qfuturesynchronizer -QT = core testlib concurrent +QT = core testlib SOURCES = tst_qfuturesynchronizer.cpp diff --git a/tests/auto/corelib/thread/qresultstore/qresultstore.pro b/tests/auto/corelib/thread/qresultstore/qresultstore.pro index 2f6c18f64c..bbebe0976b 100644 --- a/tests/auto/corelib/thread/qresultstore/qresultstore.pro +++ b/tests/auto/corelib/thread/qresultstore/qresultstore.pro @@ -1,5 +1,5 @@ CONFIG += testcase TARGET = tst_qresultstore -QT = core-private testlib concurrent +QT = core-private testlib SOURCES = tst_qresultstore.cpp DEFINES += QT_STRICT_ITERATORS diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro index e9c9af7143..b492611ca7 100644 --- a/tests/auto/other/lancelot/lancelot.pro +++ b/tests/auto/other/lancelot/lancelot.pro @@ -1,7 +1,7 @@ CONFIG += testcase CONFIG -= app_bundle TARGET = tst_lancelot -QT += xml testlib +QT += testlib SOURCES += tst_lancelot.cpp \ paintcommands.cpp diff --git a/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro b/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro index 56c1b60d94..a859f15fbb 100644 --- a/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro +++ b/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro @@ -2,6 +2,6 @@ CONFIG += testcase TARGET = tst_qprintdevice SOURCES += tst_qprintdevice.cpp -QT += printsupport-private network testlib +QT += printsupport-private testlib DEFINES += QT_USE_USING_NAMESPACE diff --git a/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro b/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro index f397f48bb8..36261780fd 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro +++ b/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro @@ -2,6 +2,6 @@ CONFIG += testcase TARGET = tst_qprinterinfo SOURCES += tst_qprinterinfo.cpp -QT += printsupport network testlib +QT += printsupport testlib DEFINES += QT_USE_USING_NAMESPACE diff --git a/tests/auto/testlib/selftests/test/test.pro b/tests/auto/testlib/selftests/test/test.pro index a2a1dd3f0b..a7487736b3 100644 --- a/tests/auto/testlib/selftests/test/test.pro +++ b/tests/auto/testlib/selftests/test/test.pro @@ -1,6 +1,6 @@ CONFIG += testcase SOURCES += ../tst_selftests.cpp -QT = core xml testlib-private +QT = core testlib-private TARGET = ../tst_selftests From eaa0063b707c214925c3a98ff7a5d1f890581c08 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 12:25:59 +0100 Subject: [PATCH 121/304] Fix compilation with QT_NO_SHAREDMEMORY If we use QLatin1String we should include qstring.h. Change-Id: Iebd761b98e515e9cd9cd34b96a0f8a602d00f086 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qsharedmemory_p.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index 51f729cf23..95fe0d1083 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -53,6 +53,8 @@ #include "qsharedmemory.h" +#include + #ifdef QT_NO_SHAREDMEMORY # ifndef QT_NO_SYSTEMSEMAPHORE namespace QSharedMemoryPrivate From cb1a4d8e06d34c9c55eb678715e2ac8596d8882b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 9 Jan 2017 11:19:38 +0100 Subject: [PATCH 122/304] Testlib: Exclude qtest_network.h when building without Qt Network Change-Id: If085684ed5252a01a682222510f6849be974feea Reviewed-by: Marc Mutz --- src/testlib/testlib.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 5b2205e875..e84651ccd5 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -111,4 +111,6 @@ mac { !qtHaveModule(widgets): HEADERSCLEAN_EXCLUDE += qtest_widgets.h +!qtHaveModule(network): HEADERSCLEAN_EXCLUDE += qtest_network.h + load(qt_module) From 858c1afb7af7d374520cbfb99aef8acadfaa9d88 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Tue, 10 Jan 2017 08:42:35 -0200 Subject: [PATCH 123/304] QNX: Fix comments on qcompilerdetection.h Change-Id: I75495b4ba3d8742419f824aa0e0b52694dbd42ed Reviewed-by: James McDonnell Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 77ce488ca0..c0f14e0f03 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -995,11 +995,20 @@ #ifdef __cplusplus # include # if defined(Q_OS_QNX) -// QNX: test if we are using libcpp (Dinkumware-based). -// Older versions (QNX 650) do not support C++11 features +// By default, QNX 7.0 uses libc++ (from LLVM) and +// QNX 6.X uses Dinkumware's libcpp. In all versions, +// it is also possible to use GNU libstdc++. + +// For Dinkumware, some features must be disabled +// (mostly because of library problems). +// Dinkumware is assumed when __GLIBCXX__ (GNU libstdc++) +// and _LIBCPP_VERSION (LLVM libc++) are both absent. +# if !defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION) + +// Older versions of libcpp (QNX 650) do not support C++11 features // _HAS_* macros are set to 1 by toolchains that actually include // Dinkum C++11 libcpp. -# if !defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION) + # if !defined(_HAS_CPP0X) || !_HAS_CPP0X // Disable C++11 features that depend on library support # undef Q_COMPILER_INITIALIZER_LISTS @@ -1016,7 +1025,7 @@ // Disable constexpr support on QNX even if the compiler supports it # undef Q_COMPILER_CONSTEXPR # endif // !_HAS_CONSTEXPR -# endif // !__GLIBCXX__ +# endif // !__GLIBCXX__ && !_LIBCPP_VERSION # endif // Q_OS_QNX # if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC) && defined(__GNUC_LIBSTD__) \ && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402) From ae42bf0f9b2b8c65ef509d5d0ecdd9a0535bb3d2 Mon Sep 17 00:00:00 2001 From: Jason Erb Date: Sun, 15 May 2016 12:16:50 -0400 Subject: [PATCH 124/304] Fixed Chinese language selection on iOS For language "Traditional Chinese" on iOS with region "US", the logic was formerly to attempt a match on country/language/script (fail), followed by country/language (which would result in script defaulting to "Simplified"). Now, the logic is to try language/script first if script is specified. Failing that, language/country will be attempted. Task-number: QTBUG-39639 Change-Id: I75a774b1e66686e95167ff221458a97a7ea2660d Reviewed-by: Konstantin Ritt Reviewed-by: Lars Knoll Reviewed-by: Jason Erb Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 83 ++++++++++++++----- .../corelib/tools/qlocale/tst_qlocale.cpp | 39 ++++++++- 2 files changed, 100 insertions(+), 22 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 20a984fafe..5b53b8b338 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -334,33 +334,17 @@ QByteArray QLocalePrivate::bcp47Name(char separator) const return localeId.withLikelySubtagsRemoved().name(separator); } -const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country) +static const QLocaleData *findLocaleDataById(const QLocaleId &localeId) { - QLocaleId localeId = QLocaleId::fromIds(language, script, country); - localeId = localeId.withLikelySubtagsAdded(); - - uint idx = locale_index[localeId.language_id]; + const uint idx = locale_index[localeId.language_id]; const QLocaleData *data = locale_data + idx; - if (idx == 0) // default language has no associated country + if (idx == 0) // default language has no associated script or country return data; Q_ASSERT(data->m_language_id == localeId.language_id); - if (localeId.script_id != QLocale::AnyScript && localeId.country_id != QLocale::AnyCountry) { - // both script and country are explicitly specified - do { - if (data->m_script_id == localeId.script_id && data->m_country_id == localeId.country_id) - return data; - ++data; - } while (data->m_language_id == localeId.language_id); - - // no match; try again with default script - localeId.script_id = QLocale::AnyScript; - data = locale_data + idx; - } - if (localeId.script_id == QLocale::AnyScript && localeId.country_id == QLocale::AnyCountry) return data; @@ -369,15 +353,72 @@ const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLoca if (data->m_country_id == localeId.country_id) return data; ++data; - } while (data->m_language_id == localeId.language_id); + } while (data->m_language_id && data->m_language_id == localeId.language_id); } else if (localeId.country_id == QLocale::AnyCountry) { do { if (data->m_script_id == localeId.script_id) return data; ++data; - } while (data->m_language_id == localeId.language_id); + } while (data->m_language_id && data->m_language_id == localeId.language_id); + } else { + do { + if (data->m_script_id == localeId.script_id && data->m_country_id == localeId.country_id) + return data; + ++data; + } while (data->m_language_id && data->m_language_id == localeId.language_id); } + return 0; +} + +const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country) +{ + QLocaleId localeId = QLocaleId::fromIds(language, script, country); + localeId = localeId.withLikelySubtagsAdded(); + + const uint idx = locale_index[localeId.language_id]; + + // Try a straight match + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + QList tried; + tried.push_back(localeId); + + // No match; try again with likely country + localeId = QLocaleId::fromIds(language, script, QLocale::AnyCountry); + localeId = localeId.withLikelySubtagsAdded(); + if (!tried.contains(localeId)) { + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + tried.push_back(localeId); + } + + // No match; try again with any country + localeId = QLocaleId::fromIds(language, script, QLocale::AnyCountry); + if (!tried.contains(localeId)) { + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + tried.push_back(localeId); + } + + // No match; try again with likely script + localeId = QLocaleId::fromIds(language, QLocale::AnyScript, country); + localeId = localeId.withLikelySubtagsAdded(); + if (!tried.contains(localeId)) { + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + tried.push_back(localeId); + } + + // No match; try again with any script + localeId = QLocaleId::fromIds(language, QLocale::AnyScript, country); + if (!tried.contains(localeId)) { + if (const QLocaleData *const data = findLocaleDataById(localeId)) + return data; + tried.push_back(localeId); + } + + // No match; return data at original index return locale_data + idx; } diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 8d9a789507..42bfb3603d 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -186,12 +186,50 @@ void tst_QLocale::ctor() QVERIFY(l.country() == default_country); } +#define TEST_CTOR(req_lang, req_script, req_country, exp_lang, exp_script, exp_country) \ + { \ + QLocale l(QLocale::req_lang, QLocale::req_script, QLocale::req_country); \ + QCOMPARE((int)l.language(), (int)exp_lang); \ + QCOMPARE((int)l.script(), (int)exp_script); \ + QCOMPARE((int)l.country(), (int)exp_country); \ + } + + // Exact matches + TEST_CTOR(Chinese, SimplifiedHanScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, TraditionalHanScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + TEST_CTOR(Chinese, TraditionalHanScript, HongKong, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::HongKong); + + // Best match for AnyCountry + TEST_CTOR(Chinese, SimplifiedHanScript, AnyCountry, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, TraditionalHanScript, AnyCountry, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + + // Best match for AnyScript (and change country to supported one, if necessary) + TEST_CTOR(Chinese, AnyScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, AnyScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + TEST_CTOR(Chinese, AnyScript, HongKong, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::HongKong); + TEST_CTOR(Chinese, AnyScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + + // Fully-specified not found; find best alternate country + TEST_CTOR(Chinese, SimplifiedHanScript, Taiwan, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, SimplifiedHanScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, TraditionalHanScript, China, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + TEST_CTOR(Chinese, TraditionalHanScript, UnitedStates, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + + // Fully-specified not found; find best alternate script + TEST_CTOR(Chinese, LatinScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + TEST_CTOR(Chinese, LatinScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan); + + // Fully-specified not found; find best alternate country and script + TEST_CTOR(Chinese, LatinScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China); + +#undef TEST_CTOR #define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \ { \ QLocale l(QLocale::req_lang, QLocale::req_country); \ QCOMPARE((int)l.language(), (int)exp_lang); \ QCOMPARE((int)l.country(), (int)exp_country); \ } + { QLocale l(QLocale::C, QLocale::AnyCountry); QCOMPARE(l.language(), QLocale::C); @@ -295,7 +333,6 @@ void tst_QLocale::ctor() TEST_CTOR(Uzbek, AnyCountry, QLocale::Uzbek, QLocale::Uzbekistan) #undef TEST_CTOR - #define TEST_CTOR(req_lc, exp_lang, exp_country) \ { \ QLocale l(req_lc); \ From f480196f1be061848275f259a2651973dc33b393 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 10 Jan 2017 09:36:50 +0100 Subject: [PATCH 125/304] tst_utf8: remove duplicate nonCharacters() data The population of data rows was factored into a separate file, qutf8data.cpp, in commit e20c4730. Merge commit 9bd03235 failed to track a conflicting change into the new file, and brought the code back into the tst_utf8.cpp, where it has been duplicating the utf8data data ever since. Change-Id: I4282685b882448f927289468bd7ab340a21ea0b3 Reviewed-by: David Faure Reviewed-by: Thiago Macieira --- tests/auto/corelib/codecs/utf8/tst_utf8.cpp | 33 --------------------- 1 file changed, 33 deletions(-) diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index 5666726a8c..8f78aa937c 100644 --- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp +++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp @@ -237,39 +237,6 @@ void tst_Utf8::nonCharacters_data() QTest::addColumn("utf8"); QTest::addColumn("utf16"); - // Unicode has a couple of "non-characters" that one can use internally - // These characters may be used for interchange; - // see: http://www.unicode.org/versions/corrigendum9.html - // - // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF, - // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and - // U+FDEF (inclusive) - - // U+FDD0 through U+FDEF - for (int i = 0; i < 32; ++i) { - char utf8[] = { char(0357), char(0267), char(0220 + i), 0 }; - QString utf16 = QChar(0xfdd0 + i); - QTest::newRow(qPrintable(QString::number(0xfdd0 + i, 16))) << QByteArray(utf8) << utf16; - } - - // the last two in Planes 1 through 16 - for (uint plane = 1; plane <= 16; ++plane) { - for (uint lower = 0xfffe; lower < 0x10000; ++lower) { - uint ucs4 = (plane << 16) | lower; - char utf8[] = { char(0xf0 | uchar(ucs4 >> 18)), - char(0x80 | (uchar(ucs4 >> 12) & 0x3f)), - char(0x80 | (uchar(ucs4 >> 6) & 0x3f)), - char(0x80 | (uchar(ucs4) & 0x3f)), - 0 }; - ushort utf16[] = { QChar::highSurrogate(ucs4), QChar::lowSurrogate(ucs4), 0 }; - - QTest::newRow(qPrintable(QString::number(ucs4, 16))) << QByteArray(utf8) << QString::fromUtf16(utf16); - } - } - - QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE") << QString(QChar(0xfffe)); - QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF") << QString(QChar(0xffff)); - extern void loadNonCharactersRows(); loadNonCharactersRows(); } From 22138f59075ccc5dce8ee0c96ffbb7b5454bb561 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 4 Jan 2017 10:03:20 +0100 Subject: [PATCH 126/304] Correct initial window size with highDPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the scaling factor when calculating the initial size of the platform window. Change-Id: Ie21f0da14e32ac437efbc304a3fd9722a7f8615e Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index bcd3e830dd..11432a4272 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -60,7 +60,7 @@ QPlatformWindow::QPlatformWindow(QWindow *window) , d_ptr(new QPlatformWindowPrivate) { Q_D(QPlatformWindow); - d->rect = window->geometry(); + d->rect = QHighDpi::toNativePixels(window->geometry(), window); } /*! From 64666b9ee0a0dc0a356e825a519fde566bddd2c9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Jan 2017 08:50:57 +0100 Subject: [PATCH 127/304] Windows: Check if the fallback key matches the shift modifier case too There are some keyboard layouts where pressing shift will give something different to what the expected key would be. For example, on a French keyboard layout, pressing SHIFT+! gives 1 as opposed to SHIFT+1 giving ! on a US keyboard layout. Therefore it should check against both cases to ensure it does not end up adding a new entry. Task-number: QTBUG-57938 Change-Id: I11c52619c048b98500f2d79876bb912720af6e65 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 00c4a6191e..b84b586f7c 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -703,7 +703,8 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 quint32 fallbackKey = winceKeyBend(vk_key); if (!fallbackKey || fallbackKey == Qt::Key_unknown) { fallbackKey = 0; - if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key < 0x5B && vk_key > 0x2F) + if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key != keyLayout[vk_key].qtKey[1] + && vk_key < 0x5B && vk_key > 0x2F) fallbackKey = vk_key; } keyLayout[vk_key].qtKey[8] = fallbackKey; From 461549c35ade73b3c048e2c5ecfbd412c438c026 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Wed, 7 Dec 2016 12:28:05 +0000 Subject: [PATCH 128/304] Don't show bogus empty window when calling QMainWindow::restoreState() Qt doesn't create the actual QDockWidgets when restoring, the user must ensure they are created before restoring state. So lets not create an empty QDockWidgetGroupWindow which you can't close and with no tabs. Change-Id: If0a6aa7cf6f3932ff4274e03f787e27aef8fa53d Task-Id: QTBUG-57492 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qdockarealayout.cpp | 10 ++++++++++ src/widgets/widgets/qdockarealayout_p.h | 1 + src/widgets/widgets/qmainwindowlayout.cpp | 11 +++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 63f8172bf6..ad19e5d5f9 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -266,6 +266,16 @@ bool QDockAreaLayoutInfo::isEmpty() const return next(-1) == -1; } +bool QDockAreaLayoutInfo::onlyHasPlaceholders() const +{ + for (const QDockAreaLayoutItem &item : item_list) { + if (!item.placeHolderItem) + return false; + } + + return true; +} + QSize QDockAreaLayoutInfo::minimumSize() const { if (isEmpty()) diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index f22a3d2de2..21787283f4 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -167,6 +167,7 @@ public: void clear(); bool isEmpty() const; + bool onlyHasPlaceholders() const; bool hasFixedSize() const; QList findSeparator(const QPoint &pos) const; int next(int idx) const; diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index aef8b9cbd5..14d7f3d835 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1030,12 +1030,19 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, Qt::Horizontal, QTabBar::RoundedSouth, mainWindow); QRect geometry; stream >> geometry; - if (!floatingTab->layoutInfo()->restoreState(stream, dockWidgets, false)) + QDockAreaLayoutInfo *info = floatingTab->layoutInfo(); + if (!info->restoreState(stream, dockWidgets, false)) return false; geometry = QDockAreaLayout::constrainedRect(geometry, floatingTab); floatingTab->move(geometry.topLeft()); floatingTab->resize(geometry.size()); - floatingTab->show(); + + // Don't show an empty QDockWidgetGroupWindow if no dock widget is available yet. + // reparentWidgets() would be triggered by show(), so do it explicitly here. + if (info->onlyHasPlaceholders()) + info->reparentWidgets(floatingTab); + else + floatingTab->show(); } break; #endif // QT_NO_TABBAR From c5332859c801c44f11269d7a4e65cdd43031784a Mon Sep 17 00:00:00 2001 From: Dmitry Chmerev Date: Tue, 10 Jan 2017 20:11:04 +0300 Subject: [PATCH 129/304] Fix QRect calculation in inputItemRectangle Because of QRect's width and height are caluculated values, they got spoiled after x and y values setting. This bug affects, in particular, Android software keyboard appearance: it could overlap focused input field. Change-Id: I27ccca27111219818722951fe6f463388d76c702 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidinputcontext.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 12e85046f8..4ab8a9d060 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -354,10 +354,10 @@ static QRect inputItemRectangle() ? QHighDpiScaling::factor(window) : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); if (pixelDensity != 1.0) { - rect.setX(rect.x() * pixelDensity); - rect.setY(rect.y() * pixelDensity); - rect.setWidth(rect.width() * pixelDensity); - rect.setHeight(rect.height() * pixelDensity); + rect.setRect(rect.x() * pixelDensity, + rect.y() * pixelDensity, + rect.width() * pixelDensity, + rect.height() * pixelDensity); } return rect; } From 8b64f9336255fa17f1b8e5f337d0e79765512150 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Wed, 4 Jan 2017 15:29:16 -0500 Subject: [PATCH 130/304] Ensure that RC_FILE is correctly handled in a single configuration When generating the Visual Studio project XML, the filter "Root Files" was not being output. Specifically, this means that even if RC_FILE was specified, it would not be included properly as a resource compilation target in the resultant Visual Studio project file. This is essentially a rather belated cherry-pick of qt/d6de960b7f. Task-number: QTBUG-57914 Change-Id: I7d03dc818df0cf36608012f1a71a3a476d8a9ff7 Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msbuild_objectmodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index e42b823598..9cc125d396 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -587,6 +587,8 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) outputFilter(tempProj, xml, xmlFilter, tempProj.ExtraCompilers.at(x)); } + outputFilter(tempProj, xml, xmlFilter, "Root Files"); + xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); xml << tag("ImportGroup") From 62882ad2fe3d9f70c876d7a51a5aab4118ce1ba3 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 10 Jan 2017 12:04:07 +0100 Subject: [PATCH 131/304] tst_qfont: clear style name in test font The test failed if qApp->font() had a styleName() set, when testing old serialization formats which didn't serialize it. Change-Id: If0236d354be144b3a990e074a22f796fffb1ed18 Reviewed-by: Simon Hausmann Reviewed-by: Konstantin Shegunov --- tests/auto/gui/text/qfont/tst_qfont.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index a6d8944656..06c0ba0819 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -358,6 +358,8 @@ void tst_QFont::serialize_data() // Versions <= Qt 2.1 had broken point size serialization, // so we set an integer point size. basicFont.setPointSize(9); + // Versions <= Qt 5.4 didn't serialize styleName, so clear it + basicFont.setStyleName(QString()); QFont font = basicFont; QTest::newRow("defaultConstructed") << font << QDataStream::Qt_1_0; From 2bb01172a76f14b1f57010b79207f6b9a9bf3f53 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 9 Jan 2017 00:10:42 +0100 Subject: [PATCH 132/304] QFont: fix fromString(toString()) when application font has styleName The style name needs to be cleared if not present in the string, otherwise the style name from qApp->font() (which propagates to any default-constructed QFont) remains. Change-Id: I9b6522a39a38526cced8a11ed02ae32582026480 Reviewed-by: Simon Hausmann Reviewed-by: Konstantin Shegunov --- src/gui/text/qfont.cpp | 2 ++ tests/auto/gui/text/qfont/tst_qfont.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 3b24039ea6..7f3ed3adaa 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2077,6 +2077,8 @@ bool QFont::fromString(const QString &descrip) setFixedPitch(l[8].toInt()); if (count == 11) d->request.styleName = l[10].toString(); + else + d->request.styleName.clear(); } if (count >= 9 && !d->request.fixedPitch) // assume 'false' fixedPitch equals default diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 06c0ba0819..2603206ab0 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -63,6 +63,7 @@ private slots: void defaultFamily_data(); void defaultFamily(); void toAndFromString(); + void fromStringWithoutStyleName(); void sharing(); }; @@ -561,6 +562,19 @@ void tst_QFont::toAndFromString() } } +void tst_QFont::fromStringWithoutStyleName() +{ + QFont font1; + font1.fromString("Noto Sans,12,-1,5,50,0,0,0,0,0,Regular"); + + QFont font2 = font1; + const QString str = "Times,16,-1,5,50,0,0,0,0,0"; + font2.fromString(str); + + QCOMPARE(font2.toString(), str); +} + + void tst_QFont::sharing() { // QFontCache references the engineData From 5fbee2c22381690282a8c9249d21e76edc4eeb05 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Jan 2017 15:51:46 +0100 Subject: [PATCH 133/304] Remove superfluous assignment Change-Id: Ic37b5db8b031a3b10f8f98645a97265ca03a75e4 Reviewed-by: Oswald Buddenhagen --- src/angle/src/compiler/translator.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/angle/src/compiler/translator.pro b/src/angle/src/compiler/translator.pro index 2e5adaee96..663a8892a7 100644 --- a/src/angle/src/compiler/translator.pro +++ b/src/angle/src/compiler/translator.pro @@ -204,6 +204,5 @@ bison_impl.output = $${BUILDSUBDIR}${QMAKE_FILE_BASE}_tab.cpp bison_impl.input = BISON_SOURCES bison_impl.commands = $$MAKEFILE_NOOP_COMMAND bison_impl.depends = $${BUILDSUBDIR}${QMAKE_FILE_BASE}_tab.h -bison_impl.output = $${BUILDSUBDIR}${QMAKE_FILE_BASE}_tab.cpp bison_impl.variable_out = GENERATED_SOURCES QMAKE_EXTRA_COMPILERS += bison_impl From 63baad4a3d39feb53dc52a9ff2270f6d06bf34fa Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 10 Jan 2017 13:03:42 -0800 Subject: [PATCH 134/304] macOS: convey correct mouse coordinates on drag release Task-number: QTBUG-57129 Change-Id: I6eb60c35bfaf63199d0f637bf2d579fadab0a644 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a63bc4d570..ba91d3e40e 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -2193,7 +2193,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin } NSPoint windowPoint = [self.window convertRectFromScreen:NSMakeRect(screenPoint.x, screenPoint.y, 1, 1)].origin; - QPoint qtWindowPoint(windowPoint.x, windowPoint.y); + NSPoint nsViewPoint = [self convertPoint: windowPoint fromView: nil]; // NSView/QWindow coordinates + QPoint qtWindowPoint(nsViewPoint.x, nsViewPoint.y); QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); From 483ee17419a4f4bbdfa4369e703ef3a75b81531b Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Fri, 2 Dec 2016 14:43:57 +0200 Subject: [PATCH 135/304] xcb: Fix colormap memory leak Change-Id: I54880c10dc089c2cd17184dcbab17fde3af6452c Reviewed-by: Louai Al-Khanji Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 11 +++++++---- src/plugins/platforms/xcb/qxcbwindow.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 3204fab197..ffbe9a2325 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -315,6 +315,7 @@ static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; QXcbWindow::QXcbWindow(QWindow *window) : QPlatformWindow(window) , m_window(0) + , m_cmap(0) , m_syncCounter(0) , m_gravity(XCB_GRAVITY_STATIC) , m_mapped(false) @@ -443,7 +444,6 @@ void QXcbWindow::create() m_visualId = visual->visual_id; m_depth = platformScreen->depthOfVisual(m_visualId); m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask, &m_imageRgbSwap); - xcb_colormap_t colormap = 0; quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL @@ -455,10 +455,10 @@ void QXcbWindow::create() static const bool haveOpenGL = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL); if ((window()->supportsOpenGL() && haveOpenGL) || m_format.hasAlpha()) { - colormap = xcb_generate_id(xcb_connection()); + m_cmap = xcb_generate_id(xcb_connection()); Q_XCB_CALL(xcb_create_colormap(xcb_connection(), XCB_COLORMAP_ALLOC_NONE, - colormap, + m_cmap, xcb_parent_id, m_visualId)); @@ -472,7 +472,7 @@ void QXcbWindow::create() type == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint), type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, defaultEventMask, - colormap + m_cmap }; m_window = xcb_generate_id(xcb_connection()); @@ -638,6 +638,9 @@ void QXcbWindow::destroy() Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); m_window = 0; } + if (m_cmap) { + xcb_free_colormap(xcb_connection(), m_cmap); + } m_mapped = false; if (m_pendingSyncRequest) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index cfa4964151..d100120d46 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -234,6 +234,7 @@ protected: quint8 mode, quint8 detail, xcb_timestamp_t timestamp); xcb_window_t m_window; + xcb_colormap_t m_cmap; uint m_depth; QImage::Format m_imageFormat; From 3ffc471385dfe6d489be10caa45c721633639060 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 4 Jan 2017 23:28:28 +0100 Subject: [PATCH 136/304] Accessibility: make sure childAt calls isValid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generally isValid should be called by the bridge, but in this case, we must verify the validity internally since we derefernce the interface internally. Task-number: QTBUG-52536 Change-Id: I14950118e58d65135bc38d77c23b8a7fed8bf39a Reviewed-by: Jan Arve Sæther --- src/gui/accessible/qaccessibleobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index b67b8062ba..2ef8502ad5 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -125,7 +125,7 @@ QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const for (int i = 0; i < childCount(); ++i) { QAccessibleInterface *childIface = child(i); Q_ASSERT(childIface); - if (childIface->rect().contains(x,y)) + if (childIface->isValid() && childIface->rect().contains(x,y)) return childIface; } return 0; From d9cb0644258a2feb8b945ca73fded0a063cf7181 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 11 Jan 2017 13:19:14 +0000 Subject: [PATCH 137/304] Doc: fix the datatype returned by Qt::TextAlignmentRole It's supposed to be a full alignment (like Top | Right), not just one flag. Change-Id: I656adda83742d7e4f31955322e937e979b32747c Reviewed-by: David Faure --- src/corelib/global/qnamespace.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 250195a512..11044cef88 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2651,7 +2651,7 @@ \value FontRole The font used for items rendered with the default delegate. (QFont) \value TextAlignmentRole The alignment of the text for items rendered with the - default delegate. (Qt::AlignmentFlag) + default delegate. (Qt::Alignment) \value BackgroundRole The background brush used for items rendered with the default delegate. (QBrush) \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead. From db226cbadc93b83d59e76515ec9cdbb6a53d2b04 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 11 Jan 2017 16:38:04 +0100 Subject: [PATCH 138/304] Put the features for platform plugins into their own section Change-Id: Icde1555e6093c9d8dd38e0abee40004db85189de Reviewed-by: Oswald Buddenhagen --- src/gui/configure.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/configure.json b/src/gui/configure.json index 2fce7eebb8..01566ad35b 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -423,6 +423,7 @@ }, "directfb": { "label": "DirectFB", + "section": "Platform plugins", "autoDetect": false, "condition": "libs.directfb", "output": [ "privateFeature" ] @@ -441,6 +442,7 @@ }, "direct2d": { "label": "Direct 2D", + "section": "Platform plugins", "condition": "config.win32 && !config.winrt && libs.direct2d", "output": [ "privateFeature" ] }, @@ -493,6 +495,7 @@ }, "integrityfb": { "label": "INTEGRITY framebuffer", + "section": "Platform plugins", "condition": "config.integrity", "output": [ "privateFeature" ] }, @@ -519,11 +522,13 @@ }, "linuxfb": { "label": "LinuxFB", + "section": "Platform plugins", "condition": "tests.linuxfb", "output": [ "privateFeature" ] }, "mirclient": { "label": "Mir client", + "section": "Platform plugins", "condition": "libs.mirclient", "output": [ "privateFeature" ] }, @@ -594,6 +599,7 @@ }, "eglfs": { "label": "EGLFS", + "section": "Platform plugins", "autoDetect": "!config.android && !config.win32", "condition": "features.egl", "output": [ "privateFeature" ] @@ -691,6 +697,7 @@ }, "xcb": { "label": "XCB", + "section": "Platform plugins", "autoDetect": "!config.darwin", "condition": "libs.xcb", "output": [ "privateFeature" ] From f3992dac6aa8c925b27fc0da19f8547341f534ba Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 3 Jan 2017 12:11:02 +0100 Subject: [PATCH 139/304] Make QSimpleDrag work with highDPI scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-57863 Change-Id: I940179a694ce992245dabb77ef6e92e027427524 Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/kernel/qsimpledrag.cpp | 37 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index a6ce04dc34..fc62273325 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -53,6 +53,8 @@ #include "qdir.h" #include "qimagereader.h" #include "qimagewriter.h" +#include "qplatformscreen.h" +#include "qplatformwindow.h" #include #include @@ -316,6 +318,25 @@ void QBasicDrag::updateCursor(Qt::DropAction action) updateAction(action); } + +static inline QPoint fromNativeGlobalPixels(const QPoint &point) +{ +#ifndef QT_NO_HIGHDPISCALING + QPoint res = point; + if (QHighDpiScaling::isActive()) { + for (const QScreen *s : qAsConst(QGuiApplicationPrivate::screen_list)) { + if (s->handle()->geometry().contains(point)) { + res = QHighDpi::fromNativePixels(point, s); + break; + } + } + } + return res; +#else + return point; +#endif +} + /*! \class QSimpleDrag \brief QSimpleDrag implements QBasicDrag for Drag and Drop operations within the Qt Application itself. @@ -344,7 +365,7 @@ void QSimpleDrag::startDrag() QBasicDrag::startDrag(); m_current_window = topLevelAt(QCursor::pos()); if (m_current_window) { - QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QCursor::pos(), drag()->supportedActions()); + QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QHighDpi::toNativePixels(QCursor::pos(), m_current_window), drag()->supportedActions()); setCanDrop(response.isAccepted()); updateCursor(response.acceptedAction()); } else { @@ -363,15 +384,15 @@ void QSimpleDrag::cancel() } } -void QSimpleDrag::move(const QPoint &globalPos) +void QSimpleDrag::move(const QPoint &nativeGlobalPos) { - //### not high-DPI aware + QPoint globalPos = fromNativeGlobalPixels(nativeGlobalPos); moveShapedPixmapWindow(globalPos); QWindow *window = topLevelAt(globalPos); if (!window) return; - const QPoint pos = globalPos - window->geometry().topLeft(); + const QPoint pos = nativeGlobalPos - window->handle()->geometry().topLeft(); const QPlatformDragQtResponse qt_response = QWindowSystemInterface::handleDrag(window, drag()->mimeData(), pos, drag()->supportedActions()); @@ -379,16 +400,16 @@ void QSimpleDrag::move(const QPoint &globalPos) setCanDrop(qt_response.isAccepted()); } -void QSimpleDrag::drop(const QPoint &globalPos) +void QSimpleDrag::drop(const QPoint &nativeGlobalPos) { - //### not high-DPI aware + QPoint globalPos = fromNativeGlobalPixels(nativeGlobalPos); - QBasicDrag::drop(globalPos); + QBasicDrag::drop(nativeGlobalPos); QWindow *window = topLevelAt(globalPos); if (!window) return; - const QPoint pos = globalPos - window->geometry().topLeft(); + const QPoint pos = nativeGlobalPos - window->handle()->geometry().topLeft(); const QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(window, drag()->mimeData(),pos, drag()->supportedActions()); if (response.isAccepted()) { From 635d0ae00717b9ba53a8e007e50fac0d2721ca35 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 12 Jan 2017 12:12:42 +0100 Subject: [PATCH 140/304] Fix typo in QT_REQUIRE_CONFIG error message Change-Id: Iecfd398935f9c10aa456bd3452d34b31bc7eb4c9 Reviewed-by: Lars Knoll Reviewed-by: Edward Welbourne --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 32176913ea..b4245ac8f6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -81,7 +81,7 @@ 1: The feature is available */ #define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1) -#define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not vailable.") +#define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not available.") #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) # define QT_NO_UNSHARABLE_CONTAINERS From be00e37bb35eadcb990b1b9a71b668c83cb89eaf Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 19 Dec 2016 18:56:43 +0100 Subject: [PATCH 141/304] Fix unnecessary regeneration of mocables in VS projects Change dcd2f829 introduced fake files with the extension .cbt for custom build tools that generate code from C++ source inputs. The moc_predefs.h header file falls into this category, because it is generated from dummy.cpp. It turns out that these fake files have to exist. Otherwise the custom build step is executed on every build. That means re-moccing all mocables on every build. Fix this by actually creating the fake .cbt files with some explanatory comment in them. Task-number: QTBUG-57695 Change-Id: I251294334425d9914677787d8ba6da1169b4cca5 Reviewed-by: Oswald Buddenhagen Reviewed-by: Oliver Wolff (cherry picked from commit 5fc2337d740963d019a1e31960a4d12dfec36ea9) Reviewed-by: Maurice Kalinowski --- qmake/generators/win32/msvc_vcproj.cpp | 25 +++++++++++++++++++++---- qmake/generators/win32/msvc_vcproj.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 21bdad1bbf..9d04a66ff4 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -760,6 +760,21 @@ bool VcprojGenerator::hasBuiltinCompiler(const QString &file) return false; } +void VcprojGenerator::createCustomBuildToolFakeFile(const QString &cbtFilePath, + const QString &realOutFilePath) +{ + QFile file(fileFixify(cbtFilePath, FileFixifyFromOutdir | FileFixifyAbsolute)); + if (file.exists()) + return; + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + warn_msg(WarnLogic, "Cannot create '%s'.", qPrintable(file.fileName())); + return; + } + file.write("This is a dummy file needed to create "); + file.write(qPrintable(realOutFilePath)); + file.write("\n"); +} + void VcprojGenerator::init() { is64Bit = (project->first("QMAKE_TARGET.arch") == "x86_64"); @@ -887,12 +902,14 @@ void VcprojGenerator::init() if (!hasBuiltinCompiler(file)) { extraCompilerSources[file] += quc.toQString(); } else { - // Use a fake file name foo.moc.cbt for the project view. + // Create a fake file foo.moc.cbt for the project view. // This prevents VS from complaining about a circular // dependency from foo.moc -> foo.moc. - QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables( - compiler_out, file, QString(), NoShell), false); - out += customBuildToolFilterFileSuffix; + QString realOut = replaceExtraCompilerVariables( + compiler_out, file, QString(), NoShell); + QString out = realOut + customBuildToolFilterFileSuffix; + createCustomBuildToolFakeFile(out, realOut); + out = Option::fixPathToTargetOS(out, false); extraCompilerSources[out] += quc.toQString(); extraCompilerOutputs[out] = file; } diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index e3e67d64b9..4882296b46 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -130,6 +130,7 @@ private: bool isStandardSuffix(const QString &suffix) const; ProString firstInputFileName(const ProString &extraCompilerName) const; QString firstExpandedOutputFileName(const ProString &extraCompilerName); + void createCustomBuildToolFakeFile(const QString &cbtFilePath, const QString &realOutFilePath); friend class VCFilter; }; From cfd069181c01bbade16c173a96100819aa719613 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 12 Jan 2017 11:31:17 +0100 Subject: [PATCH 142/304] winrt: Fix Qt5PrintSupport(d).lib generation With QT_NO_PRINTER set via the feature system there is no symbol exported at all in a packaging build. This implies that no .lib is generated. When an application has QT+=printsupport the build will fail due to a missing file. For android and ios it only worked as there is no separation and linker works against the .so file Task-number: QTBUG-56321 Change-Id: I389adaca61669b302b6c431effed2ef6d1c499a3 Reviewed-by: Simon Hausmann Reviewed-by: Friedemann Kleint --- src/printsupport/kernel/qprinter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 6d6d61b343..7824d28ac5 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -2326,4 +2326,8 @@ QPrinter::PrintRange QPrinter::printRange() const QT_END_NAMESPACE +#elif defined(Q_OS_WINRT) +QT_BEGIN_NAMESPACE +bool Q_PRINTSUPPORT_EXPORT qt_winrt_export_lib_creation_variable; +QT_END_NAMESPACE #endif // QT_NO_PRINTER From 5a1b4832a2704e7fb386d6b4c73dab85facdc40b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 10 Jan 2017 15:30:42 -0800 Subject: [PATCH 143/304] Adapt to the C++ SIC introduced by P0021: noexcept overloading C++17 adopts P0021R1[1], which makes noexcept be part of the function pointer's type and thus be overloadable. It contains some provisions for allowing a noexcept function pointer to cast implicitly to a non- noexcept function pointer, but that fails in the presence of templates and additional overloads that could match the type in question. Fortunately, the paper proposed a test macro, so we can change our sources now and be compatible with both C++14 and C++17 rules. This first failed with Clang 4.0 trunk. This source incompatibility is not our fault, it's the language's doing. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html Task-number: QTBUG-58054 Change-Id: I2bc52f3c7a574209b213fffd14988cf0b875be63 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobjectdefs_impl.h | 55 +++++++++++++++++++ .../auto/corelib/kernel/qobject/test/test.pro | 3 + .../corelib/kernel/qobject/tst_qobject.cpp | 35 ++++++++++++ tests/auto/corelib/kernel/qtimer/qtimer.pro | 3 + .../auto/corelib/kernel/qtimer/tst_qtimer.cpp | 8 +++ 5 files changed, 104 insertions(+) diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 79c9c8303e..1768e8ccc6 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -149,6 +149,20 @@ namespace QtPrivate { (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...), ApplyReturnValue(arg[0]); } }; +#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 + template + struct FunctorCall, List, R, SlotRet (Obj::*)(SlotArgs...) noexcept> { + static void call(SlotRet (Obj::*f)(SlotArgs...) noexcept, Obj *o, void **arg) { + (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...), ApplyReturnValue(arg[0]); + } + }; + template + struct FunctorCall, List, R, SlotRet (Obj::*)(SlotArgs...) const noexcept> { + static void call(SlotRet (Obj::*f)(SlotArgs...) const noexcept, Obj *o, void **arg) { + (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...), ApplyReturnValue(arg[0]); + } + }; +#endif template struct FunctionPointer { @@ -187,6 +201,47 @@ namespace QtPrivate { } }; +#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 + template struct FunctionPointer + { + typedef Obj Object; + typedef List Arguments; + typedef Ret ReturnType; + typedef Ret (Obj::*Function) (Args...) noexcept; + template struct ChangeClass { typedef Ret (Base:: *Type)(Args...) noexcept; }; + enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = true}; + template + static void call(Function f, Obj *o, void **arg) { + FunctorCall::Value, SignalArgs, R, Function>::call(f, o, arg); + } + }; + template struct FunctionPointer + { + typedef Obj Object; + typedef List Arguments; + typedef Ret ReturnType; + typedef Ret (Obj::*Function) (Args...) const noexcept; + template struct ChangeClass { typedef Ret (Base:: *Type)(Args...) const noexcept; }; + enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = true}; + template + static void call(Function f, Obj *o, void **arg) { + FunctorCall::Value, SignalArgs, R, Function>::call(f, o, arg); + } + }; + + template struct FunctionPointer + { + typedef List Arguments; + typedef Ret ReturnType; + typedef Ret (*Function) (Args...) noexcept; + enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = false}; + template + static void call(Function f, void *, void **arg) { + FunctorCall::Value, SignalArgs, R, Function>::call(f, arg); + } + }; +#endif + template struct Functor { template diff --git a/tests/auto/corelib/kernel/qobject/test/test.pro b/tests/auto/corelib/kernel/qobject/test/test.pro index f3bc045455..4e77cb48c5 100644 --- a/tests/auto/corelib/kernel/qobject/test/test.pro +++ b/tests/auto/corelib/kernel/qobject/test/test.pro @@ -3,5 +3,8 @@ TARGET = ../tst_qobject QT = core-private network testlib SOURCES = ../tst_qobject.cpp +# Force C++17 if available (needed due to P0012R1) +contains(QT_CONFIG, c++1z): CONFIG += c++1z + !winrt: TEST_HELPER_INSTALLS = ../signalbug/signalbug DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 91810cdcd8..7b75438b19 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -120,6 +120,7 @@ private slots: void connectCxx0x(); void connectToStaticCxx0x(); void connectCxx0xTypeMatching(); + void connectCxx17Noexcept(); void connectConvert(); void connectWithReference(); void connectManyArguments(); @@ -4757,10 +4758,13 @@ class LotsOfSignalsAndSlots: public QObject public slots: void slot_v() {} + void slot_v_noexcept() Q_DECL_NOTHROW {} void slot_vi(int) {} + void slot_vi_noexcept() Q_DECL_NOTHROW {} void slot_vii(int, int) {} void slot_viii(int, int, int) {} int slot_i() { return 0; } + int slot_i_noexcept() Q_DECL_NOTHROW { return 0; } int slot_ii(int) { return 0; } int slot_iii(int, int) { return 0; } int slot_iiii(int, int, int) { return 0; } @@ -4774,13 +4778,18 @@ class LotsOfSignalsAndSlots: public QObject void slot_vPFvvE(fptr) {} void const_slot_v() const {}; + void const_slot_v_noexcept() const Q_DECL_NOTHROW {} void const_slot_vi(int) const {}; + void const_slot_vi_noexcept(int) const Q_DECL_NOTHROW {} static void static_slot_v() {} + static void static_slot_v_noexcept() Q_DECL_NOTHROW {} static void static_slot_vi(int) {} + static void static_slot_vi_noexcept(int) Q_DECL_NOTHROW {} static void static_slot_vii(int, int) {} static void static_slot_viii(int, int, int) {} static int static_slot_i() { return 0; } + static int static_slot_i_noexcept() Q_DECL_NOTHROW { return 0; } static int static_slot_ii(int) { return 0; } static int static_slot_iii(int, int) { return 0; } static int static_slot_iiii(int, int, int) { return 0; } @@ -4943,6 +4952,32 @@ void tst_QObject::connectCxx0xTypeMatching() } +void receiverFunction_noexcept() Q_DECL_NOTHROW {} +struct Functor_noexcept { void operator()() Q_DECL_NOTHROW {} }; +void tst_QObject::connectCxx17Noexcept() +{ + // this is about connecting signals to slots with the Q_DECL_NOTHROW qualifier + // as semantics changed due to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html + typedef LotsOfSignalsAndSlots Foo; + Foo obj; + + QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_v_noexcept); + QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_i_noexcept); + QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_vi_noexcept); + + QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_v_noexcept); + QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_i_noexcept); + QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_vi_noexcept); + + QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_vi_noexcept)); + QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_v_noexcept)); + + QObject::connect(&obj, &Foo::signal_v, receiverFunction_noexcept); + + Functor_noexcept fn; + QObject::connect(&obj, &Foo::signal_v, fn); +} + class StringVariant : public QObject { Q_OBJECT signals: diff --git a/tests/auto/corelib/kernel/qtimer/qtimer.pro b/tests/auto/corelib/kernel/qtimer/qtimer.pro index 8afdbb148e..b27d862bc5 100644 --- a/tests/auto/corelib/kernel/qtimer/qtimer.pro +++ b/tests/auto/corelib/kernel/qtimer/qtimer.pro @@ -2,3 +2,6 @@ CONFIG += testcase TARGET = tst_qtimer QT = core testlib SOURCES = tst_qtimer.cpp + +# Force C++17 if available +contains(QT_CONFIG, c++1z): CONFIG += c++1z diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index fe97695d19..29ff552f6a 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -766,6 +766,11 @@ class StaticEventLoop { public: static void quitEventLoop() + { + quitEventLoop_noexcept(); + } + + static void quitEventLoop_noexcept() Q_DECL_NOTHROW { QVERIFY(!_e.isNull()); _e->quit(); @@ -787,6 +792,9 @@ void tst_QTimer::singleShotToFunctors() QTimer::singleShot(0, &StaticEventLoop::quitEventLoop); QCOMPARE(_e->exec(), 0); + QTimer::singleShot(0, &StaticEventLoop::quitEventLoop_noexcept); + QCOMPARE(_e->exec(), 0); + QThread t1; QObject c1; c1.moveToThread(&t1); From 67f11a31997dc2cf804b627a8d55cc7d78fec37a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: [PATCH 144/304] QtNetwork: fix GCC 7 warnings GCC 7 warns about implicit fall-throughs now. Fix by adding the missing Q_FALLTHROUGH(), and, in one case, by moving the existing suppressant into the correct position. Change-Id: I7383f47e690b6334ef69c9df745c2205247ca7d0 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 2 +- src/network/kernel/qhostaddress.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 205490b830..7fa19dc65b 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1080,8 +1080,8 @@ void QHttpNetworkConnectionChannel::_q_encrypted() "detected unknown Next Protocol Negotiation protocol"); break; } - Q_FALLTHROUGH(); } + Q_FALLTHROUGH(); case QSslConfiguration::NextProtocolNegotiationNone: protocolHandler.reset(new QHttpProtocolHandler(this)); connection->setConnectionType(QHttpNetworkConnection::ConnectionTypeHTTP); diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 8fac76f86a..086e8cede1 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -291,21 +291,27 @@ bool QNetmaskAddress::setAddress(const QHostAddress &address) d->clear(); return false; // invalid IP-style netmask - // the rest always falls through case 254: ++netmask; + Q_FALLTHROUGH(); case 252: ++netmask; + Q_FALLTHROUGH(); case 248: ++netmask; + Q_FALLTHROUGH(); case 240: ++netmask; + Q_FALLTHROUGH(); case 224: ++netmask; + Q_FALLTHROUGH(); case 192: ++netmask; + Q_FALLTHROUGH(); case 128: ++netmask; + Q_FALLTHROUGH(); case 0: break; } From 610c7da075789c1ae736c4a016ef822a4e500f29 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 26 Sep 2016 21:37:49 +0200 Subject: [PATCH 145/304] Plug memleaks in tst_QStackedLayout QLayout::replaceWidget() doesn't delete the affected item, but returns it. Change-Id: Ibda96e4bf2432ad13ed2908c7d37547f46e29a37 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp index 835b6ca799..5be4846b3e 100644 --- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp +++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp @@ -377,7 +377,7 @@ void tst_QStackedLayout::replaceWidget() QCOMPARE(stackLayout->indexOf(replaceFrom), 1); QCOMPARE(stackLayout->indexOf(replaceTo), -1); - stackLayout->replaceWidget(replaceFrom, replaceTo); + delete stackLayout->replaceWidget(replaceFrom, replaceTo); QCOMPARE(stackLayout->indexOf(replaceFrom), -1); QCOMPARE(stackLayout->indexOf(replaceTo), 1); From 7d898ae38e42f44dabcc972ad81cb7f05ecd8ad3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 10 Jan 2017 12:49:11 +0100 Subject: [PATCH 146/304] QGradientCache: fix a new/delete mismatch Commit f839f536 fixed a data race in the gradient cache by reference-counting the CacheInfo objects stored in the cache. To this end, QSpanData gained a ref-counted pointer to the CacheInfo whose members it references to keep the object alive for as long as the QSpanData object needs it. However, since CacheInfo is only later defined in qpaintengine_raster.cpp, the counted pointer's payload was chosen as CacheInfo's base class, QSharedData. As it turns out, e.g. in the QPainter test, the data race was real and so QSpanData ends up being the entity that destroys (at least some) CacheInfos, either in its destructor, or in the setup() method. Since QSharedData's destructor is not virtual, and QExplicitlySharedDataPointer knows nothing of the CacheInfo-ness of its payload, we end up calling the destructor of the base class, and not the CacheInfo one. Fix by using QSharedPointer instead, which stores the correct deleter internally. Ideally, QSpanData would contain a QSharedPointer, but QSharedPointer's implementation is deficient in that respect and does not compile when instantiated with void, and we can't use std::shared_ptr, yet, so introduce an arbitrary base class, Pinnable, to be used instead. Change-Id: I5573c599d5464278d3a8e4248d887ef9ffcd7b70 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/painting/qdrawhelper_p.h | 8 +++++++- src/gui/painting/qpaintengine_raster.cpp | 18 +++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index e537c343bb..0e46962784 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -64,6 +64,8 @@ #include "private/qrasterdefs_p.h" #include +#include + QT_BEGIN_NAMESPACE #if defined(Q_CC_GNU) @@ -335,7 +337,11 @@ struct QSpanData QGradientData gradient; QTextureData texture; }; - QExplicitlySharedDataPointer cachedGradient; + class Pinnable { + protected: + ~Pinnable() {} + }; // QSharedPointer is not supported + QSharedPointer cachedGradient; void init(QRasterBuffer *rb, const QRasterPaintEngine *pe); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index df96a993e3..6d5eaf5aed 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4150,7 +4150,7 @@ void QRasterBuffer::flushToARGBImage(QImage *target) const class QGradientCache { public: - struct CacheInfo : public QSharedData + struct CacheInfo : QSpanData::Pinnable { inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) : stops(qMove(s)), opacity(op), interpolationMode(mode) {} @@ -4161,9 +4161,9 @@ public: QGradient::InterpolationMode interpolationMode; }; - typedef QMultiHash > QGradientColorTableHash; + typedef QMultiHash> QGradientColorTableHash; - inline QExplicitlySharedDataPointer getBuffer(const QGradient &gradient, int opacity) { + inline QSharedPointer getBuffer(const QGradient &gradient, int opacity) { quint64 hash_val = 0; const QGradientStops stops = gradient.stops(); @@ -4177,7 +4177,7 @@ public: return addCacheElement(hash_val, gradient, opacity); else { do { - const QExplicitlySharedDataPointer &cache_info = it.value(); + const auto &cache_info = it.value(); if (cache_info->stops == stops && cache_info->opacity == opacity && cache_info->interpolationMode == gradient.interpolationMode()) return cache_info; ++it; @@ -4193,12 +4193,12 @@ protected: inline void generateGradientColorTable(const QGradient& g, QRgba64 *colorTable, int size, int opacity) const; - QExplicitlySharedDataPointer addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { + QSharedPointer addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { if (cache.size() == maxCacheSize()) { // may remove more than 1, but OK cache.erase(cache.begin() + (qrand() % maxCacheSize())); } - QExplicitlySharedDataPointer cache_entry(new CacheInfo (gradient.stops(), opacity, gradient.interpolationMode())); + auto cache_entry = QSharedPointer::create(gradient.stops(), opacity, gradient.interpolationMode()); generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity); for (int i = 0; i < GRADIENT_STOPTABLE_SIZE; ++i) cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32(); @@ -4438,7 +4438,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QLinearGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; @@ -4460,7 +4460,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QRadialGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; @@ -4486,7 +4486,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QConicalGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; From 6292ecdf6da6c13942dd3f39c9cd164c29c7ab37 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 5 Oct 2016 23:29:41 +0200 Subject: [PATCH 147/304] QSystemTrayIcon: initialize all members The 'showArrow' member was not init'ed. Initialize it to true, which is the default value of the QBalloonTip::showBalloon() function's argument of the same purpose. Reported as new by Coverity, but dating back all the way to cc3875c2e463be5cf126a18637295a0c56358eda, so affects all current branches. Coverity-Id: 171482 Change-Id: Ica519ecda3a4ae413f606faab8c22f7072f412a8 Reviewed-by: Friedemann Kleint --- src/widgets/util/qsystemtrayicon.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 224ffeb6e2..630524aadb 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -436,7 +436,10 @@ bool QBalloonTip::isBalloonVisible() QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title, const QString& message, QSystemTrayIcon *ti) - : QWidget(0, Qt::ToolTip), trayIcon(ti), timerId(-1) + : QWidget(0, Qt::ToolTip), + trayIcon(ti), + timerId(-1), + showArrow(true) { setAttribute(Qt::WA_DeleteOnClose); QObject::connect(ti, SIGNAL(destroyed()), this, SLOT(close())); From 21306bccc4fef8c78d550946ec4d7a5426eb5b0d Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 13 Jan 2017 17:29:17 +0900 Subject: [PATCH 148/304] Fix build without feature.tabletevent Change-Id: I13950e184453318671e4cac6dac844e76771f430 Reviewed-by: Lars Knoll --- src/platformsupport/input/input.pro | 4 +++- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/input/input.pro b/src/platformsupport/input/input.pro index 2c2ace6780..f8ff4344cf 100644 --- a/src/platformsupport/input/input.pro +++ b/src/platformsupport/input/input.pro @@ -11,7 +11,9 @@ qtConfig(evdev) { include($$PWD/evdevmouse/evdevmouse.pri) include($$PWD/evdevkeyboard/evdevkeyboard.pri) include($$PWD/evdevtouch/evdevtouch.pri) - include($$PWD/evdevtablet/evdevtablet.pri) + qtConfig(tabletevent) { + include($$PWD/evdevtablet/evdevtablet.pri) + } } qtConfig(tslib) { diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index f4f56f25f1..d91cbfe82d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1032,6 +1032,7 @@ bool QXcbConnection::isTouchScreen(int id) const && device->qtTouchDevice->type() == QTouchDevice::TouchScreen; } +#if QT_CONFIG(tabletevent) static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { // keep in sync with wacom_intuos_inout() in Linux kernel driver wacom_wac.c switch (toolId) { @@ -1065,7 +1066,6 @@ static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { return QTabletEvent::Stylus; // Safe default assumption if nonzero } -#ifndef QT_NO_TABLETEVENT bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletData) { bool handled = true; From 4baf08653c69fe5a131dae4ea27ac4cd67743f6e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 09:02:03 +0100 Subject: [PATCH 149/304] QHostAddress: add missing docs qHash(QHostAddress) was added in Qt 5.0 (at least the version with uint seed = 0). op==(QHostAddress::SpecialAddress, QHostAddress) was there since QHostAddress was added before public history. Since QHostAddress does not have a \since, the I did not supply one for op==, either. Since the equality operator did not have unit-tests, added one. Change-Id: I954a0df02464338f08a12ca58d4cc0ceb013e67a Reviewed-by: Thiago Macieira --- src/network/kernel/qhostaddress.cpp | 14 ++++++++++++++ .../kernel/qhostaddress/tst_qhostaddress.cpp | 1 + 2 files changed, 15 insertions(+) diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 086e8cede1..fc753204a9 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1251,6 +1251,11 @@ QDebug operator<<(QDebug d, const QHostAddress &address) } #endif +/*! + \since 5.0 + \relates QHostAddress + Returns a hash of the host address \a key, using \a seed to seed the calculation. +*/ uint qHash(const QHostAddress &key, uint seed) { // both lines might throw @@ -1258,6 +1263,15 @@ uint qHash(const QHostAddress &key, uint seed) return qHashBits(key.d->a6.c, 16, seed); } +/*! + \relates QHostAddress + \fn operator==(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs) + + Returns \c true if special address \a lhs is the same as host address \a rhs; + otherwise returns \c false. + + \sa isEqual() +*/ #ifndef QT_NO_DATASTREAM /*! \relates QHostAddress diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp index 364e435d3d..a715c38f32 100644 --- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp +++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp @@ -271,6 +271,7 @@ void tst_QHostAddress::specialAddresses() //check special address equal to itself (QTBUG-22898), note two overloads of operator== QVERIFY(QHostAddress(address) == QHostAddress(address)); QVERIFY(QHostAddress(address) == address); + QVERIFY(address == QHostAddress(address)); QVERIFY(!(QHostAddress(address) != QHostAddress(address))); QVERIFY(!(QHostAddress(address) != address)); From 0deca277d2d187a455b38d717578814be6f93231 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: [PATCH 150/304] QtCore: fix GCC 7 warnings GCC 7 warns about implicit fall-throughs now. Fix by adding Q_FALLTHROUGH. Change-Id: I482ab4c6adc469b11e1fd163516ff486b3b55ef7 Reviewed-by: Thiago Macieira --- src/corelib/statemachine/qstatemachine.cpp | 4 +++- src/corelib/tools/qdatetimeparser.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 433f595611..d7cdec9aac 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -2024,7 +2024,9 @@ void QStateMachinePrivate::processEvents(EventProcessingMode processingMode) if (QThread::currentThread() == q->thread()) { _q_process(); break; - } // fallthrough -- processing must be done in the machine thread + } + // processing must be done in the machine thread, so: + Q_FALLTHROUGH(); case QueuedProcessing: processingScheduled = true; QMetaObject::invokeMethod(q, "_q_process", Qt::QueuedConnection); diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index ae429950c8..65016933a0 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1139,6 +1139,7 @@ end: } break; } } + Q_FALLTHROUGH(); case MonthSection: if (sn.count >= 3) { const int currentMonth = newCurrentValue.date().month(); From dbb4504f1214cddff47eb3b8dd935f3adb7f0940 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Sun, 15 Jan 2017 00:26:42 +0100 Subject: [PATCH 151/304] Add Q_CC_CLANG to the documentation page Task-number: QTBUG-42247 Change-Id: I3f707df4d25cac12fabac863b4f6bb50bfac5e26 Reviewed-by: Jake Petroules --- src/corelib/global/qglobal.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6efdc4c22c..f6053ce622 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1518,6 +1518,13 @@ bool qSharedBuild() Q_DECL_NOTHROW C/C++, Intel C++ for Windows. */ +/*! + \macro Q_CC_CLANG + \relates + + Defined if the application is compiled using Clang. +*/ + /*! \macro Q_CC_BOR \relates From 9ad4e651d26334f77297cc7cbfb413e3c22c391d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 12 Jan 2017 16:06:28 +0100 Subject: [PATCH 152/304] Fully qualify enum arguments in input device manager signals Otherwise queued connections may complain about DeviceType not being registered. Change-Id: I1f93f8b34e78919e72ea99000c42da7024b6bdf3 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qinputdevicemanager_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h index 11bbaae592..db9d0596b6 100644 --- a/src/gui/kernel/qinputdevicemanager_p.h +++ b/src/gui/kernel/qinputdevicemanager_p.h @@ -79,7 +79,7 @@ public: void setCursorPos(const QPoint &pos); signals: - void deviceListChanged(DeviceType type); + void deviceListChanged(QInputDeviceManager::DeviceType type); void cursorPositionChangeRequested(const QPoint &pos); }; From ca7f67e82b380e1b45a29cb2d2982bfe5e773d4a Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 14 Jan 2017 13:20:30 +0900 Subject: [PATCH 153/304] Fix build without feature.animation Change-Id: Ia1b9ae3a35cbc73d0bbf27db234d0cd120d0b601 Reviewed-by: Lars Knoll --- src/corelib/statemachine/qstatemachine_p.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 9418813afd..c28b162305 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -79,7 +79,7 @@ class QFinalState; class QHistoryState; class QState; -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) class QAbstractAnimation; #endif @@ -123,7 +123,7 @@ public: // private slots void _q_start(); void _q_process(); -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) void _q_animationFinished(); #endif void _q_startDelayedEventTimer(int id, int delay); @@ -152,7 +152,7 @@ public: const QList &statesToEnter_sorted, const QSet &statesForDefaultEntry, QHash > &propertyAssignmentsForState -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) , const QList &selectedAnimations #endif ); @@ -264,7 +264,7 @@ public: QSet pendingErrorStates; QSet pendingErrorStatesForDefaultEntry; -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) bool animated; struct InitializeAnimationResult { @@ -326,7 +326,9 @@ public: static const Handler *handler; }; +#if QT_CONFIG(animation) Q_DECLARE_SHARED(QStateMachinePrivate::InitializeAnimationResult) +#endif Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler(); From f225a459a0555eed6f2a2eac6509173d9f5207a1 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 5 Jan 2017 12:39:56 +0100 Subject: [PATCH 154/304] Fix unneeded recompiles of glslang_tab.cpp To work around qmake deficiencies src/angle/src/compiler/translator.pro contains a no-op extra compiler that "creates" glslang_tab.cpp and adds a dependency to glslang_tab.h. However, both files are created in one bison call, and for some reason the .cpp file is created before the .h file. Then the dependency glslang_tab.cpp -> glslang_tab.h results in recompiling glslang_tab.cpp on every incremental build. Ensure that glslang_tab.cpp is newer than glslang_tab.h. Change-Id: I6f59e213c84af85c59c02d90ac220bd347faddd1 Reviewed-by: Oswald Buddenhagen --- src/angle/src/compiler/translator.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/angle/src/compiler/translator.pro b/src/angle/src/compiler/translator.pro index 663a8892a7..398b9230cc 100644 --- a/src/angle/src/compiler/translator.pro +++ b/src/angle/src/compiler/translator.pro @@ -189,7 +189,8 @@ QMAKE_EXTRA_COMPILERS += flex defineReplace(myDirName) { return($$dirname(1)) } bison.commands = $$addGnuPath(bison) --no-lines --skeleton=yacc.c --defines=${QMAKE_FILE_OUT} \ --output=${QMAKE_FUNC_FILE_OUT_myDirName}$$QMAKE_DIR_SEP${QMAKE_FILE_OUT_BASE}.cpp \ - ${QMAKE_FILE_NAME} + ${QMAKE_FILE_NAME}$$escape_expand(\\n\\t) \ + @echo // EOF>>${QMAKE_FUNC_FILE_OUT_myDirName}$$QMAKE_DIR_SEP${QMAKE_FILE_OUT_BASE}.cpp bison.output = $${BUILDSUBDIR}${QMAKE_FILE_BASE}_tab.h bison.input = BISON_SOURCES bison.dependency_type = TYPE_C From 17515f1b621952846237dfcdd401bb76f132a20d Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 14 Jan 2017 12:17:39 +0900 Subject: [PATCH 155/304] Fix build without feature.imageformatplugin Change-Id: I28c146bfa1795794ad27d27c458970c5127cca67 Reviewed-by: Lars Knoll --- src/gui/configure.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/configure.json b/src/gui/configure.json index 01566ad35b..154ba63f00 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -636,6 +636,7 @@ }, "gif": { "label": "GIF", + "condition": "features.imageformatplugin", "output": [ "privateFeature", { "type": "define", "negative": true, "name": "QT_NO_IMAGEFORMAT_GIF" } @@ -643,11 +644,13 @@ }, "ico": { "label": "ICO", + "condition": "features.imageformatplugin", "output": [ "privateFeature", "feature" ] }, "jpeg": { "label": "JPEG", "disable": "input.libjpeg == 'no'", + "condition": "features.imageformatplugin", "output": [ "privateFeature", { "type": "define", "negative": true, "name": "QT_NO_IMAGEFORMAT_JPEG" } From e12b9b0db32a7480f3beb0ee7be919f059b80c21 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 11 Jan 2017 10:01:44 +0100 Subject: [PATCH 156/304] QKeySequenceEdit: If the next key is Key_unknown then it should be ignored When triggering a combination of keys which is causing a dead key then it will send Key_unknown which is not a valid key to be used in a shortcut so it should just skip past it as if it were a modifier key. Task-number: QTBUG-57932 Change-Id: I16e004b84f3aa854f8f8f2bbdf86beb6d764de48 Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/widgets/widgets/qkeysequenceedit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 2fbc42330d..3252ce5941 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -257,7 +257,8 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) if (nextKey == Qt::Key_Control || nextKey == Qt::Key_Shift || nextKey == Qt::Key_Meta - || nextKey == Qt::Key_Alt) { + || nextKey == Qt::Key_Alt + || nextKey == Qt::Key_unknown) { return; } From 117b3e1b8f43bea829b818e4c20645e8a8d1e8e6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Jan 2017 12:50:07 +0100 Subject: [PATCH 157/304] qt_targets.prf: Don't unconditionally set product and description Check on QMAKE_TARGET_PRODUCT/QMAKE_TARGET_DESCRIPTION before assigning values. This enables providing other values by for example the Qt tool applications. Change-Id: I62270ca38b7a9110185f6163b280409dbaf395f6 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_targets.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/qt_targets.prf b/mkspecs/features/qt_targets.prf index 72429526a7..69e39170cc 100644 --- a/mkspecs/features/qt_targets.prf +++ b/mkspecs/features/qt_targets.prf @@ -1,4 +1,4 @@ QMAKE_TARGET_COMPANY = The Qt Company Ltd -QMAKE_TARGET_PRODUCT = Qt5 -QMAKE_TARGET_DESCRIPTION = C++ application development framework. +isEmpty(QMAKE_TARGET_PRODUCT): QMAKE_TARGET_PRODUCT = Qt5 +isEmpty(QMAKE_TARGET_DESCRIPTION): QMAKE_TARGET_DESCRIPTION = C++ application development framework. QMAKE_TARGET_COPYRIGHT = Copyright (C) 2015 The Qt Company Ltd. From 0243863382ab580a0d25c4df9e9bfa6e2f31c7cb Mon Sep 17 00:00:00 2001 From: Aleksei Ilin Date: Mon, 14 Nov 2016 20:27:38 +0300 Subject: [PATCH 158/304] Fix access incorrect index in QListView with batch layout The size of flowPositions is larger by one than the number of rows in the model so the last correct row number is flowPositions.count()-2, not flowPositions.count()-1. Change-Id: Idf8bbd155151d553947d5d299dd01ffaff0c95fa Task-number: QTBUG-47694 Reviewed-by: Alexander Volkov Reviewed-by: David Faure --- src/widgets/itemviews/qlistview.cpp | 2 +- .../widgets/itemviews/qlistview/tst_qlistview.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 0788e0287a..65421bfb67 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -2348,7 +2348,7 @@ QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) c { if (flowPositions.isEmpty() || segmentPositions.isEmpty() - || index.row() >= flowPositions.count()) + || index.row() >= flowPositions.count() - 1) return QListViewItem(); const int segment = qBinarySearch(segmentStartRows, index.row(), diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 0f1c5723d5..6eed21abb2 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -150,6 +150,7 @@ private slots: void horizontalScrollingByVerticalWheelEvents(); void taskQTBUG_7232_AllowUserToControlSingleStep(); void taskQTBUG_51086_skippingIndexesInSelectedIndexes(); + void taskQTBUG_47694_indexOutOfBoundBatchLayout(); }; // Testing get/set functions @@ -2486,5 +2487,18 @@ void tst_QListView::taskQTBUG_51086_skippingIndexesInSelectedIndexes() QVERIFY(!indexes.contains(data.index(8, 0))); } +void tst_QListView::taskQTBUG_47694_indexOutOfBoundBatchLayout() +{ + QListView view; + view.setLayoutMode(QListView::Batched); + int batchSize = view.batchSize(); + + QStandardItemModel model(batchSize + 1, 1); + + view.setModel(&model); + + view.scrollTo(model.index(batchSize - 1, 0)); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" From 83583d7999181ba613a0e27a8006e4c092edffa7 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 13 Jan 2017 19:17:04 +0900 Subject: [PATCH 159/304] Fix build without feature.cssparser Change-Id: Ib751a3d1ad37aae68d6a05aab493833fbcc0b53d Reviewed-by: Lars Knoll --- src/gui/text/qtexthtmlparser_p.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h index e93d46a59f..77bfa685c0 100644 --- a/src/gui/text/qtexthtmlparser_p.h +++ b/src/gui/text/qtexthtmlparser_p.h @@ -243,7 +243,7 @@ struct QTextHtmlParserNode { void parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider); -#ifndef QT_NO_CSSPARSER +#if QT_CONFIG(cssparser) void applyCssDeclarations(const QVector &declarations, const QTextDocument *resourceProvider); void setListStyle(const QVector &cssValues); @@ -317,7 +317,7 @@ protected: bool nodeIsChildOf(int i, QTextHTMLElements id) const; -#ifndef QT_NO_CSSPARSER +#if QT_CONFIG(cssparser) QVector declarationsForNode(int node) const; void resolveStyleSheetImports(const QCss::StyleSheet &sheet); void importStyleSheet(const QString &href); @@ -337,7 +337,9 @@ protected: const QTextDocument *resourceProvider; }; +#if QT_CONFIG(cssparser) Q_DECLARE_TYPEINFO(QTextHtmlParser::ExternalStyleSheet, Q_MOVABLE_TYPE); +#endif QT_END_NAMESPACE From 5a628fdb98cf6d9fddb890069f7a8d327bdafadf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Jan 2017 12:55:11 +0100 Subject: [PATCH 160/304] qt_targets.prf: Bump copyright year Change-Id: I371fbc28abd6b0e3497e94b7d974fef5d20c7acc Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_targets.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/qt_targets.prf b/mkspecs/features/qt_targets.prf index 69e39170cc..cd76efdaf3 100644 --- a/mkspecs/features/qt_targets.prf +++ b/mkspecs/features/qt_targets.prf @@ -1,4 +1,4 @@ QMAKE_TARGET_COMPANY = The Qt Company Ltd isEmpty(QMAKE_TARGET_PRODUCT): QMAKE_TARGET_PRODUCT = Qt5 isEmpty(QMAKE_TARGET_DESCRIPTION): QMAKE_TARGET_DESCRIPTION = C++ application development framework. -QMAKE_TARGET_COPYRIGHT = Copyright (C) 2015 The Qt Company Ltd. +QMAKE_TARGET_COPYRIGHT = Copyright (C) 2017 The Qt Company Ltd. From 23ba2f073cf163b379312d5086a880c7ec040209 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Jan 2017 16:04:33 +0100 Subject: [PATCH 161/304] Windows QPA: Fix QScreen::grabWindow(0) for non-primary screens Previously, the code grabbed the client rectangle of GetDesktopWindow(), which is always the primary screen. Fix by using the geometry of the QPlatformScreen. In addition, subtract x, y from the effective size when sizes < 0 were passed in as does XCB. Task-number: QTBUG-58110 Change-Id: I6ed439d2e1da8affd0a1475717d5570017fb1f2b Reviewed-by: Oliver Wolff Reviewed-by: Joerg Bornemann --- .../platforms/windows/qwindowsscreen.cpp | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 23d43a95a5..7a885b462e 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -188,14 +188,30 @@ QWindowsScreen::QWindowsScreen(const QWindowsScreenData &data) : Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); -QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const +QPixmap QWindowsScreen::grabWindow(WId window, int xIn, int yIn, int width, int height) const { - RECT r; - HWND hwnd = window ? reinterpret_cast(window) : GetDesktopWindow(); - GetClientRect(hwnd, &r); + QSize windowSize; + int x = xIn; + int y = yIn; + HWND hwnd = reinterpret_cast(window); + if (hwnd) { + RECT r; + GetClientRect(hwnd, &r); + windowSize = QSize(r.right - r.left, r.bottom - r.top); + } else { + // Grab current screen. The client rectangle of GetDesktopWindow() is the + // primary screen, but it is possible to grab other screens from it. + hwnd = GetDesktopWindow(); + const QRect screenGeometry = geometry(); + windowSize = screenGeometry.size(); + x += screenGeometry.x(); + y += screenGeometry.y(); + } - if (width < 0) width = r.right - r.left; - if (height < 0) height = r.bottom - r.top; + if (width < 0) + width = windowSize.width() - xIn; + if (height < 0) + height = windowSize.height() - yIn; // Create and setup bitmap HDC display_dc = GetDC(0); From a7d34eff8f8a2ca81e7bcb5d110a507995ea42ab Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 17 Jan 2017 15:43:49 +0000 Subject: [PATCH 162/304] Update .gitignore Change-Id: If4de9b2f2b469f45b2d579d0401bde44d3477d3c Reviewed-by: Oswald Buddenhagen --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index a1079a33c6..e0677a3a68 100644 --- a/.gitignore +++ b/.gitignore @@ -120,6 +120,7 @@ config.opt config.status config.summary config.log +config.cache mkspecs/default mkspecs/default-host mkspecs/qconfig.pri @@ -127,12 +128,14 @@ mkspecs/qdevice.pri mkspecs/qfeatures.pri mkspecs/qhost.pri moc_*.cpp +qmake/qmake qmake/qmake.exe qmake/Makefile.bak qmake/qmake_pch.pch src/corelib/global/qconfig.cpp src/corelib/global/qconfig.h src/corelib/global/qconfig.h.qmake +src/corelib/global/qconfig_p.h src/corelib/global/qfeatures.h src/platformsupport/*_interface.* src/platformsupport/*_adaptor.* @@ -155,6 +158,9 @@ translations/*_untranslated.ts qrc_*.cpp *.version *.version.in +qt*-config.h +qt*-config_p.h +qt*-config.pri # Test generated files QObject.log From 19a1a0871d4a9081646925c422fe32e900846c2e Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Mon, 16 Jan 2017 21:43:12 +0100 Subject: [PATCH 163/304] QSslDiffieHellmanParameters: simplify defaultParameters() construction This commit simplifies defaultParameters() to simply construct an empty QSslDiffieHellmanParameters and assigning the DER-form of the DH parameters to QSslDiffieHellmanParametersPrivate's derData field. This creates a valid QSslDiffieHellmanParameters instance, but skips any potentially expensive verification steps. The previous implementation of defaultParameters() would use the public fromEncoded() method to construct an instance of the default parameters. This triggers a verification of the passed-in data, which can be expensive. To ensure our defaultParameters() QSslDiffieHellmanParameters instance does pass verification, this commit adds an autotest to verify that. Fixes QTBUG-57815. Change-Id: I6b1d9dbbfde526b232c319195ddbad42326be27c Task-number: QTBUG-57815 Reviewed-by: Timur Pocheptsov --- .../ssl/qssldiffiehellmanparameters.cpp | 18 +++++----- .../tst_qssldiffiehellmanparameters.cpp | 35 +++++++++++++++++++ 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/network/ssl/qssldiffiehellmanparameters.cpp b/src/network/ssl/qssldiffiehellmanparameters.cpp index d0fcb3189a..de7eab9a9e 100644 --- a/src/network/ssl/qssldiffiehellmanparameters.cpp +++ b/src/network/ssl/qssldiffiehellmanparameters.cpp @@ -68,6 +68,12 @@ QT_BEGIN_NAMESPACE +// The 1024-bit MODP group from RFC 2459 (Second Oakley Group) +Q_AUTOTEST_EXPORT const char *qssl_dhparams_default_base64 = + "MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR" + "Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL" + "/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC"; + /*! Returns the default QSslDiffieHellmanParameters used by QSslSocket. @@ -76,15 +82,9 @@ QT_BEGIN_NAMESPACE */ QSslDiffieHellmanParameters QSslDiffieHellmanParameters::defaultParameters() { - // The 1024-bit MODP group from RFC 2459 (Second Oakley Group) - return fromEncoded( - QByteArray::fromBase64(QByteArrayLiteral( - "MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR" - "Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL" - "/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC" - )), - QSsl::Der - ); + QSslDiffieHellmanParameters def; + def.d->derData = QByteArray::fromBase64(QByteArray(qssl_dhparams_default_base64)); + return def; } /*! diff --git a/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp b/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp index f3b9003fbb..ddf503eed6 100644 --- a/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp +++ b/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp @@ -42,6 +42,13 @@ #include #include +// Default DH parameters, exported by qssldiffiehellmanparameters.cpp. +QT_BEGIN_NAMESPACE +extern Q_AUTOTEST_EXPORT const char *qssl_dhparams_default_base64; +QT_END_NAMESPACE + +QT_USE_NAMESPACE + class tst_QSslDiffieHellmanParameters : public QObject { Q_OBJECT @@ -54,6 +61,7 @@ private Q_SLOTS: void constructionPEM(); void unsafe512Bits(); void unsafeNonPrime(); + void defaultIsValid(); #endif }; @@ -157,6 +165,33 @@ void tst_QSslDiffieHellmanParameters::unsafeNonPrime() #endif } +void tst_QSslDiffieHellmanParameters::defaultIsValid() +{ + // The QSslDiffieHellmanParameters::defaultParameters() method takes a shortcut, + // by not verifying the passed-in parameters. Instead, it simply assigns the default + // DH parameters to the derData field of QSslDiffieHellmanParametersPrivate. + // + // This test ensures that our default parameters pass the internal verification tests + // by constructing, using fromEncoded(), a QSslDiffieHellmanParameters instance that + // we expect to be equivalent to the one returned by defaultParameters(). By using + // fromEncoded() we go through the internal verification mechanisms. Finally, to ensure + // the two instances are equivalent, we compare them. + + const auto dh = QSslDiffieHellmanParameters::fromEncoded( + QByteArray::fromBase64(QByteArray(qssl_dhparams_default_base64)), + QSsl::Der + ); + + const auto defaultdh = QSslDiffieHellmanParameters::defaultParameters(); + +#ifndef QT_NO_OPENSSL + QCOMPARE(dh.isEmpty(), false); + QCOMPARE(dh.isValid(), true); + QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError); + QCOMPARE(dh, defaultdh); +#endif +} + #endif // QT_NO_SSL QTEST_MAIN(tst_QSslDiffieHellmanParameters) From 88932d4339ea604a1bea8c09aef3945ac348df9c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 Jan 2017 13:31:06 +0100 Subject: [PATCH 164/304] Android: transform input rectangle correctly QRect::setX/setY will change both position and size. In this case, the width and/or height of the input rectangle could end up negative. The correct functions to use are moveLeft/moveTop which will preserve the size when changing the position. Task-number: QTBUG-58179 Change-Id: I71a2e38958754dc53e062ad1c780e2337f72ec32 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroidinputcontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 12e85046f8..436e41bad5 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -354,8 +354,8 @@ static QRect inputItemRectangle() ? QHighDpiScaling::factor(window) : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); if (pixelDensity != 1.0) { - rect.setX(rect.x() * pixelDensity); - rect.setY(rect.y() * pixelDensity); + rect.moveLeft(rect.x() * pixelDensity); + rect.moveTop(rect.y() * pixelDensity); rect.setWidth(rect.width() * pixelDensity); rect.setHeight(rect.height() * pixelDensity); } From 1e7ce7aab07bf8605503bf1e5a3da3e9f86d42cb Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 17 Jan 2017 13:24:57 +0100 Subject: [PATCH 165/304] Fix registration of system default font QPlatformFontDatabase::resolveFontFamilyAlias returns the input unchanged if the font-name is not found. This means we never register the system default font when it is only a virtual font name. Task-number: QTBUG-58225 Change-Id: Ib4f80bb758aa66a163d223573bfe624bb3c134ab Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/windows/qwindowsfontdatabase.cpp | 2 +- .../fontdatabases/windows/qwindowsfontdatabase_ft.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 887123083a..c457246354 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1191,7 +1191,7 @@ void QWindowsFontDatabase::populateFontDatabase() ReleaseDC(0, dummy); // Work around EnumFontFamiliesEx() not listing the system font. QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family(); - if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily).isEmpty()) + if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily) == systemDefaultFamily) QPlatformFontDatabase::registerFontFamily(systemDefaultFamily); } diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp index ebb82baf6f..7cfebf0436 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp @@ -386,7 +386,7 @@ void QWindowsFontDatabaseFT::populateFontDatabase() ReleaseDC(0, dummy); // Work around EnumFontFamiliesEx() not listing the system font QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family(); - if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily).isEmpty()) + if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily) == systemDefaultFamily) QPlatformFontDatabase::registerFontFamily(systemDefaultFamily); } From 49dc9aa409d727824f26b246054a22b5a7dd5980 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Jan 2017 10:40:18 +0100 Subject: [PATCH 166/304] Windows QPA: Do not return QPlatformIntegration::ShowIsMaximized in tablet mode The hint is not appropriate for Windows 10 tablet mode as it affects only main windows. Dialogs should still show up in normal size. Partially reverts change d377f14fd5b4fe3ed64392c6b743bac395f9f891. Task-number: QTBUG-58227 Change-Id: If9cf4990eb40913904cd97e17a7622bc6cbe84ca Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/windows/qwindowsintegration.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index f49ad0e767..3f74fd5296 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -512,11 +512,6 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co return QVariant(keyBoardAutoRepeatRateMS()); #endif case QPlatformIntegration::ShowIsMaximized: -#ifndef QT_NO_CLIPBOARD - return qt_windowsIsTabletMode(d->m_clipboard.clipboardViewer()); -#else - break; -#endif case QPlatformIntegration::StartDragTime: case QPlatformIntegration::StartDragDistance: case QPlatformIntegration::KeyboardInputInterval: From 3e31b71b9ca859cad8823a9d8d19063dd14be809 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Wed, 2 Nov 2016 20:40:12 +0300 Subject: [PATCH 167/304] dbusmenu: Map showPopup method to ItemActivationRequested signal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way the Qt accelerator shortcuts (i.e. Alt+F for the File menu) will cause the matching menu to be opened on the server side. Change-Id: I02a5b3c20c6eae130d0f133b33c9e247cff38d44 Reviewed-by: Tor Arne Vestbø --- .../themes/genericunix/dbusmenu/qdbusmenubar.cpp | 2 ++ .../genericunix/dbusmenu/qdbusplatformmenu.cpp | 14 ++++++++++++++ .../genericunix/dbusmenu/qdbusplatformmenu_p.h | 9 ++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp index 76d658f51a..fb0705c8c7 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp @@ -59,6 +59,8 @@ QDBusMenuBar::QDBusMenuBar() m_menuAdaptor, &QDBusMenuAdaptor::ItemsPropertiesUpdated); connect(m_menu, &QDBusPlatformMenu::updated, m_menuAdaptor, &QDBusMenuAdaptor::LayoutUpdated); + connect(m_menu, &QDBusPlatformMenu::popupRequested, + m_menuAdaptor, &QDBusMenuAdaptor::ItemActivationRequested); } QDBusMenuBar::~QDBusMenuBar() diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp index 15440a03cd..c1ebbbf91b 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu.cpp @@ -39,6 +39,7 @@ #include "qdbusplatformmenu_p.h" +#include #include #include @@ -210,6 +211,8 @@ void QDBusPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem) this, &QDBusPlatformMenu::propertiesUpdated); disconnect(menu, &QDBusPlatformMenu::updated, this, &QDBusPlatformMenu::updated); + disconnect(menu, &QDBusPlatformMenu::popupRequested, + this, &QDBusPlatformMenu::popupRequested); } emitUpdated(); } @@ -222,6 +225,8 @@ void QDBusPlatformMenu::syncSubMenu(const QDBusPlatformMenu *menu) this, &QDBusPlatformMenu::propertiesUpdated, Qt::UniqueConnection); connect(menu, &QDBusPlatformMenu::updated, this, &QDBusPlatformMenu::updated, Qt::UniqueConnection); + connect(menu, &QDBusPlatformMenu::popupRequested, + this, &QDBusPlatformMenu::popupRequested, Qt::UniqueConnection); } void QDBusPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem) @@ -278,6 +283,15 @@ void QDBusPlatformMenu::setContainingMenuItem(QDBusPlatformMenuItem *item) m_containingMenuItem = item; } +void QDBusPlatformMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) +{ + Q_UNUSED(parentWindow); + Q_UNUSED(targetRect); + Q_UNUSED(item); + setVisible(true); + emit popupRequested(m_containingMenuItem->dbusID(), QDateTime::currentMSecsSinceEpoch()); +} + QPlatformMenuItem *QDBusPlatformMenu::menuItemAt(int position) const { return m_items.value(position); diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h index 38c27e8051..2e6e04d28d 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusplatformmenu_p.h @@ -161,13 +161,7 @@ public: void setMenuType(MenuType type) Q_DECL_OVERRIDE { Q_UNUSED(type); } void setContainingMenuItem(QDBusPlatformMenuItem *item); - void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) Q_DECL_OVERRIDE - { - Q_UNUSED(parentWindow); - Q_UNUSED(targetRect); - Q_UNUSED(item); - setVisible(true); - } + void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) Q_DECL_OVERRIDE; void dismiss() Q_DECL_OVERRIDE { } // Closes this and all its related menu popups @@ -187,6 +181,7 @@ public: signals: void updated(uint revision, int dbusId); void propertiesUpdated(QDBusMenuItemList updatedProps, QDBusMenuItemKeysList removedProps); + void popupRequested(int id, uint timestamp); private: quintptr m_tag; From 287f548d4c7cc594ffecc9c050dc5ec9fdaa6d37 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Wed, 2 Nov 2016 10:51:39 +0300 Subject: [PATCH 168/304] Make shortcuts work for platform menu bars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a platform menu bar is used, the QMenuBar is hidden, so shortcuts for QActions attached only to it do not work. Extend the macOS-specific code to treat such menubars as visible to other platforms, to make the shortcuts work. The exception is made for internal QMenuBar shortcuts, which are forwarded to the platform menu. A follow-up change will add support for this to QDBusPlatformMenu. The updateGeometries() method is called for platform menu bars too to make sure the internal shortcuts are registered even if the global menu is in use. Add two cases to the tst_QMenuBar::activatedCount() test to test both native and non-native menu bars when possible (it now passes with native menu bars too). Change-Id: I2d7128512719ac199cd3f8f7ba28333d04d84ed4 Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qshortcut.cpp | 8 +++--- src/widgets/widgets/qmenubar.cpp | 13 ++++++++-- .../widgets/widgets/qmenubar/tst_qmenubar.cpp | 25 +++++++++++++------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 6eec5ff7e8..be5788274e 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -141,9 +141,11 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) { bool visible = w->isVisible(); -#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR) - if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast(w)) - visible = true; +#ifndef QT_NO_MENUBAR + if (QMenuBar *menuBar = qobject_cast(w)) { + if (menuBar->isNativeMenuBar()) + visible = true; + } #endif if (!visible || !w->isEnabled()) diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 63fe09f77e..2588f41468 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1271,10 +1271,12 @@ void QMenuBar::actionEvent(QActionEvent *e) } else if(e->type() == QEvent::ActionRemoved) { e->action()->disconnect(this); } - if (isVisible()) { + // updateGeometries() is also needed for native menu bars because + // it updates shortcutIndexMap + if (isVisible() || isNativeMenuBar()) d->updateGeometries(); + if (isVisible()) update(); - } } /*! @@ -1686,6 +1688,13 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id) { Q_Q(QMenuBar); QAction *act = actions.at(id); + if (act && act->menu()) { + if (QPlatformMenu *platformMenu = act->menu()->platformMenu()) { + platformMenu->showPopup(q->windowHandle(), actionRects.at(id), Q_NULLPTR); + return; + } + } + setCurrentAction(act, true, true); if (act && !act->menu()) { activateAction(act, QAction::Trigger); diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index b04fb7cd5d..f19d7619cc 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -93,6 +93,7 @@ private slots: #if !defined(Q_OS_DARWIN) void accel(); void activatedCount(); + void activatedCount_data(); void check_accelKeys(); void check_cursorKeys1(); @@ -144,8 +145,8 @@ protected slots: void slotForTaskQTBUG53205(); private: - TestMenu initSimpleMenuBar(QMenuBar *mb); - TestMenu initWindowWithSimpleMenuBar(QMainWindow &w); + TestMenu initSimpleMenuBar(QMenuBar *mb, bool forceNonNative = true); + TestMenu initWindowWithSimpleMenuBar(QMainWindow &w, bool forceNonNative = true); QAction *createCharacterAction(QMenu *menu, char lowerAscii); QMenu *addNumberedMenu(QMenuBar *mb, int n); TestMenu initComplexMenuBar(QMenuBar *mb); @@ -213,10 +214,10 @@ void tst_QMenuBar::cleanup() // Create a simple menu bar and connect its actions to onSimpleActivated(). -TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb) -{ +TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb, bool forceNonNative) { TestMenu result; - mb->setNativeMenuBar(false); + if (forceNonNative) + mb->setNativeMenuBar(false); connect(mb, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*))); QMenu *menu = mb->addMenu(QStringLiteral("&accel")); QAction *action = menu->addAction(QStringLiteral("menu1") ); @@ -239,11 +240,11 @@ TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb) return result; } -inline TestMenu tst_QMenuBar::initWindowWithSimpleMenuBar(QMainWindow &w) +inline TestMenu tst_QMenuBar::initWindowWithSimpleMenuBar(QMainWindow &w, bool forceNonNative) { w.resize(200, 200); centerOnScreen(&w); - return initSimpleMenuBar(w.menuBar()); + return initSimpleMenuBar(w.menuBar(), forceNonNative); } // add a menu with number n, set number as data. @@ -341,7 +342,8 @@ void tst_QMenuBar::activatedCount() { // create a popup menu with menu items set the accelerators later... QMainWindow w; - initWindowWithSimpleMenuBar(w); + QFETCH( bool, forceNonNative ); + initWindowWithSimpleMenuBar(w, forceNonNative); w.show(); QApplication::setActiveWindow(&w); QVERIFY(QTest::qWaitForWindowActive(&w)); @@ -350,6 +352,13 @@ void tst_QMenuBar::activatedCount() //wait(5000); QCOMPARE( m_simpleActivatedCount, 2 ); //1 from the popupmenu and 1 from the menubar } + +void tst_QMenuBar::activatedCount_data() +{ + QTest::addColumn("forceNonNative"); + QTest::newRow( "forcing non-native menubar" ) << true; + QTest::newRow( "not forcing non-native menubar" ) << false; +} #endif void tst_QMenuBar::clear() From a300330203790b41a12a27dc4341b57ae81fd29e Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 7 Dec 2016 13:13:47 +0100 Subject: [PATCH 169/304] Make sure we call glClearDepth(double) on desktop GL Task-number: QTBUG-56798 Change-Id: I028510c0f75df5c7d2dce539c32ea503009467db Reviewed-by: Laszlo Agocs Reviewed-by: Bruno de Oliveira Abinader --- src/gui/opengl/qopenglfunctions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index e4e7c6d1b5..ad8b19a2bc 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -2196,9 +2196,10 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *c) #ifndef QT_OPENGL_ES_2 // setup fallbacks in case some methods couldn't get resolved - if (!f.ClearDepthf) + bool es = QOpenGLContext::currentContext()->isOpenGLES(); + if (!f.ClearDepthf || !es) f.ClearDepthf = qopenglfSpecialClearDepthf; - if (!f.DepthRangef) + if (!f.DepthRangef || !es) f.DepthRangef = qopenglfSpecialDepthRangef; if (!f.GetShaderPrecisionFormat) f.GetShaderPrecisionFormat = qopenglfSpecialGetShaderPrecisionFormat; From 814a2c8ddf48347612a61a7f7155796f766d67d3 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Thu, 17 Nov 2016 10:49:29 +0000 Subject: [PATCH 170/304] docs: Mention that QWidget::ensurePolished() also affects children Change-Id: I083d1c503039010024c89db59003fb6fca050c26 Reviewed-by: David Faure Reviewed-by: Martin Smith --- src/widgets/kernel/qwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index ace50f13ee..1c79e4ea92 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9993,8 +9993,8 @@ bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *resu } /*! - Ensures that the widget has been polished by QStyle (i.e., has a - proper font and palette). + Ensures that the widget and its children have been polished by + QStyle (i.e., have a proper font and palette). QWidget calls this function after it has been fully constructed but before it is shown the very first time. You can call this From 3edeb5c909a4ec62440e2075b9d49ec256a1ba68 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Wed, 18 Jan 2017 11:09:37 -0800 Subject: [PATCH 171/304] Cocoa: fix regression preventing windows from showing up The regression was introduced by 593ab638609 which fixed another bug related to window modality. To determine whether the window needs to be (made key and ordered front) or just (ordered front), instead of calling currentModalSession() which might change internal state of event dispatcher we just check if cocoaModalSessionStack is empty or not. Task-number: QTBUG-57991 Task-number: QTBUG-56166 Change-Id: I6c4f92860d8c93decd44e572af1690ed7be6f1f0 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 602da0a175..40666772c5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -695,7 +695,7 @@ void QCocoaWindow::setVisible(bool visible) if (cocoaEventDispatcher) cocoaEventDispatcherPrivate = static_cast(QObjectPrivate::get(cocoaEventDispatcher)); - if (!(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession())) + if (cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->cocoaModalSessionStack.isEmpty()) [m_nsWindow makeKeyAndOrderFront:nil]; else [m_nsWindow orderFront:nil]; From b934572b30ca64ea0f85dffaeb9ff3c30add1e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 13 Jan 2017 17:40:56 +0100 Subject: [PATCH 172/304] QDBusTrayIcon: always save the temp icon in Unity We enforce the check of saving the icon when the indicator process name isn't available (as we might be running in a confined world), but we're running in Unity. Change-Id: I80d3be1a8c6eba8c391364260746e78cf89a5b98 Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge --- .../themes/genericunix/dbustray/qdbustrayicon.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp index 5c4157c206..b55ace357a 100644 --- a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp +++ b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp @@ -171,6 +171,12 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon) uint pid = session.interface()->servicePid(KDEWatcherService).value(); QString processName = QLockFilePrivate::processNameByPid(pid); necessary = processName.endsWith(QLatin1String("indicator-application-service")); + if (!necessary && QGuiApplication::desktopSettingsAware()) { + // Accessing to process name might be not allowed if the application + // is confined, thus we can just rely on the current desktop in use + const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); + necessary = services->desktopEnvironment().split(':').contains("UNITY"); + } necessity_checked = true; } if (!necessary) From 7780ee9e5f20f80ab9e053058d0b6d92586cf876 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 16 Jan 2017 13:26:09 +0100 Subject: [PATCH 173/304] Windows QPA: Call InvalidateRect() in WM_PAINT/GL Software rendering Bring back the call to InvalidateRect() removed by change 6086c81e4d999d88ce4d412 since it seems that GL Software rendering requires it (also for single buffer mode). Task-number: QTBUG-58178 Change-Id: I197a1b3c3906c4afa43943db30dbc07dfb656cc7 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a9b061ad73..6894062d61 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -43,7 +43,7 @@ #include "qwindowsscreen.h" #include "qwindowsintegration.h" #include "qwindowsnativeinterface.h" -#include "qwindowsopenglcontext.h" +#include "qwindowsglcontext.h" #ifdef QT_NO_CURSOR # include "qwindowscursor.h" #endif @@ -1582,6 +1582,16 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, return false; PAINTSTRUCT ps; +#if QT_CONFIG(dynamicgl) + // QTBUG-58178: GL software rendering needs InvalidateRect() to suppress + // artifacts while resizing. + if (testFlag(OpenGLSurface) + && QOpenGLStaticContext::opengl32.moduleIsNotOpengl32() + && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + InvalidateRect(hwnd, 0, false); + } +#endif // dynamicgl + BeginPaint(hwnd, &ps); // Observed painting problems with Aero style disabled (QTBUG-7865). From f2e39c4a154b109b9308ab657a1ce64cff6ab176 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 9 Jan 2017 15:44:30 +0100 Subject: [PATCH 174/304] inline "committing" of configure command line built-ins the options may need to take effect before the regular test processing commences (which is actually going to be the case in the next commit). the indirection via the callback only obfuscated the code anyway. Change-Id: I5307b0be15cf4cc2c2db391ce5b5a93f81076b5c Reviewed-by: Joerg Bornemann --- mkspecs/features/data/configure.json | 7 ------- mkspecs/features/qt_configure.prf | 19 ++++++------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/mkspecs/features/data/configure.json b/mkspecs/features/data/configure.json index 8e5ff5f0a4..98ccde1ee3 100644 --- a/mkspecs/features/data/configure.json +++ b/mkspecs/features/data/configure.json @@ -14,12 +14,5 @@ "redo": { "type": "redo" } } - - }, - - "features": { - "builtins": { - "output": [ "builtins" ] - } } } diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index a0948dad86..5e444f62b2 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1601,19 +1601,6 @@ defineTest(qtConfOutput_privateFeature) { } } -# command line built-ins post-processing -defineTest(qtConfOutput_builtins) { - QMAKE_CONFIG_VERBOSE = $$eval(config.input.verbose) - isEmpty(QMAKE_CONFIG_VERBOSE): \ - QMAKE_CONFIG_VERBOSE = false - export(QMAKE_CONFIG_VERBOSE) - - QMAKE_CONFIG_CACHE_USE = $$eval(config.input.cache_use) - isEmpty(QMAKE_CONFIG_CACHE_USE): \ - QMAKE_CONFIG_CACHE_USE = all - export(QMAKE_CONFIG_CACHE_USE) -} - defineTest(qtConfProcessOneOutput) { feature = $${1} fpfx = $${currentConfig}.features.$${feature} @@ -1786,6 +1773,9 @@ qtConfCheckErrors() QMAKE_CONFIG_CACHE = $$dirname(_QMAKE_SUPER_CACHE_)/config.cache else: \ QMAKE_CONFIG_CACHE = $$dirname(_QMAKE_CACHE_)/config.cache +QMAKE_CONFIG_CACHE_USE = $$eval(config.input.cache_use) +isEmpty(QMAKE_CONFIG_CACHE_USE): \ + QMAKE_CONFIG_CACHE_USE = all !equals(QMAKE_CONFIG_CACHE_USE, none) { include($$QMAKE_CONFIG_CACHE, , true) # this crudely determines when to discard the cache. this also catches the case @@ -1800,6 +1790,9 @@ equals(QMAKE_CONFIG_CACHE_USE, none) { write_file($$QMAKE_CONFIG_CACHE, cont) } +QMAKE_CONFIG_VERBOSE = $$eval(config.input.verbose) +isEmpty(QMAKE_CONFIG_VERBOSE): \ + QMAKE_CONFIG_VERBOSE = false QMAKE_CONFIG_LOG = $$OUT_PWD/config.log !equals(QMAKE_CONFIG_CACHE_USE, all): \ write_file($$QMAKE_CONFIG_LOG, "") From 068fca3ceca5ef8669902c7cf7b70588e3d74256 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 9 Jan 2017 15:38:24 +0100 Subject: [PATCH 175/304] log configure command line to config.log that makes the log file mostly self-contained. for code re-use, the qtSystemQuote() function was factored out. Change-Id: Ie3469518ba384131b69f5f15c577240e2674d507 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_configure.prf | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 5e444f62b2..ee323501f9 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -183,7 +183,9 @@ defineTest(qtConfCommandline_redo) { qtConfAddError("No config.opt present - cannot redo configuration.") return() } - QMAKE_EXTRA_ARGS = $$cat($$OUT_PWD/config.opt, lines) $$QMAKE_EXTRA_ARGS + QMAKE_EXTRA_REDO_ARGS = $$cat($$OUT_PWD/config.opt, lines) + export(QMAKE_EXTRA_REDO_ARGS) # just for config.log + QMAKE_EXTRA_ARGS = $$QMAKE_EXTRA_REDO_ARGS $$QMAKE_EXTRA_ARGS export(QMAKE_EXTRA_ARGS) QMAKE_REDO_CONFIG = true export(QMAKE_REDO_CONFIG) @@ -387,14 +389,17 @@ defineTest(qtConfPkgConfigPackageExists) { return(true) } -defineReplace(qtConfPrepareArgs) { - arglist = $$split(1) +defineReplace(qtSystemQuote) { args = - for (a, arglist): \ + for (a, 1): \ args += $$system_quote($$a) return($$args) } +defineReplace(qtConfPrepareArgs) { + return($$qtSystemQuote($$split(1))) +} + defineTest(qtConfSetupLibraries) { for (l, $${currentConfig}.libraries._KEYS_) { lpfx = $${currentConfig}.libraries.$${l} @@ -1796,6 +1801,9 @@ isEmpty(QMAKE_CONFIG_VERBOSE): \ QMAKE_CONFIG_LOG = $$OUT_PWD/config.log !equals(QMAKE_CONFIG_CACHE_USE, all): \ write_file($$QMAKE_CONFIG_LOG, "") +qtLog("Command line: $$qtSystemQuote($$QMAKE_SAVED_ARGS)") +$$QMAKE_REDO_CONFIG: \ + qtLog("config.opt: $$qtSystemQuote($$QMAKE_EXTRA_REDO_ARGS)") CONFIG += qt_conf_tests_allowed logn() From 9c05ccb6bc89d9ca3fa76daebf15ac3a3c9fd95a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 9 Jan 2017 16:00:08 +0100 Subject: [PATCH 176/304] put some empty lines between configure runs into config.log Change-Id: I6c3e3b139752bb9d1b60c590bb1ea72ae2e4fbdf Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_configure.prf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index ee323501f9..4056b4d05a 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1801,6 +1801,8 @@ isEmpty(QMAKE_CONFIG_VERBOSE): \ QMAKE_CONFIG_LOG = $$OUT_PWD/config.log !equals(QMAKE_CONFIG_CACHE_USE, all): \ write_file($$QMAKE_CONFIG_LOG, "") +else: \ + write_file($$QMAKE_CONFIG_LOG, $$list($$escape_expand(\\n)), append) qtLog("Command line: $$qtSystemQuote($$QMAKE_SAVED_ARGS)") $$QMAKE_REDO_CONFIG: \ qtLog("config.opt: $$qtSystemQuote($$QMAKE_EXTRA_REDO_ARGS)") From 0796c62ad50740c71555c6db51c42f998b4258c1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 16 Jan 2017 21:13:29 +0100 Subject: [PATCH 177/304] add depend_includepath to the qmake manual Task-number: QTBUG-1834 Started-by: Kavindra Palaraja Change-Id: I3f906f3141f48072bd29e08d99193a2dcd847926 Reviewed-by: Joerg Bornemann --- qmake/doc/src/qmake-manual.qdoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 34e86b94c5..a8ccd199b4 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -960,6 +960,8 @@ \row \li c++14 \li C++14 support is enabled. This option has no effect if the compiler does not support C++14. By default, support is disabled. + \row \li depend_includepath \li Appending the value of INCLUDEPATH to + DEPENDPATH is enabled. Set by default. \endtable When you use the \c debug_and_release option (which is the default under From 4dcfd90e4fd7d4c49138038dbbcbda8794a9fbff Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 10 Jan 2017 14:18:02 +0100 Subject: [PATCH 178/304] fix parallel builds with -qt-freetype -system-libpng freetype has no dependency on gui, so it needs to pull in gui's configuration manually, as that's where the system libpng is found. Task-number: QTBUG-58038 Change-Id: I881495f7d2a8f7c1a45d7d4c9e7698ff1d30f2a9 Reviewed-by: Joerg Bornemann Reviewed-by: Joni Poikelin --- src/3rdparty/freetype/freetype.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/3rdparty/freetype/freetype.pro b/src/3rdparty/freetype/freetype.pro index 5b1eb92e32..390a6da749 100644 --- a/src/3rdparty/freetype/freetype.pro +++ b/src/3rdparty/freetype/freetype.pro @@ -69,6 +69,7 @@ DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB include(../zlib_dependency.pri) DEFINES += FT_CONFIG_OPTION_USE_PNG +include($$OUT_PWD/../../gui/qtgui-config.pri) QMAKE_USE_PRIVATE += libpng DEFINES += TT_CONFIG_OPTION_SUBPIXEL_HINTING From 6b070340a818089cb5cc2d01c155d1696c8e392b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 13 Jan 2017 18:29:25 +0100 Subject: [PATCH 179/304] fix detection of statically built system-libpng it has a dependency on zlib, which needs to be explicitly linked when linking statically. Task-number: QTBUG-56163 Change-Id: I4564844e8a35686db48c429b259e78558d312819 Reviewed-by: Tim Blechmann Reviewed-by: Oswald Buddenhagen --- src/gui/configure.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/configure.json b/src/gui/configure.json index 154ba63f00..6f87eb5aed 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -159,8 +159,8 @@ "test": "unix/libpng", "sources": [ { "type": "pkgConfig", "args": "libpng" }, - { "libs": "-llibpng", "condition": "config.msvc" }, - { "libs": "-lpng", "condition": "!config.msvc" } + { "libs": "-llibpng -lzdll", "condition": "config.msvc" }, + { "libs": "-lpng -lz", "condition": "!config.msvc" } ] }, "mirclient": { From a4e4f8918183608a0449c5d60622e6b355b8dbbd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 20:20:39 +0100 Subject: [PATCH 180/304] fix up static linking of plugins somewhat move the code before the linking of qt modules - dependency resolution would re-order them anyway (or static linking would fail). on the way, fix up the coding style and rename some variables. the code to de-duplicate/normalize QTPLUGIN is pulled ahead, which means that the automatic plugin importing wouldn't make a mess of it any more. but this is mostly legacy anyway. Change-Id: Id135470d027f5d84b7f30531425a65efa230f278 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 626cf9c809..3ccbbe7061 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -63,6 +63,8 @@ CLEAN_QT_PRIVATE = $$replace(QT_PRIVATE, -private$, _private) qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends") +QTPLUGIN = $$unique($$list($$lower($$QTPLUGIN))) + import_plugins:qtConfig(static) { manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy. autoplugs = # Auto-added plugins. @@ -132,6 +134,22 @@ import_plugins:qtConfig(static) { } } +# Only link against plugins in static builds +!isEmpty(QTPLUGIN):qtConfig(static) { + for (plug, QTPLUGIN) { + # Check if the plugin is known to Qt. We can use this to determine + # the plugin path. Unknown plugins must rely on the default link path. + plug_type = $$eval(QT_PLUGIN.$${plug}.TYPE) + !isEmpty(plug_type) { + plug_path = $$eval(QT_PLUGIN.$${plug}.PATH) + isEmpty(plug_path): \ + plug_path = $$[QT_INSTALL_PLUGINS/get] + LIBS += -L$$plug_path/$$plug_type + } + LIBS += -l$${plug}$$qtPlatformTargetSuffix() + } +} + # target variable, flag source variable defineTest(qtProcessModuleFlags) { for(flag, $$2) { @@ -322,24 +340,3 @@ contains(all_qt_module_deps, qml): \ QMAKE_DISTCLEAN += $$QML_IMPORT_CPP } } -qtConfig(static) { - for (QTPLUG, $$list($$lower($$unique(QTPLUGIN)))) { - # Check if the plugin is known to Qt. We can use this to determine - # the plugin path. Unknown plugins must rely on the default link path. - QT_PLUGINPATH = $$eval(QT_PLUGIN.$${QTPLUG}.TYPE) - - # Generate the plugin linker line - QT_LINKAGE = -l$${QTPLUG}$$qtPlatformTargetSuffix() - - # Only link against plugin in static builds - { - !isEmpty(QT_PLUGINPATH) { - plugpath = $$eval(QT_PLUGIN.$${QTPLUG}.PATH) - isEmpty(plugpath): \ - plugpath = $$[QT_INSTALL_PLUGINS/get] - LIBS *= -L$$plugpath/$$QT_PLUGINPATH - } - LIBS += $$QT_LINKAGE - } - } -} From fd3ea76d4ef0a9d287e618c2ab074eb7515fa778 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 17 Jan 2017 16:50:59 +0100 Subject: [PATCH 181/304] configure: better suppression magic for old qdevice.pri instead of forcing an early load and discarding its contents again before they could cause harm, trick qmake into not loading it at all. Change-Id: I672ca9de362b1f23bf5cfea007053570c8534fc6 Reviewed-by: Joerg Bornemann --- configure.pri | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/configure.pri b/configure.pri index b184ceff5b..cc173b6777 100644 --- a/configure.pri +++ b/configure.pri @@ -409,13 +409,12 @@ defineTest(reloadSpec) { } # nobody's going to try to re-load the features above, # so don't bother with being selective. - QMAKE_INTERNAL_INCLUDED_FEATURES = + QMAKE_INTERNAL_INCLUDED_FEATURES = \ + # loading it gets simulated below. + $$[QT_HOST_DATA/src]/mkspecs/features/device_config.prf _SAVED_CONFIG = $$CONFIG load(spec_pre) - load(device_config) # avoid that the spec loads it later. - # discard possible settings from an earlier configure run. - discard_from($$[QT_HOST_DATA/get]/mkspecs/qdevice.pri) # qdevice.pri gets written too late (and we can't write it early # enough, as it's populated in stages, with later ones depending # on earlier ones). so inject its variables manually. From d22579f51ef342a54937cb99dab62331afa0ff91 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 19 Jan 2017 15:08:27 -0800 Subject: [PATCH 182/304] QWidget::winId(): Remove documentation bit about macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Carbon port has been removed since 5.0, so there's only one framework against which we can build Qt. Change-Id: I38ce410f50cd4eda7abcc50ac4c4c7a23b3e1f45 Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 1c79e4ea92..cf90df6b9b 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2526,10 +2526,6 @@ QWidget *QWidget::find(WId id) If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle. - On \macos, the type returned depends on which framework Qt was linked - against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt - is using Cocoa, {WId} is a pointer to an NSView. - This value may change at run-time. An event with type QEvent::WinIdChange will be sent to the widget following a change in window system identifier. From 6834d0eeccc7333ab9d53251b3bd4a24058843da Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 17 Jan 2017 17:10:21 +0100 Subject: [PATCH 183/304] prevent configure from putting garbage into .qmake.stash in cross-builds, toolchain.prf was loaded before CROSS_COMPILE was set up, leading to caching of possibly nonsensical values. this change also necessitated that msvc-version.conf is loaded only when toolchain.prf is, which is best done by loading the former from within the latter. that seems quite appropriate in the first place. Change-Id: I62577e827a75e335e03df016bd1aa1932643fd6c Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- configure.pri | 12 +++++++++++- mkspecs/features/toolchain.prf | 2 ++ mkspecs/features/win32/default_pre.prf | 1 - 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/configure.pri b/configure.pri index cc173b6777..94aea44b13 100644 --- a/configure.pri +++ b/configure.pri @@ -411,7 +411,10 @@ defineTest(reloadSpec) { # so don't bother with being selective. QMAKE_INTERNAL_INCLUDED_FEATURES = \ # loading it gets simulated below. - $$[QT_HOST_DATA/src]/mkspecs/features/device_config.prf + $$[QT_HOST_DATA/src]/mkspecs/features/device_config.prf \ + # must be delayed until qdevice.pri is ready. + $$[QT_HOST_DATA/src]/mkspecs/features/mac/toolchain.prf \ + $$[QT_HOST_DATA/src]/mkspecs/features/toolchain.prf _SAVED_CONFIG = $$CONFIG load(spec_pre) @@ -825,6 +828,13 @@ defineTest(qtConfOutput_reloadSpec) { !isEmpty($${currentConfig}.output.devicePro)| \ !isEmpty(config.input.sysroot): \ reloadSpec() + + bypassNesting() { + QMAKE_INTERNAL_INCLUDED_FEATURES -= \ + $$[QT_HOST_DATA/src]/mkspecs/features/mac/toolchain.prf \ + $$[QT_HOST_DATA/src]/mkspecs/features/toolchain.prf + load(toolchain) + } } defineTest(qtConfOutput_shared) { diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index d71f40b831..fdefd513e3 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -153,3 +153,5 @@ unset(target_prefix) QMAKE_CFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT + +msvc:!intel_icl:!clang_cl: include(../common/msvc-version.conf) diff --git a/mkspecs/features/win32/default_pre.prf b/mkspecs/features/win32/default_pre.prf index 11160f5b5c..bdb72c0d89 100644 --- a/mkspecs/features/win32/default_pre.prf +++ b/mkspecs/features/win32/default_pre.prf @@ -1,3 +1,2 @@ CONFIG = rtti_off incremental_off windows $$CONFIG load(default_pre) -msvc:!intel_icl:!clang_cl: include(../../common/msvc-version.conf) From f67afee9e932dd220474227882a745233455d729 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 12 Jan 2017 20:52:51 +0100 Subject: [PATCH 184/304] determine QMAKE_DEFAULT_{INC,LIB}DIRS separately for host and target note that in principle this leaves room for a race condition, as the first project to determine the host config is not going to be the top-level one. in qtbase and qtdeclarative, this is naturally serialized via the common bootstrapped libraries (bootstrap resp. qmldevtools). activeqt, qt3d, qtscxml, and qtwayland all build only one bootstrapped tool each. qtwebengine makes a fake host build to create files for gyp/gn; the convert_dict tool is declared a host tool, but isn't actually built when x-building anyway, and even if, it's serialized on the former. qttools needs explicit serialization, though. no other host builds exist within qt as of now. Task-number: QTBUG-58126 Change-Id: I81a02a2d98f2bfe5d6aaa51119d5e7919549f119 Reviewed-by: Joerg Bornemann --- mkspecs/features/toolchain.prf | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index fdefd513e3..9e11ab9958 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -12,7 +12,12 @@ defineReplace(qtMakeExpand) { } } -isEmpty(QMAKE_DEFAULT_INCDIRS):!host_build { +host_build: \ + target_prefix = QMAKE_HOST_CXX +else: \ + target_prefix = QMAKE_CXX + +isEmpty($${target_prefix}.INCDIRS) { # # Get default include and library paths from compiler # @@ -44,6 +49,8 @@ isEmpty(QMAKE_DEFAULT_INCDIRS):!host_build { } QMAKE_DEFAULT_LIBDIRS = $$unique(QMAKE_DEFAULT_LIBDIRS) } else: msvc { + # This doesn't differentiate between host and target, + # but neither do the compilers. LIB = $$getenv("LIB") QMAKE_DEFAULT_LIBDIRS = $$split(LIB, $$QMAKE_DIRLIST_SEP) INCLUDE = $$getenv("INCLUDE") @@ -55,8 +62,11 @@ isEmpty(QMAKE_DEFAULT_INCDIRS):!host_build { isEmpty(QMAKE_DEFAULT_LIBDIRS): QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib } - !isEmpty(QMAKE_DEFAULT_INCDIRS): cache(QMAKE_DEFAULT_INCDIRS, set stash) - !isEmpty(QMAKE_DEFAULT_LIBDIRS): cache(QMAKE_DEFAULT_LIBDIRS, set stash) + cache($${target_prefix}.INCDIRS, set stash, QMAKE_DEFAULT_INCDIRS) + cache($${target_prefix}.LIBDIRS, set stash, QMAKE_DEFAULT_LIBDIRS) +} else { + QMAKE_DEFAULT_INCDIRS = $$eval($${target_prefix}.INCDIRS) + QMAKE_DEFAULT_LIBDIRS = $$eval($${target_prefix}.LIBDIRS) } # @@ -73,11 +83,6 @@ defineReplace(qtVariablesFromGCC) { return($$system("$$1 -E $$system_quote($$PWD/data/macros.cpp) <$$null_device 2>$$null_device", lines)) } -host_build: \ - target_prefix = QMAKE_HOST_CXX -else: \ - target_prefix = QMAKE_CXX - isEmpty($${target_prefix}.COMPILER_MACROS) { msvc { clang_cl { From 6b8666c7f24acd13246c51eeee1316dd95ab1860 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 12 Jan 2017 20:58:45 +0100 Subject: [PATCH 185/304] don't separate host and target toolchain when not x-building there isn't a point to determining the values separately if they are actually the same things. Change-Id: I74cd2bf39e96d559630709559602c234c38b0c47 Reviewed-by: Joerg Bornemann --- mkspecs/features/toolchain.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 9e11ab9958..15b0829235 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -12,7 +12,7 @@ defineReplace(qtMakeExpand) { } } -host_build: \ +cross_compile:host_build: \ target_prefix = QMAKE_HOST_CXX else: \ target_prefix = QMAKE_CXX From d9203fa534f31509e87bb6c6c702c1b7149372e3 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 22 Nov 2016 13:14:53 +0100 Subject: [PATCH 186/304] winrt: Add support for Visual Studio 2017 Tested with RC Task-number: QTBUG-57086 Change-Id: I57ecfd0751538dcba41ebaf028de1bc5b4debbb7 Reviewed-by: Maurice Kalinowski --- mkspecs/features/winrt/default_pre.prf | 2 +- mkspecs/features/winrt/package_manifest.prf | 6 +- mkspecs/winrt-x64-msvc2017/qmake.conf | 20 +++++ mkspecs/winrt-x64-msvc2017/qplatformdefs.h | 40 +++++++++ mkspecs/winrt-x86-msvc2017/qmake.conf | 19 +++++ mkspecs/winrt-x86-msvc2017/qplatformdefs.h | 40 +++++++++ qmake/generators/win32/msvc_nmake.cpp | 94 +++++++++++++++++---- 7 files changed, 201 insertions(+), 20 deletions(-) create mode 100644 mkspecs/winrt-x64-msvc2017/qmake.conf create mode 100644 mkspecs/winrt-x64-msvc2017/qplatformdefs.h create mode 100644 mkspecs/winrt-x86-msvc2017/qmake.conf create mode 100644 mkspecs/winrt-x86-msvc2017/qplatformdefs.h diff --git a/mkspecs/features/winrt/default_pre.prf b/mkspecs/features/winrt/default_pre.prf index f397ef3d61..f79d04ce41 100644 --- a/mkspecs/features/winrt/default_pre.prf +++ b/mkspecs/features/winrt/default_pre.prf @@ -1,4 +1,4 @@ -*msvc2015 { +*msvc2015|*msvc2017 { # Note that the order is important - ucrt(d) has to be first. # Otherwise, the linker might use malloc from a different library, # but free_dbg() from the runtime, causing an assertion failure diff --git a/mkspecs/features/winrt/package_manifest.prf b/mkspecs/features/winrt/package_manifest.prf index e7859a7cae..e0e421ed9a 100644 --- a/mkspecs/features/winrt/package_manifest.prf +++ b/mkspecs/features/winrt/package_manifest.prf @@ -94,7 +94,7 @@ isEmpty(WINRT_MANIFEST.background): WINRT_MANIFEST.background = green isEmpty(WINRT_MANIFEST.foreground): WINRT_MANIFEST.foreground = light isEmpty(WINRT_MANIFEST.default_language): WINRT_MANIFEST.default_language = en - *-msvc2015 { + *-msvc2015|*-msvc2017 { isEmpty(WINRT_MANIFEST.minVersion): WINRT_MANIFEST.minVersion = $$(UCRTVersion) isEmpty(WINRT_MANIFEST.minVersion): error("No UCRTVersion found in environment.")) isEmpty(WINRT_MANIFEST.maxVersionTested): WINRT_MANIFEST.maxVersionTested = $$WINRT_MANIFEST.minVersion @@ -118,7 +118,7 @@ # All Windows 10 applications need to have internetClient. It is also not marked as additional # capability anymore and is assumed to be standard. - *-msvc2015: WINRT_MANIFEST.capabilities += internetClient + *-msvc2015|*-msvc2017: WINRT_MANIFEST.capabilities += internetClient contains(WINRT_MANIFEST.capabilities, defaults) { WINRT_MANIFEST.capabilities -= defaults @@ -145,7 +145,7 @@ } # Dependencies are given as a string list. The CRT dependency is added automatically above. - # For MSVC2015 the dependencies are added in conjunction with TargetDeviceFamily + # For MSVC2015/2017 the dependencies are added in conjunction with TargetDeviceFamily # Due to the hard coded dependency on "Windows.Universal" the tag # is already inside the MSVC2015 manifest. WINRT_MANIFEST.dependencies = $$unique(WINRT_MANIFEST.dependencies) diff --git a/mkspecs/winrt-x64-msvc2017/qmake.conf b/mkspecs/winrt-x64-msvc2017/qmake.conf new file mode 100644 index 0000000000..cb2209fa23 --- /dev/null +++ b/mkspecs/winrt-x64-msvc2017/qmake.conf @@ -0,0 +1,20 @@ +# +# qmake configuration for winrt-x64-msvc2017 +# +# Written for Microsoft Visual C++ 2017 +# + +include(../common/winrt_winphone/qmake.conf) +DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X64 __X64__ __x64__ + +QMAKE_CFLAGS += -FS +QMAKE_CXXFLAGS += -FS +QMAKE_LFLAGS += /MACHINE:X64 /NODEFAULTLIB:kernel32.lib + +QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib + +VCPROJ_ARCH = x64 +WINSDK_VER = 10.0 +WINTARGET_VER = winv10.0 +WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in +WINRT_MANIFEST.architecture = x64 diff --git a/mkspecs/winrt-x64-msvc2017/qplatformdefs.h b/mkspecs/winrt-x64-msvc2017/qplatformdefs.h new file mode 100644 index 0000000000..2a1aef5e88 --- /dev/null +++ b/mkspecs/winrt-x64-msvc2017/qplatformdefs.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the qmake spec 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$ +** +****************************************************************************/ + +#include "../common/winrt_winphone/qplatformdefs.h" diff --git a/mkspecs/winrt-x86-msvc2017/qmake.conf b/mkspecs/winrt-x86-msvc2017/qmake.conf new file mode 100644 index 0000000000..3c9506bbad --- /dev/null +++ b/mkspecs/winrt-x86-msvc2017/qmake.conf @@ -0,0 +1,19 @@ +# +# qmake configuration for winrt-x86-msvc2017 +# +# Written for Microsoft Visual C++ 2017 +# + +include(../common/winrt_winphone/qmake.conf) +DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X86 __X86__ __x86__ + +QMAKE_CFLAGS += -FS +QMAKE_CXXFLAGS += -FS +QMAKE_LFLAGS += /SAFESEH /MACHINE:X86 /NODEFAULTLIB:kernel32.lib + +QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib +VCPROJ_ARCH = Win32 +WINSDK_VER = 10.0 +WINTARGET_VER = winv10.0 +WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in +WINRT_MANIFEST.architecture = x86 diff --git a/mkspecs/winrt-x86-msvc2017/qplatformdefs.h b/mkspecs/winrt-x86-msvc2017/qplatformdefs.h new file mode 100644 index 0000000000..2a1aef5e88 --- /dev/null +++ b/mkspecs/winrt-x86-msvc2017/qplatformdefs.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the qmake spec 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$ +** +****************************************************************************/ + +#include "../common/winrt_winphone/qplatformdefs.h" diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 5b5eecd373..92043e829f 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -75,25 +75,44 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) QString arch = project->first("VCPROJ_ARCH").toQString().toLower(); QString compiler; QString compilerArch; - if (arch == QLatin1String("arm")) { - compiler = QStringLiteral("x86_arm"); - compilerArch = QStringLiteral("arm"); - } else if (arch == QLatin1String("x64")) { - const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); - if (hostArch.contains("x86_64")) - compiler = QStringLiteral("amd64"); - else - compiler = QStringLiteral("x86_amd64"); - compilerArch = QStringLiteral("amd64"); - } else { - arch = QStringLiteral("x86"); - } - const QString msvcVer = project->first("MSVC_VER").toQString(); if (msvcVer.isEmpty()) { fprintf(stderr, "Mkspec does not specify MSVC_VER. Cannot continue.\n"); return false; } + + if (msvcVer == QStringLiteral("15.0")) { + const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); + if (hostArch.contains("x86_64")) + compiler = QStringLiteral("HostX64/"); + else + compiler = QStringLiteral("HostX86/"); + if (arch == QLatin1String("arm")) { + compiler += QStringLiteral("arm"); + compilerArch = QStringLiteral("arm"); + } else if (arch == QLatin1String("x64")) { + compiler += QStringLiteral("x64"); + compilerArch = QStringLiteral("amd64"); + } else { + compiler += QStringLiteral("x86"); + compilerArch = QStringLiteral("amd64"); + } + } else { + if (arch == QLatin1String("arm")) { + compiler = QStringLiteral("x86_arm"); + compilerArch = QStringLiteral("arm"); + } else if (arch == QLatin1String("x64")) { + const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); + if (hostArch.contains("x86_64")) + compiler = QStringLiteral("amd64"); + else + compiler = QStringLiteral("x86_amd64"); + compilerArch = QStringLiteral("amd64"); + } else { + arch = QStringLiteral("x86"); + } + } + const QString winsdkVer = project->first("WINSDK_VER").toQString(); if (winsdkVer.isEmpty()) { fprintf(stderr, "Mkspec does not specify WINSDK_VER. Cannot continue.\n"); @@ -107,7 +126,11 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) const bool isPhone = project->isActiveConfig(QStringLiteral("winphone")); #ifdef Q_OS_WIN - QString regKey = QStringLiteral("Software\\Microsoft\\VisualStudio\\") + msvcVer + ("\\Setup\\VC\\ProductDir"); + QString regKey; + if (msvcVer == QStringLiteral("15.0")) + regKey = QStringLiteral("Software\\Microsoft\\VisualStudio\\SxS\\VS7\\") + msvcVer; + else + regKey = QStringLiteral("Software\\Microsoft\\VisualStudio\\") + msvcVer + ("\\Setup\\VC\\ProductDir"); const QString vcInstallDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey, KEY_WOW64_32KEY); if (vcInstallDir.isEmpty()) { fprintf(stderr, "Failed to find the Visual Studio installation directory.\n"); @@ -134,7 +157,46 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) QStringList incDirs; QStringList libDirs; QStringList binDirs; - if (msvcVer == QStringLiteral("14.0")) { + if (msvcVer == QStringLiteral("15.0")) { + const QString toolsInstallDir = qgetenv("VCToolsInstallDir"); + if (toolsInstallDir.isEmpty()) { + fprintf(stderr, "Failed to access tools installation dir.\n"); + return false; + } + + binDirs << toolsInstallDir + QStringLiteral("bin/") + compiler; + if (arch == QStringLiteral("x64")) + binDirs << toolsInstallDir + QStringLiteral("bin/HostX86/X86"); + binDirs << kitDir + QStringLiteral("bin/x86"); + binDirs << vcInstallDir + QStringLiteral("Common7/Tools"); + binDirs << vcInstallDir + QStringLiteral("Common7/ide"); + binDirs << vcInstallDir + QStringLiteral("MSBuild/15.0/bin"); + + incDirs << toolsInstallDir + QStringLiteral("include"); + incDirs << vcInstallDir + QStringLiteral("VC/Auxiliary/VS/include"); + + const QString crtVersion = qgetenv("UCRTVersion"); + if (crtVersion.isEmpty()) { + fprintf(stderr, "Failed to access CRT version.\n"); + return false; + } + const QString crtInclude = kitDir + QStringLiteral("Include/") + crtVersion; + const QString crtLib = kitDir + QStringLiteral("Lib/") + crtVersion; + incDirs << crtInclude + QStringLiteral("/ucrt"); + incDirs << crtInclude + QStringLiteral("/um"); + incDirs << crtInclude + QStringLiteral("/shared"); + incDirs << crtInclude + QStringLiteral("/winrt"); + + incDirs << kitDir + QStringLiteral("Extension SDKs/WindowsMobile/") + + crtVersion + QStringLiteral("/Include/WinRT"); + + libDirs << toolsInstallDir + QStringLiteral("lib/") + arch + QStringLiteral("/store"); + + libDirs << vcInstallDir + QStringLiteral("VC/Auxiliary/VS/lib/") + arch; + + libDirs << crtLib + QStringLiteral("/ucrt/") + arch; + libDirs << crtLib + QStringLiteral("/um/") + arch; + } else if (msvcVer == QStringLiteral("14.0")) { binDirs << vcInstallDir + QStringLiteral("bin/") + compiler; binDirs << vcInstallDir + QStringLiteral("bin/"); // Maybe remove for x86 again? binDirs << kitDir + QStringLiteral("bin/") + (arch == QStringLiteral("arm") ? QStringLiteral("x86") : arch); From fa6444939ccd19c9685bc6bed98b4fa302e7f6f8 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 17 Jan 2017 23:55:07 +0200 Subject: [PATCH 187/304] Support QMAKE_PRE_LINK and QMAKE_POST_LINK for static libs on unix prelink was not supported at all for ar. postlink was done for most cases, but missing in one particular ar invocation. Task-number: QTBUG-57276 Change-Id: Ic72c42a9502c97d7111b3f3941b387024d46a27d Reviewed-by: Oswald Buddenhagen --- qmake/generators/unix/unixmake2.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 946906ba65..b4d43a3dc2 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -658,11 +658,15 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "$(TARGETA): " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) $(OBJCOMP)"; if(do_incremental) t << " $(INCREMENTAL_OBJECTS)"; - t << ' ' << depVar("POST_TARGETDEPS") << "\n\t" - << "-$(DEL_FILE) $(TARGETA) \n\t" + t << ' ' << depVar("POST_TARGETDEPS") << "\n\t"; + if (!project->isEmpty("QMAKE_PRE_LINK")) + t << var("QMAKE_PRE_LINK") << "\n\t"; + t << "-$(DEL_FILE) $(TARGETA) \n\t" << var("QMAKE_AR_CMD"); if(do_incremental) t << " $(INCREMENTAL_OBJECTS)"; + if (!project->isEmpty("QMAKE_POST_LINK")) + t << "\n\t" << var("QMAKE_POST_LINK"); if(!project->isEmpty("QMAKE_RANLIB")) t << "\n\t$(RANLIB) $(TARGETA)"; t << endl << endl; @@ -679,6 +683,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << " $(OBJECTS) $(OBJCOMP) " << depVar("POST_TARGETDEPS") << "\n\t"; if(!destdir.isEmpty()) t << mkdir_p_asstring(destdir, false) << "\n\t"; + if (!project->isEmpty("QMAKE_PRE_LINK")) + t << var("QMAKE_PRE_LINK") << "\n\t"; t << "-$(DEL_FILE) " << destdir << "$(TARGET)\n\t" << var("QMAKE_AR_CMD") << "\n"; if(!project->isEmpty("QMAKE_POST_LINK")) @@ -709,6 +715,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } if(!destdir.isEmpty()) t << mkdir_p_asstring(destdir, false) << "\n\t"; + if (!project->isEmpty("QMAKE_PRE_LINK")) + t << var("QMAKE_PRE_LINK") << "\n\t"; t << "-$(DEL_FILE) " << lib << "\n\t" << ar << "\n"; if(!project->isEmpty("QMAKE_POST_LINK")) From 8f960badfcf3afdf2d489dfb7ccc96a656ae0f9d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 20 Jan 2017 09:45:13 +0100 Subject: [PATCH 188/304] Don't ignore major version "0" when resolving targets on windows This was missed in dd9ec1564, leading to errors for example when building with separate_debug_info. Change-Id: Ibeb8020abe32690bcc691c1ca139508775c91db2 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/resolve_target.prf | 1 - 1 file changed, 1 deletion(-) diff --git a/mkspecs/features/resolve_target.prf b/mkspecs/features/resolve_target.prf index 629a02a4f3..d5ba70ca8c 100644 --- a/mkspecs/features/resolve_target.prf +++ b/mkspecs/features/resolve_target.prf @@ -19,7 +19,6 @@ win32 { contains(TEMPLATE, .*lib) { !skip_target_version_ext:isEmpty(TARGET_VERSION_EXT):!isEmpty(VERSION) { TARGET_VERSION_EXT = $$section(VERSION, ., 0, 0) - isEqual(TARGET_VERSION_EXT, 0):unset(TARGET_VERSION_EXT) } static:TARGET_EXT = .lib else:TARGET_EXT = .dll From 5060740fa980fdd5d2828b3b7e8956386266a7eb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 19 Jan 2017 21:54:41 +0100 Subject: [PATCH 189/304] utilize configure results better in native builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit don't ignore detected features for host tools when we're not actually cross-building. Change-Id: Id62a3c1c6b7ae422b14efb4fbea0892b05a047cc Reviewed-by: Thiago Macieira Reviewed-by: René J.V. Bertin --- mkspecs/features/default_post.prf | 2 +- mkspecs/features/qt_common.prf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index e7e9a5bd87..7f5ab3a10c 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -60,7 +60,7 @@ debug { } # disable special linker flags for host builds (no proper test for host support yet) -!host_build { +!host_build|!cross_compile { use_gold_linker: QMAKE_LFLAGS += $$QMAKE_LFLAGS_USE_GOLD enable_new_dtags: QMAKE_LFLAGS += $$QMAKE_LFLAGS_NEW_DTAGS } diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index 7967697eb4..2dfc22f16e 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -17,7 +17,7 @@ qtConfig(c++14): CONFIG += c++14 qtConfig(c++1z): CONFIG += c++1z contains(TEMPLATE, .*lib) { # module and plugins - !host_build:qtConfig(reduce_exports): CONFIG += hide_symbols + if(!host_build|!cross_compile):qtConfig(reduce_exports): CONFIG += hide_symbols unix:qtConfig(reduce_relocations): CONFIG += bsymbolic_functions qtConfig(separate_debug_info): CONFIG += separate_debug_info From a41677d04c3835eb12a30cf546c0b0804592325d Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Mon, 16 Jan 2017 15:39:32 -0800 Subject: [PATCH 190/304] QQuickWidget: fix drag and drop QQuickWidget did not receive mouse release events after drag and drop because the logic was so: 1) QWidgetWindow::handleMouseEvent() was called on press and qt_button_down was set to the corresponding QQuickWidget; 2) After drag started, qt_button_down was set to 0 in QApplicationPrivate::notifyDragStarted(); 3) On mouse release QWidgetWindow::handleMouseEvent() was called again, but because qt_button_down was 0 QApplicationPrivate::pickMouseReceiver() returned 0 and as a result QWidgetWindow ignored the event and did not propagate it to QQuickWidget for further processing. The step 2 is a widgets-specific fix for QTBUG-26145 that does not work for QQuickWidget (QtQuick has its own focus system). Note that because Widgets and QtQuick do not share the sources, there is no possibility to cast the pointer to check whether qt_button_down is a QQuickWidget or some other QWidget-derived class object, so we have to use QObject::inherits() method to check that. Task-number: QTBUG-56713 Change-Id: I599b843e903c64329e6178752e0dc49f674bb890 Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qapplication.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 128b5dc2b8..5908d3036b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4501,9 +4501,13 @@ void QApplicationPrivate::notifyThemeChanged() #ifndef QT_NO_DRAGANDDROP void QApplicationPrivate::notifyDragStarted(const QDrag *drag) { - // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation. QGuiApplicationPrivate::notifyDragStarted(drag); - qt_button_down = 0; + // QTBUG-26145 + // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation... + // QTBUG-56713 + // ...only if qt_button_down is not a QQuickWidget + if (qt_button_down && !qt_button_down->inherits("QQuickWidget")) + qt_button_down = nullptr; } #endif // QT_NO_DRAGANDDROP From 4d49f94060e20c5e47a587cc630a40718d91e62c Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Thu, 19 Jan 2017 14:25:12 -0800 Subject: [PATCH 191/304] Cocoa: fix bug when left mouse button release event delivered as right The regression was introduced during refactoring by 820e69d6c and the initial change that added this logic is adc3ef97d. This condition had become redundant and wrong after refactoring because m_sendUpAsRightButton flag is set in the proper way in QNSView::mouseDown() which later calls QNSView::handleMouseEvent() anyway. Task-number: QTBUG-58219 Change-Id: I1951cf4067af6f0c1837c1c15b8a09dfe7939493 Reviewed-by: Timur Pocheptsov Reviewed-by: Pavol Markovic --- src/plugins/platforms/cocoa/qnsview.mm | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ba91d3e40e..970ce9e785 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -853,9 +853,6 @@ static bool _q_dontOverrideCtrlLMB = false; if (masked) return false; - if (button == Qt::RightButton) - m_sendUpAsRightButton = true; - m_buttons |= button; [self handleMouseEvent:theEvent]; From 578154c47dfeaf9eb7f7ed428b876314fc239350 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 20 Jan 2017 09:02:05 +0100 Subject: [PATCH 192/304] tst_QPauseAnimation: Use QTRY_COMPARE for checking the stopped state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QTRY_COMPARE with a timeout to check for the stopped state unless BAD_TIMER_RESOLUTION is defined. This speeds up the test by 1s and prints diagnostic information should an interval be too short (as seems to be the case on macOS, currently). Change-Id: I8f884cd66ad33314124d3130d9f49606e6dfe9f3 Reviewed-by: Jędrzej Nowacki --- .../qpauseanimation/tst_qpauseanimation.cpp | 64 ++++++++----------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index 25b6216075..290c2abc98 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -40,6 +40,16 @@ #ifdef BAD_TIMER_RESOLUTION static const char timerError[] = "On this platform, consistent timing is not working properly due to bad timer resolution"; + +# define WAIT_FOR_STOPPED(animation, duration) \ + QTest::qWait(duration); \ + if (animation.state() != QAbstractAnimation::Stopped) \ + QEXPECT_FAIL("", timerError, Abort); \ + QCOMPARE(animation.state(), QAbstractAnimation::Stopped) +#else +// Use QTRY_COMPARE with one additional timer tick +# define WAIT_FOR_STOPPED(animation, duration) \ + QTRY_COMPARE_WITH_TIMEOUT(animation.state(), QAbstractAnimation::Stopped, (duration)) #endif class TestablePauseAnimation : public QPauseAnimation @@ -108,11 +118,10 @@ void tst_QPauseAnimation::changeDirectionWhileRunning() TestablePauseAnimation animation; animation.setDuration(400); animation.start(); - QTest::qWait(100); - QCOMPARE(animation.state(), QAbstractAnimation::Running); + QTRY_COMPARE(animation.state(), QAbstractAnimation::Running); animation.setDirection(QAbstractAnimation::Backward); - QTest::qWait(animation.totalDuration() + 50); - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); + const int expectedDuration = animation.totalDuration() + 100; + WAIT_FOR_STOPPED(animation, expectedDuration); } void tst_QPauseAnimation::noTimerUpdates_data() @@ -137,14 +146,9 @@ void tst_QPauseAnimation::noTimerUpdates() animation.setDuration(duration); animation.setLoopCount(loopCount); animation.start(); - QTest::qWait(animation.totalDuration() + 100); + const int expectedDuration = animation.totalDuration() + 150; + WAIT_FOR_STOPPED(animation, expectedDuration); -#ifdef BAD_TIMER_RESOLUTION - if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); const int expectedLoopCount = 1 + loopCount; #ifdef BAD_TIMER_RESOLUTION @@ -166,13 +170,9 @@ void tst_QPauseAnimation::multiplePauseAnimations() animation.start(); animation2.start(); - QTest::qWait(animation.totalDuration() + 100); -#ifdef BAD_TIMER_RESOLUTION - if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); + const int expectedDuration = animation.totalDuration() + 150; + WAIT_FOR_STOPPED(animation, expectedDuration); #ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Running) @@ -192,13 +192,7 @@ void tst_QPauseAnimation::multiplePauseAnimations() #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 2); - QTest::qWait(550); - -#ifdef BAD_TIMER_RESOLUTION - if (animation2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - QCOMPARE(animation2.state(), QAbstractAnimation::Stopped); + WAIT_FOR_STOPPED(animation2, 600); #ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 3) @@ -229,13 +223,9 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations() QCOMPARE(pause.state(), QAbstractAnimation::Running); QCOMPARE(pause.m_updateCurrentTimeCount, 2); - QTest::qWait(animation.totalDuration() + 100); + const int expectedDuration = animation.totalDuration() + 150; + WAIT_FOR_STOPPED(animation, expectedDuration); -#ifdef BAD_TIMER_RESOLUTION - if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); QCOMPARE(pause.state(), QAbstractAnimation::Stopped); QVERIFY(pause.m_updateCurrentTimeCount > 3); } @@ -405,13 +395,8 @@ void tst_QPauseAnimation::multipleSequentialGroups() // This is a pretty long animation so it tends to get rather out of sync // when using the consistent timer, so run for an extra half second for good // measure... - QTest::qWait(group.totalDuration() + 500); - -#ifdef BAD_TIMER_RESOLUTION - if (group.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", timerError, Abort); -#endif - QCOMPARE(group.state(), QAbstractAnimation::Stopped); + const int expectedDuration = group.totalDuration() + 550; + WAIT_FOR_STOPPED(group, expectedDuration); #ifdef BAD_TIMER_RESOLUTION if (subgroup1.state() != QAbstractAnimation::Stopped) @@ -449,8 +434,9 @@ void tst_QPauseAnimation::zeroDuration() TestablePauseAnimation animation; animation.setDuration(0); animation.start(); - QTest::qWait(animation.totalDuration() + 100); - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); + const int expectedDuration = animation.totalDuration() + 150; + WAIT_FOR_STOPPED(animation, expectedDuration); + QCOMPARE(animation.m_updateCurrentTimeCount, 1); } From ebffedb11dbce9391982dd3646b5466103aa5705 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 18 Jan 2017 13:07:56 +0100 Subject: [PATCH 193/304] Avoid trashing other contexts' VAOs in destroy() The following is safe: QOpenGLVertexArrayObject *vao = ... vao->create(); switch the current context delete vao; because the QOpenGLVAO dtor recognizes that the wrong context is current, and will temporarily restore the VAO's associated one in order to safely destroy the vao object. However, the following has been problematic: vao.create(); switch the current context vao.destroy(); simply because all the logic was in the dtor and destroy() blindly deleted the vao object in whatever context was current. This can lead to releasing a completely unrelated vao object that happens to have the same name in another context. The expectation is for context-dependent wrappers is that a ctor-create-dtor-ctor-create-dtor-... sequence is equivalent to create-destroy-create-destroy-..., so move the safe cleanup logic from the dtor to destroy(). Change-Id: Ie3bddbf4bfeb8629948c4783cc88422c9df03e65 Reviewed-by: Allan Sandfeld Jensen --- src/gui/opengl/qopenglvertexarrayobject.cpp | 94 ++++++++++----------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index babe52aa83..0262538250 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -197,33 +197,59 @@ void QOpenGLVertexArrayObjectPrivate::destroy() { Q_Q(QOpenGLVertexArrayObject); + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QOpenGLContext *oldContext = 0; + QSurface *oldContextSurface = 0; + QScopedPointer offscreenSurface; + if (context && context != ctx) { + oldContext = ctx; + oldContextSurface = ctx ? ctx->surface() : 0; + // Cannot just make the current surface current again with another context. + // The format may be incompatible and some platforms (iOS) may impose + // restrictions on using a window with different contexts. Create an + // offscreen surface (a pbuffer or a hidden window) instead to be safe. + offscreenSurface.reset(new QOffscreenSurface); + offscreenSurface->setFormat(context->format()); + offscreenSurface->create(); + if (context->makeCurrent(offscreenSurface.data())) { + ctx = context; + } else { + qWarning("QOpenGLVertexArrayObject::destroy() failed to make VAO's context current"); + ctx = 0; + } + } + if (context) { QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); context = 0; } - if (!vao) - return; - - switch (vaoFuncsType) { + if (vao) { + switch (vaoFuncsType) { #ifndef QT_OPENGL_ES_2 - case Core_3_2: - vaoFuncs.core_3_2->glDeleteVertexArrays(1, &vao); - break; - case Core_3_0: - vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao); - break; + case Core_3_2: + vaoFuncs.core_3_2->glDeleteVertexArrays(1, &vao); + break; + case Core_3_0: + vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao); + break; #endif - case ARB: - case APPLE: - case OES: - vaoFuncs.helper->glDeleteVertexArrays(1, &vao); - break; - default: - break; + case ARB: + case APPLE: + case OES: + vaoFuncs.helper->glDeleteVertexArrays(1, &vao); + break; + default: + break; + } + + vao = 0; } - vao = 0; + if (oldContext && oldContextSurface) { + if (!oldContext->makeCurrent(oldContextSurface)) + qWarning("QOpenGLVertexArrayObject::destroy() failed to restore current context"); + } } /*! @@ -354,37 +380,7 @@ QOpenGLVertexArrayObject::QOpenGLVertexArrayObject(QOpenGLVertexArrayObjectPriva */ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() { - QOpenGLContext* ctx = QOpenGLContext::currentContext(); - - Q_D(QOpenGLVertexArrayObject); - QOpenGLContext *oldContext = 0; - QSurface *oldContextSurface = 0; - QScopedPointer offscreenSurface; - if (d->context && ctx && d->context != ctx) { - oldContext = ctx; - oldContextSurface = ctx->surface(); - // Cannot just make the current surface current again with another context. - // The format may be incompatible and some platforms (iOS) may impose - // restrictions on using a window with different contexts. Create an - // offscreen surface (a pbuffer or a hidden window) instead to be safe. - offscreenSurface.reset(new QOffscreenSurface); - offscreenSurface->setFormat(d->context->format()); - offscreenSurface->create(); - if (d->context->makeCurrent(offscreenSurface.data())) { - ctx = d->context; - } else { - qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to make VAO's context current"); - ctx = 0; - } - } - - if (ctx) - destroy(); - - if (oldContext) { - if (!oldContext->makeCurrent(oldContextSurface)) - qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context"); - } + destroy(); } /*! From a828a02d9f86b5b1d472768a5a52f963c6ff8175 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 20 Jan 2017 09:47:13 +0100 Subject: [PATCH 194/304] Fix sanity checks in DRIVE CX and Jetson K1 Pro specs This amends e58eb3d6. Task-number: QTBUG-58287 Change-Id: Ia4b5d0cf5f71d1e0977e3c8674ef08929112f7e9 Reviewed-by: Oswald Buddenhagen --- mkspecs/devices/linux-drive-cx-g++/qmake.conf | 10 ++++++++-- mkspecs/devices/linux-jetson-tk1-pro-g++/qmake.conf | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mkspecs/devices/linux-drive-cx-g++/qmake.conf b/mkspecs/devices/linux-drive-cx-g++/qmake.conf index 985f8626ad..a658f29deb 100644 --- a/mkspecs/devices/linux-drive-cx-g++/qmake.conf +++ b/mkspecs/devices/linux-drive-cx-g++/qmake.conf @@ -16,8 +16,6 @@ include(../common/linux_device_pre.conf) -isEmpty(VIBRANTE_SDK_TOPDIR):error("You must pass -device-option VIBRANTE_SDK_TOPDIR=/path/to/sdk") - QMAKE_INCDIR += \ $${VIBRANTE_SDK_TOPDIR}/include \ $$[QT_SYSROOT]/usr/include @@ -43,4 +41,12 @@ COMPILER_FLAGS += -mtune=cortex-a57.cortex-a53 -march=armv8-a EGLFS_DEVICE_INTEGRATION = eglfs_kms_egldevice include(../common/linux_arm_device_post.conf) + +# override the default from linux_arm_device_post.conf +defineTest(qtConfSanitizeMkspec) { + isEmpty(VIBRANTE_SDK_TOPDIR): \ + error("You must pass -device-option VIBRANTE_SDK_TOPDIR=/path/to/sdk") + deviceSanityCheckCompiler() +} + load(qt_config) diff --git a/mkspecs/devices/linux-jetson-tk1-pro-g++/qmake.conf b/mkspecs/devices/linux-jetson-tk1-pro-g++/qmake.conf index 31aacad99f..1f44c47151 100644 --- a/mkspecs/devices/linux-jetson-tk1-pro-g++/qmake.conf +++ b/mkspecs/devices/linux-jetson-tk1-pro-g++/qmake.conf @@ -14,8 +14,6 @@ include(../common/linux_device_pre.conf) -isEmpty(VIBRANTE_SDK_TOPDIR):error("You must pass -device-option VIBRANTE_SDK_TOPDIR=/path/to/sdk") - QMAKE_INCDIR += \ $${VIBRANTE_SDK_TOPDIR}/include \ $$[QT_SYSROOT]/usr/include @@ -38,4 +36,12 @@ COMPILER_FLAGS += -mtune=cortex-a15 -march=armv7-a -mfpu=neon-vfpv EGLFS_DEVICE_INTEGRATION = eglfs_kms_egldevice include(../common/linux_arm_device_post.conf) + +# override the default from linux_arm_device_post.conf +defineTest(qtConfSanitizeMkspec) { + isEmpty(VIBRANTE_SDK_TOPDIR): \ + error("You must pass -device-option VIBRANTE_SDK_TOPDIR=/path/to/sdk") + deviceSanityCheckCompiler() +} + load(qt_config) From 2597d27732e5e256d967d8a1db396c339b5afd3f Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 14 Nov 2016 10:11:05 +0100 Subject: [PATCH 195/304] Doc: Remove specific mention of 'Qt 4' from Model/View documentation Change-Id: If2101124d1bc772c9412c3d09d2d7753d9b51569 Reviewed-by: Leena Miettinen --- src/widgets/doc/src/modelview.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/doc/src/modelview.qdoc b/src/widgets/doc/src/modelview.qdoc index 4a53ea5cbd..1c0bb5195a 100644 --- a/src/widgets/doc/src/modelview.qdoc +++ b/src/widgets/doc/src/modelview.qdoc @@ -83,7 +83,7 @@ Model/View is a technology used to separate data from views in widgets that handle data sets. Standard widgets are not designed for separating data - from views and this is why Qt 4 has two different types of widgets. Both + from views and this is why Qt has two different types of widgets. Both types of widgets look the same, but they interact with data differently. \table From 92eafefb5abaa7f5ef41c3e85f22d8dd69486297 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 21 Jan 2017 15:10:12 +0900 Subject: [PATCH 196/304] Fix build without features.textcodec Change-Id: Ia9636db509270db93c2f9e46adaf1def0f157344 Reviewed-by: Lars Knoll --- src/corelib/configure.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/configure.json b/src/corelib/configure.json index c170b38977..66bf0dac92 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -305,6 +305,7 @@ "label": "Mimetype handling", "purpose": "Provides MIME type handling.", "section": "Utilities", + "condition": "features.textcodec", "output": [ "publicFeature", "feature" ] }, "system-pcre": { From 00593d8e3713fb83001637d3794d26fe83bd6144 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Sun, 22 Jan 2017 16:09:00 +0100 Subject: [PATCH 197/304] features/resources.prf: fix use of unescaped backslash Without this, building a project with qmake -Wall will always produce the following warning: mkspecs/features/resources.prf:22: Unescaped backslashes are deprecated Change-Id: I0aeedbf470958ab458651a263e3f804ea2d1a0f0 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/resources.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index adc8e9a8ac..de769b4b86 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -19,7 +19,7 @@ defineReplace(xml_escape) { RESOURCES += qmake_immediate for(resource, RESOURCES) { # Regular case of user qrc file - contains(resource, ".*\.qrc$"): \ + contains(resource, ".*\\.qrc$"): \ next() # Fallback for stand-alone files/directories From ecf025f613e5f59a8653ffd2d3d4aa6f47b668df Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 19 Apr 2016 10:16:42 +0200 Subject: [PATCH 198/304] Fix dereference before null check in QOpenGLExtensionMatcher QOpenGLContext pointer was dereferenced before checking if it valid. Coverity-Id: 11370 Change-Id: I87d83a87d88ad7c055f3ed32096bfda036224ca9 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopengl.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index eb08492254..384cd0bd13 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -64,6 +64,10 @@ typedef const GLubyte * (QOPENGLF_APIENTRYP qt_glGetStringi)(GLenum, GLuint); QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() { QOpenGLContext *ctx = QOpenGLContext::currentContext(); + if (!ctx) { + qWarning("QOpenGLExtensionMatcher::QOpenGLExtensionMatcher: No context"); + return; + } QOpenGLFunctions *funcs = ctx->functions(); const char *extensionStr = 0; @@ -79,19 +83,17 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() // clear error state while (funcs->glGetError()) {} - if (ctx) { - qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress("glGetStringi"); + qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress("glGetStringi"); - if (!glGetStringi) - return; + if (!glGetStringi) + return; - GLint numExtensions = 0; - funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + GLint numExtensions = 0; + funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); - for (int i = 0; i < numExtensions; ++i) { - const char *str = reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)); - m_extensions.insert(str); - } + for (int i = 0; i < numExtensions; ++i) { + const char *str = reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)); + m_extensions.insert(str); } #endif // QT_OPENGL_3 } From 4d7313a466dd775e58705924f72525d4838c70fe Mon Sep 17 00:00:00 2001 From: Aleksei Timofeyev Date: Fri, 22 Apr 2016 17:00:27 +0500 Subject: [PATCH 199/304] QLocalSocket/Win: Fix access to deleted pipeWriter waitForWrite can emit a signal outside QLocalSocket and pipeWriter could be deleted there. Change-Id: Ic35ec6455bd05402fd38fb3e1b219aa4534a0ff6 Reviewed-by: Joerg Bornemann --- src/network/socket/qlocalsocket_win.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index bed4355aa9..312c934632 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -309,10 +309,8 @@ bool QLocalSocket::flush() { Q_D(QLocalSocket); bool written = false; - if (d->pipeWriter) { - while (d->pipeWriter->waitForWrite(0)) - written = true; - } + while (d->pipeWriter && d->pipeWriter->waitForWrite(0)) + written = true; return written; } From 4b1d825ddcd1c116b158039e4772ee41c9785104 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 20 Dec 2016 09:10:55 +0100 Subject: [PATCH 200/304] QGuiApplication: Send QEvent::Window(Un)blocked to embedded window, too Change 333f641622c795a4b826d2d48aeabd5b5eab6e90 modified QGuiApplication::topLevelWindows() to no longer include embedded windows. This causes the blocked handling in Active Qt to no longer be triggered. Fix this by iterating over the list using the same condition as before, avoiding the construction of a temporary list as a side effect. Task-number: QTBUG-18099 Change-Id: I06a1a4e324fea9f543ceb5274bb064734f8d56af Reviewed-by: Miikka Heikkinen Reviewed-by: Andy Shaw --- src/gui/kernel/qguiapplication.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 98cdecc444..71f27db6b7 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -759,6 +759,14 @@ void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) updateBlockedStatusRecursion(window, shouldBeBlocked); } +// Return whether the window needs to be notified about window blocked events. +// As opposed to QGuiApplication::topLevelWindows(), embedded windows are +// included in this list (QTBUG-18099). +static inline bool needsWindowBlockedEvent(const QWindow *w) +{ + return w->isTopLevel() && w->type() != Qt::Desktop; +} + void QGuiApplicationPrivate::showModalWindow(QWindow *modal) { self->modalWindowList.prepend(modal); @@ -776,10 +784,8 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) } } - QWindowList windows = QGuiApplication::topLevelWindows(); - for (int i = 0; i < windows.count(); ++i) { - QWindow *window = windows.at(i); - if (!window->d_func()->blockedByModalWindow) + for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) { + if (needsWindowBlockedEvent(window) && !window->d_func()->blockedByModalWindow) updateBlockedStatus(window); } @@ -790,10 +796,8 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window) { self->modalWindowList.removeAll(window); - QWindowList windows = QGuiApplication::topLevelWindows(); - for (int i = 0; i < windows.count(); ++i) { - QWindow *window = windows.at(i); - if (window->d_func()->blockedByModalWindow) + for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) { + if (needsWindowBlockedEvent(window) && window->d_func()->blockedByModalWindow) updateBlockedStatus(window); } } From 186a5af82bd302a85aec3652fadc4ef376468713 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 23 Jan 2017 11:58:37 +0300 Subject: [PATCH 201/304] Doc: do not break the values list by blank lines in qnamespace.qdoc There should be no blank lines in \value content, otherwise qdoc ends the list and starts a new one. Change-Id: Idddc7992317894487445aea36397136df40b9691 Reviewed-by: Martin Smith --- src/corelib/global/qnamespace.qdoc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 11044cef88..48aaf34dcd 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -123,16 +123,14 @@ \value AA_PluginApplication Indicates that Qt is used to author a plugin. Depending on the operating system, it suppresses specific initializations that do not necessarily make sense in the plugin case. - For example on OS X, this includes avoiding loading our nib for the main menu and not taking possession of the native menu bar. Setting this attribute to true will also set the AA_DontUseNativeMenuBar attribute to true. It also disables native event filters. - This attribute has been added in Qt 5.7. It must be set before \l {QGuiApplication}{Q(Gui)Application} is constructed. - \value AA_MacPluginApplication This attribute has been deprecated. + \value AA_MacPluginApplication This attribute has been deprecated. Use AA_PluginApplication instead. \value AA_DontUseNativeMenuBar All menubars created while this attribute is @@ -166,7 +164,6 @@ \value AA_UseHighDpiPixmaps Make QIcon::pixmap() generate high-dpi pixmaps that can be larger than the requested size. Such pixmaps will have \l {QPixmap::devicePixelRatio}{devicePixelRatio()} set to a value higher than 1. - After setting this attribute, application code that uses pixmap sizes in layout geometry calculations should typically divide by \l {QPixmap::devicePixelRatio}{devicePixelRatio()} to get device-independent layout geometry. From 45948967bd2442d27c7526ec6f74b0df3edbe40a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 23 Jan 2017 11:04:12 +0100 Subject: [PATCH 202/304] tst_QSocks5SocketEngine: Refactor tests Rewrite tcpSocketNonBlockingTest() and downloadBigFile() to use lambdas for the slots. This allows for removing the related member variables and slots of the test class and ensures no leaks of sockets or inconsistent values. Add an error handler printing the error message to the flaky downloadBigFile() test. Change-Id: Ieb64063c41e045a1a50a6d074bef01753ee319ef Reviewed-by: Timur Pocheptsov --- .../tst_qsocks5socketengine.cpp | 136 +++++++----------- 1 file changed, 50 insertions(+), 86 deletions(-) diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index c945d77cda..18da122000 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -54,7 +54,6 @@ class tst_QSocks5SocketEngine : public QObject, public QAbstractSocketEngineRece private slots: void initTestCase(); - void init(); void construction(); void errorTest_data(); void errorTest(); @@ -74,13 +73,6 @@ private slots: void incomplete(); protected slots: - void tcpSocketNonBlocking_hostFound(); - void tcpSocketNonBlocking_connected(); - void tcpSocketNonBlocking_closed(); - void tcpSocketNonBlocking_readyRead(); - void tcpSocketNonBlocking_bytesWritten(qint64); - void exitLoopSlot(); - void downloadBigFileSlot(); void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); private: @@ -89,11 +81,6 @@ private: void closeNotification() { } void exceptionNotification() { } void connectionNotification() { } - QTcpSocket *tcpSocketNonBlocking_socket; - QStringList tcpSocketNonBlocking_data; - qint64 tcpSocketNonBlocking_totalWritten; - QTcpSocket *tmpSocket; - qint64 bytesAvailable; }; class MiniSocks5ResponseHandler : public QObject @@ -153,12 +140,6 @@ void tst_QSocks5SocketEngine::initTestCase() QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); } -void tst_QSocks5SocketEngine::init() -{ - tmpSocket = 0; - bytesAvailable = 0; -} - //--------------------------------------------------------------------------- void tst_QSocks5SocketEngine::construction() { @@ -631,13 +612,27 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() { QSocks5SocketEngineHandler socks5; + qint64 tcpSocketNonBlocking_totalWritten = 0; + QStringList tcpSocketNonBlocking_data; QTcpSocket socket; - connect(&socket, SIGNAL(hostFound()), SLOT(tcpSocketNonBlocking_hostFound())); - connect(&socket, SIGNAL(connected()), SLOT(tcpSocketNonBlocking_connected())); - connect(&socket, SIGNAL(disconnected()), SLOT(tcpSocketNonBlocking_closed())); - connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(tcpSocketNonBlocking_bytesWritten(qint64))); - connect(&socket, SIGNAL(readyRead()), SLOT(tcpSocketNonBlocking_readyRead())); - tcpSocketNonBlocking_socket = &socket; + connect(&socket, &QAbstractSocket::hostFound, + &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); + connect(&socket, &QAbstractSocket::connected, + &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); + connect(&socket, &QIODevice::bytesWritten, + [&tcpSocketNonBlocking_totalWritten] (qint64 written) + { + tcpSocketNonBlocking_totalWritten += written; + QTestEventLoop::instance().exitLoop(); + }); + + connect(&socket, &QIODevice::readyRead, + [&tcpSocketNonBlocking_data, &socket] () + { + while (socket.canReadLine()) + tcpSocketNonBlocking_data.append(socket.readLine()); + QTestEventLoop::instance().exitLoop(); + }); // Connect socket.connectToHost(QtNetworkSettings::serverName(), 143); @@ -725,62 +720,50 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() QCOMPARE(socket.state(), QTcpSocket::UnconnectedState); } -void tst_QSocks5SocketEngine::tcpSocketNonBlocking_hostFound() -{ - QTestEventLoop::instance().exitLoop(); -} - -void tst_QSocks5SocketEngine::tcpSocketNonBlocking_connected() -{ - QTestEventLoop::instance().exitLoop(); -} - -void tst_QSocks5SocketEngine::tcpSocketNonBlocking_readyRead() -{ - while (tcpSocketNonBlocking_socket->canReadLine()) - tcpSocketNonBlocking_data.append(tcpSocketNonBlocking_socket->readLine()); - - QTestEventLoop::instance().exitLoop(); -} - -void tst_QSocks5SocketEngine::tcpSocketNonBlocking_bytesWritten(qint64 written) -{ - tcpSocketNonBlocking_totalWritten += written; - QTestEventLoop::instance().exitLoop(); -} - -void tst_QSocks5SocketEngine::tcpSocketNonBlocking_closed() -{ -} - //---------------------------------------------------------------------------------- void tst_QSocks5SocketEngine::downloadBigFile() { QSocks5SocketEngineHandler socks5; - if (tmpSocket) - delete tmpSocket; - tmpSocket = new QTcpSocket; + QTcpSocket socket; + qint64 bytesAvailable = 0; + connect(&socket, &QAbstractSocket::connected, + &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); + connect(&socket, &QIODevice::readyRead, + [&socket, &bytesAvailable] () + { + const QByteArray tmp = socket.readAll(); + int correction = tmp.indexOf(char(0), 0); //skip header + if (correction == -1) + correction = 0; + bytesAvailable += (tmp.size() - correction); + if (bytesAvailable >= 10000000) + QTestEventLoop::instance().exitLoop(); + }); - connect(tmpSocket, SIGNAL(connected()), SLOT(exitLoopSlot())); - connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot())); + connect(&socket, QOverload::of(&QAbstractSocket::error), + [&socket] (QAbstractSocket::SocketError errorCode) + { + qWarning().noquote().nospace() << QTest::currentTestFunction() + << ": error " << errorCode << ": " << socket.errorString(); + }); - tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80); + socket.connectToHost(QtNetworkSettings::serverName(), 80); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); - QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); - QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); - QVERIFY(tmpSocket->write("HOST: ") > 0); - QVERIFY(tmpSocket->write(hostName.data()) > 0); - QVERIFY(tmpSocket->write("\r\n") > 0); - QVERIFY(tmpSocket->write("\r\n") > 0); + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); + QVERIFY(socket.write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); + QVERIFY(socket.write("HOST: ") > 0); + QVERIFY(socket.write(hostName.data()) > 0); + QVERIFY(socket.write("\r\n") > 0); + QVERIFY(socket.write("\r\n") > 0); + - bytesAvailable = 0; QTime stopWatch; stopWatch.start(); @@ -791,31 +774,12 @@ void tst_QSocks5SocketEngine::downloadBigFile() QCOMPARE(bytesAvailable, qint64(10000000)); - QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); /*qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s", bytesAvailable / (1024.0 * 1024.0), stopWatch.elapsed() / 1024.0, (bytesAvailable / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024));*/ - - delete tmpSocket; - tmpSocket = 0; -} - -void tst_QSocks5SocketEngine::exitLoopSlot() -{ - QTestEventLoop::instance().exitLoop(); -} - - -void tst_QSocks5SocketEngine::downloadBigFileSlot() -{ - QByteArray tmp=tmpSocket->readAll(); - int correction=tmp.indexOf((char)0,0); //skip header - if (correction==-1) correction=0; - bytesAvailable += (tmp.size()-correction); - if (bytesAvailable >= 10000000) - QTestEventLoop::instance().exitLoop(); } void tst_QSocks5SocketEngine::passwordAuth() From 79352528a1726b4551ea4d9285dd2394dd0d43da Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 16 Nov 2016 10:53:44 +0100 Subject: [PATCH 203/304] Windows QPA: Prevent usage of child windows as transient parent When using foreign window integrations such as MFC/winmigrate, it is possible that a child window is found which can cause issues with modality. Loop up to top level. Task-number: QTSOLBUG-71 Task-number: QTBUG-57159 Change-Id: Ib36e0f8f4f6b1e22ba1240013871facef2c0c1ab Reviewed-by: Andy Shaw --- src/plugins/platforms/windows/qwindowswindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 6894062d61..b5522c1f90 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1273,6 +1273,12 @@ void QWindowsWindow::updateTransientParent() const if (const QWindowsWindow *tw = QWindowsWindow::windowsWindowOf(tp)) if (!tw->testFlag(WithinDestroy)) // Prevent destruction by parent window (QTBUG-35499, QTBUG-36666) newTransientParent = tw->handle(); + + // QTSOLBUG-71: When using the MFC/winmigrate solution, it is possible that a child + // window is found, which can cause issues with modality. Loop up to top level. + while (newTransientParent && (GetWindowLongPtr(newTransientParent, GWL_STYLE) & WS_CHILD) != 0) + newTransientParent = GetParent(newTransientParent); + if (newTransientParent != oldTransientParent) SetWindowLongPtr(m_data.hwnd, GWL_HWNDPARENT, LONG_PTR(newTransientParent)); } From df7a65afdaef4a402bbc2c7af27688678856887d Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 4 Jan 2017 10:27:02 +0100 Subject: [PATCH 204/304] Fix license header of QInputControl The license headers here were accidentally copied from Qt 5.6, since the files were targeted for that branch originally. This updates them to the proper LGPLv3 + GPLv2 + commercial. Change-Id: I0623bdbf8fd4475405500b2687ef8dce2f1dbb6b Reviewed-by: Simon Hausmann --- src/gui/text/qinputcontrol.cpp | 30 ++++++++++++++++++------------ src/gui/text/qinputcontrol_p.h | 30 ++++++++++++++++++------------ 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/gui/text/qinputcontrol.cpp b/src/gui/text/qinputcontrol.cpp index c2c198866a..af21ee86ee 100644 --- a/src/gui/text/qinputcontrol.cpp +++ b/src/gui/text/qinputcontrol.cpp @@ -5,27 +5,33 @@ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 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. +** 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. ** -** 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. +** 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$ ** diff --git a/src/gui/text/qinputcontrol_p.h b/src/gui/text/qinputcontrol_p.h index 3b46067ba9..e5709b5e54 100644 --- a/src/gui/text/qinputcontrol_p.h +++ b/src/gui/text/qinputcontrol_p.h @@ -5,27 +5,33 @@ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 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. +** 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. ** -** 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. +** 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$ ** From 40827457a7883bf2465b5365c9e95f38a59404d5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 20 Jan 2017 10:22:32 -0800 Subject: [PATCH 205/304] QMacCocoaViewContainer: Fix typos, wording in documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also removes reference to Carbon and the old dual backend. Change-Id: I01292caa7efcbe85526cd7602ec8ac678fd78eab Reviewed-by: Tor Arne Vestbø Reviewed-by: Timur Pocheptsov --- .../widgets/qmaccocoaviewcontainer_mac.mm | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index b4f2b8959e..8e565ecfe0 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -56,27 +56,21 @@ \inmodule QtWidgets While Qt offers a lot of classes for writing your application, Apple's - Cocoa framework offers lots of functionality that is not currently in Qt or - may never end up in Qt. Using QMacCocoaViewContainer, it is possible to put an - arbitrary NSView-derived class from Cocoa and put it in a Qt hierarchy. - Depending on how comfortable you are with using objective-C, you can use - QMacCocoaViewContainer directly, or subclass it to wrap further functionality - of the underlying NSView. + Cocoa frameworks offer functionality that is not currently available (or + may never end up) in Qt. Using QMacCocoaViewContainer, it is possible to take an + arbitrary NSView-derived class from Cocoa and put it in a Qt widgets hierarchy. + Depending on the level of integration you need, you can use QMacCocoaViewContainer + directly or subclass it to wrap more functionality of the underlying NSView. - QMacCocoaViewContainer works regardless if Qt is built against Carbon or - Cocoa. However, QCocoaContainerView requires \macos 10.5 or better to be - used with Carbon. + It should be also noted that, at the Cocoa level, there is a difference + between top-level windows and views (widgets that are inside a window). + For this reason, make sure that the NSView that you are wrapping doesn't + end up as a top-level window. The best way to ensure this is to make sure + QMacCocoaViewContainer's parent widget is not null. - It should be also noted that at the low level on \macos, there is a - difference between windows (top-levels) and view (widgets that are inside a - window). For this reason, make sure that the NSView that you are wrapping - doesn't end up as a top-level. The best way to ensure this is to make sure - you always have a parent and not set the parent to 0. - - If you are using QMacCocoaViewContainer as a sub-class and are mixing and - matching objective-C with C++ (a.k.a. objective-C++). It is probably - simpler to have your file end with \tt{.mm} than \tt{.cpp}. Most Apple tools will - correctly identify the source as objective-C++. + If you are using QMacCocoaViewContainer as a subclass and are accessing Cocoa API, + it is probably simpler to have your file end with \tt{.mm} instead of \tt{.cpp}. + Most Apple tools will correctly identify the source as Objective-C++. QMacCocoaViewContainer requires knowledge of how Cocoa works, especially in regard to its reference counting (retain/release) nature. It is noted in @@ -85,7 +79,8 @@ pool. If this is done outside of a running event loop, it is up to the developer to provide the autorelease pool. - The following is a snippet of subclassing QMacCocoaViewContainer to wrap a NSSearchField. + The following is a snippet showing how to subclass QMacCocoaViewContainer + to wrap an NSSearchField. \snippet macmainwindow.mm 0 */ From aa8fb3608952ab9f344e2b6beb7e083908c8d905 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 20 Jan 2017 11:39:35 -0800 Subject: [PATCH 206/304] QMacNativeWidget: Remove Carbon reference from documentation Change-Id: Ie1f1064a98f202194cad98aa3fa106e87eba7f39 Reviewed-by: Timur Pocheptsov --- src/widgets/widgets/qmacnativewidget_mac.mm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm index 936bd35187..9ad8aa1305 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.mm +++ b/src/widgets/widgets/qmacnativewidget_mac.mm @@ -65,15 +65,11 @@ but it cannot be shown on its own. It needs to be put into a window when it is created or later through a native call. - QMacNativeWidget works for either Carbon or Cocoa depending on how Qt was configured. If Qt is - using Carbon, QMacNativeWidget will embed into Carbon hierarchies. If Qt is - using Cocoa, QMacNativeWidget embeds into Cocoa hierarchies. - - Here is an example of putting a QPushButton into a NSWindow: + Here is an example showing how to put a QPushButton into a NSWindow: \snippet qmacnativewidget/main.mm 0 - Note that QMacNativeWidget requires knowledge of Carbon or Cocoa. All it + Note that QMacNativeWidget requires knowledge of Cocoa. All it does is get the Qt hierarchy into a window not owned by Qt. It is then up to the programmer to ensure it is placed correctly in the window and responds correctly to events. From dd52fd0024600d3beffc82d6da02b4239a62d725 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 17 Jan 2017 17:05:00 +0100 Subject: [PATCH 207/304] Ensure a pixel density of at least 1 for Qt::AA_EnableHighDpiScaling Very large 1080p TVs or any display which is running at an abnormally low resolution can have a DPI lower than 48, which means that qRound(dpi/96) will result in a 0 pixel density, causing critical issues for applications using Qt::AA_EnableHighDpiScaling. Make sure that we always have a pixel density of at least 1 to allow applications not having to worry about such displays. Task-number: QTBUG-56140 Change-Id: I1dafbf7794a99ae6f872984c0337d8ff0d1fc1c0 Reviewed-by: Shawn Rutledge Reviewed-by: Friedemann Kleint --- src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp | 2 +- src/plugins/platforms/windows/qwindowsscreen.cpp | 2 +- src/plugins/platforms/winrt/qwinrtscreen.cpp | 2 +- src/plugins/platforms/xcb/qxcbscreen.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp index 3e1e93f1e4..863a115b74 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp @@ -226,7 +226,7 @@ QDpi QEglFSDeviceIntegration::logicalDpi() const qreal QEglFSDeviceIntegration::pixelDensity() const { - return qRound(logicalDpi().first / qreal(100)); + return qMax(1, qRound(logicalDpi().first / qreal(100))); } Qt::ScreenOrientation QEglFSDeviceIntegration::nativeOrientation() const diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 7a885b462e..c70323c06f 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -265,7 +265,7 @@ qreal QWindowsScreen::pixelDensity() const // the pixel density since it is reflects the Windows UI scaling. // High DPI auto scaling should be disabled when the user chooses // small fonts on a High DPI monitor, resulting in lower logical DPI. - return qRound(logicalDpi().first / 96); + return qMax(1, qRound(logicalDpi().first / 96)); } /*! diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index f87ae9fd24..2a4b6c8907 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -647,7 +647,7 @@ QDpi QWinRTScreen::logicalDpi() const qreal QWinRTScreen::pixelDensity() const { Q_D(const QWinRTScreen); - return qRound(d->logicalDpi / 96); + return qMax(1, qRound(d->logicalDpi / 96)); } qreal QWinRTScreen::scaleFactor() const diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index a9675935f4..d8facdbb84 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -631,7 +631,7 @@ void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation) m_sizeMillimeters = sizeInMillimeters(xGeometry.size(), virtualDpi()); qreal dpi = xGeometry.width() / physicalSize().width() * qreal(25.4); - m_pixelDensity = qRound(dpi/96); + m_pixelDensity = qMax(1, qRound(dpi/96)); m_geometry = QRect(xGeometry.topLeft(), xGeometry.size()); m_availableGeometry = xGeometry & m_virtualDesktop->workArea(); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); From acacca859c3416e525599c4162292dd2a5e78fb7 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 22 Jan 2017 00:18:58 +0100 Subject: [PATCH 208/304] Doc: update QStringList doc with missing QRegularExpression reference The documentation of QStringList is missing some mention of QRegularExpression as well as still using QRegExp in some sample code. This patch fixes that. Change-Id: I4a7c9fe8e5ae7c73497192bb71d1fa66ee864bd2 Reviewed-by: Sze Howe Koh --- src/corelib/doc/snippets/qstringlist/main.cpp | 2 +- src/corelib/tools/qstringlist.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp index 7e7d55ca30..4d9c015747 100644 --- a/src/corelib/doc/snippets/qstringlist/main.cpp +++ b/src/corelib/doc/snippets/qstringlist/main.cpp @@ -97,7 +97,7 @@ Widget::Widget(QWidget *parent) //! [6] //! [7] - QStringList monospacedFonts = fonts.filter(QRegExp("Courier|Fixed")); + QStringList monospacedFonts = fonts.filter(QRegularExpression("Courier|Fixed")); //! [7] //! [8] diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index a0b65ea554..88ceae20b9 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -143,8 +143,8 @@ QT_BEGIN_NAMESPACE \snippet qstringlist/main.cpp 6 - The argument to split can be a single character, a string, or a - QRegExp. + The argument to split can be a single character, a string, a + QRegularExpression or a (deprecated) QRegExp. In addition, the \l {QStringList::operator+()}{operator+()} function allows you to concatenate two string lists into one. To From 00bbb4d27301a566f004880d68d3be8659620506 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 00:51:19 +0100 Subject: [PATCH 209/304] Example: migrate network-chat to use QRegularExpression Update the network-chat example to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: Idcd3dc5b3e9b520b2eeef9565d50195cc8dffd06 Reviewed-by: Sze Howe Koh --- examples/network/network-chat/peermanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/network/network-chat/peermanager.cpp b/examples/network/network-chat/peermanager.cpp index b056d5ed1f..4e2ea3e6f3 100644 --- a/examples/network/network-chat/peermanager.cpp +++ b/examples/network/network-chat/peermanager.cpp @@ -68,7 +68,7 @@ PeerManager::PeerManager(Client *client) QStringList environment = QProcess::systemEnvironment(); foreach (QString string, envVariables) { - int index = environment.indexOf(QRegExp(string)); + int index = environment.indexOf(QRegularExpression(string)); if (index != -1) { QStringList stringList = environment.at(index).split('='); if (stringList.size() == 2) { From cbd7dea83ed5d1f8876759e44d589b0e4c90c5f3 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 22 Jan 2017 00:08:16 +0100 Subject: [PATCH 210/304] Doc: updated QString::fromRawData documentation to QRegularExpression QString::fromRawData code sample still shows the use of QRegExp. This patch updates it for QRegularExpression and cleans the code. Change-Id: Iff0f736cdbdd7d35c65fde1496ce9f838a8f5c6d Reviewed-by: Thiago Macieira --- src/corelib/doc/snippets/qstring/main.cpp | 4 ++-- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index 5871026f95..41ee5a9cef 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -380,14 +380,14 @@ void Widget::fillFunction() void Widget::fromRawDataFunction() { //! [22] - QRegExp pattern; + QRegularExpression pattern("\u00A4"); static const QChar unicode[] = { 0x005A, 0x007F, 0x00A4, 0x0060, 0x1009, 0x0020, 0x0020}; int size = sizeof(unicode) / sizeof(QChar); QString str = QString::fromRawData(unicode, size); - if (str.contains(QRegExp(pattern))) { + if (str.contains(pattern) { // ... //! [22] //! [23] } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 8888eced87..9a3c05ac85 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -8144,7 +8144,7 @@ bool QString::isRightToLeft() const to create a deep copy of the data, ensuring that the raw data isn't modified. - Here's an example of how we can use a QRegExp on raw data in + Here's an example of how we can use a QRegularExpression on raw data in memory without requiring to copy the data into a QString: \snippet qstring/main.cpp 22 From 59780d132aa114f8b7edfb17a24b91d09e38236d Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Mon, 23 Jan 2017 15:25:38 -0800 Subject: [PATCH 211/304] Cocoa: fix crash regression in qt_mac_create_nsimage() The regression was introduced in d8857f21ac264. The original change was meant to fix support for SVG icons, but failed to take into account a valid QIcon with no sizes, but which is also unable to create a pixmap for the requested size. Task-number: QTBUG-58344 Change-Id: I7ac1dbfaf6e3dab8581fe4b33c814e2517fcdba8 Reviewed-by: Andy Shaw --- src/gui/painting/qcoregraphics.mm | 2 ++ tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index 803328c10f..3753fa4e88 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -157,6 +157,8 @@ NSImage *qt_mac_create_nsimage(const QIcon &icon, int defaultSize) availableSizes << QSize(defaultSize, defaultSize); foreach (QSize size, availableSizes) { QPixmap pm = icon.pixmap(size); + if (pm.isNull()) + continue; QImage image = pm.toImage(); CGImageRef cgImage = qt_mac_toCGImage(image); NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index f19d7619cc..e3af0135e7 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -136,6 +136,7 @@ private slots: void QTBUG_57404_existingMenuItemException(); #endif void taskQTBUG55966_subMenuRemoved(); + void QTBUG_58344_invalidIcon(); void platformMenu(); @@ -1594,5 +1595,14 @@ void tst_QMenuBar::taskQTBUG55966_subMenuRemoved() QTest::qWait(500); } +void tst_QMenuBar::QTBUG_58344_invalidIcon() +{ + QMenuBar menuBar; + QMenu menu("menu"); + menu.addAction(QIcon("crash.png"), "crash"); + menuBar.addMenu(&menu); + // No crash, all fine. +} + QTEST_MAIN(tst_QMenuBar) #include "tst_qmenubar.moc" From 74819c4ed95af98d3caf5144f44123dee0149e45 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 23:27:17 +0100 Subject: [PATCH 212/304] Tutorial: migrate addressbook tutorial to use QRegularExpression Update the addressbook tutorial to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: Ibea9252ab8fe1d12e6fc862fa70229ca6efe0804 Reviewed-by: Sze Howe Koh --- examples/widgets/tutorials/addressbook/part7/addressbook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp index 8fabcf8758..e946c873e3 100644 --- a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp +++ b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp @@ -402,7 +402,7 @@ void AddressBook::exportAsVCard() int index = name.indexOf(" "); if (index != -1) { - nameList = name.split(QRegExp("\\s+"), QString::SkipEmptyParts); + nameList = name.split(QRegularExpression("\\s+"), QString::SkipEmptyParts); firstName = nameList.first(); lastName = nameList.last(); } else { From b0649df7d69a3db1538c62c624eda42a6326110b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 23 Jan 2017 09:57:46 +0100 Subject: [PATCH 213/304] Fix MIPS32 processor detection Gcc defines neither _MIPS_ARCH_MIPS32 nor __mips32 on MIPS32 architectures, instead __mips is defined to 32. This fix exposed bit-rot in qdrawhelper where qt_memfill32 was set as a function pointer despite not being one since Qt4. Change-Id: I87461823e54fa3166223ebf97175fd05d2f2fd16 Reviewed-by: Thiago Macieira --- src/corelib/global/qprocessordetection.h | 6 +++--- src/gui/painting/qdrawhelper.cpp | 14 +------------- src/gui/painting/qdrawhelper_mips_dsp.cpp | 5 +++++ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index 566d76d3d2..55fcb37093 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -231,9 +231,6 @@ # if defined(_MIPS_ARCH_MIPS2) || (defined(__mips) && __mips - 0 >= 2) # define Q_PROCESSOR_MIPS_II # endif -# if defined(_MIPS_ARCH_MIPS32) || defined(__mips32) -# define Q_PROCESSOR_MIPS_32 -# endif # if defined(_MIPS_ARCH_MIPS3) || (defined(__mips) && __mips - 0 >= 3) # define Q_PROCESSOR_MIPS_III # endif @@ -243,6 +240,9 @@ # if defined(_MIPS_ARCH_MIPS5) || (defined(__mips) && __mips - 0 >= 5) # define Q_PROCESSOR_MIPS_V # endif +# if defined(_MIPS_ARCH_MIPS32) || defined(__mips32) || (defined(__mips) && __mips - 0 >= 32) +# define Q_PROCESSOR_MIPS_32 +# endif # if defined(_MIPS_ARCH_MIPS64) || defined(__mips64) # define Q_PROCESSOR_MIPS_64 # define Q_PROCESSOR_WORDSIZE 8 diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index adc28f07d3..298304c4ef 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6030,18 +6030,10 @@ void qt_memfill16(quint16 *dest, quint16 color, int count) qt_memfill_template(dest, color, count); } #endif -#if !defined(__SSE2__) && !defined(__ARM_NEON__) -# ifdef QT_COMPILER_SUPPORTS_MIPS_DSP -extern "C" void qt_memfill32_asm_mips_dsp(quint32 *, quint32, int); -# endif - +#if !defined(__SSE2__) && !defined(__ARM_NEON__) && !defined(__mips_dsp) void qt_memfill32(quint32 *dest, quint32 color, int count) { -# ifdef QT_COMPILER_SUPPORTS_MIPS_DSP - qt_memfill32_asm_mips_dsp(dest, color, count); -# else qt_memfill_template(dest, color, count); -# endif } #endif @@ -6233,10 +6225,6 @@ static void qInitDrawhelperFunctions() #endif -#if defined(Q_PROCESSOR_MIPS_32) && defined(QT_COMPILER_SUPPORTS_MIPS_DSP) - qt_memfill32 = qt_memfill32_asm_mips_dsp; -#endif // Q_PROCESSOR_MIPS_32 - #if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) if (qCpuHasFeature(DSP) && qCpuHasFeature(DSPR2)) { // Composition functions are all DSP r1 diff --git a/src/gui/painting/qdrawhelper_mips_dsp.cpp b/src/gui/painting/qdrawhelper_mips_dsp.cpp index b72ca3da3d..783e481296 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp.cpp +++ b/src/gui/painting/qdrawhelper_mips_dsp.cpp @@ -43,6 +43,11 @@ QT_BEGIN_NAMESPACE +void qt_memfill32(quint32 *dest, quint32 color, int count) +{ + qt_memfill32_asm_mips_dsp(dest, color, count); +} + void qt_blend_argb32_on_argb32_mips_dsp(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, From fc893d949c2d8924ea42b10b6b1dce118c3c985c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 24 Jan 2017 13:02:21 +0100 Subject: [PATCH 214/304] model-view-programming.qdoc: Add missing list/endlist Fixes qdoc-warnings: qtbase/src/widgets/doc/src/model-view-programming.qdoc:2076: warning: Command '\li' outside of '\list' and '\table' qtbase/src/widgets/doc/src/model-view-programming.qdoc:2077: warning: Command '\li' outside of '\list' and '\table' qtbase/src/widgets/doc/src/model-view-programming.qdoc:2078: warning: Command '\li' outside of '\list' and '\table' qtbase/src/widgets/doc/src/model-view-programming.qdoc:2079: warning: Command '\li' outside of '\list' and '\table' Amends change 7adfe7494bb4a2c1d3a036fe9dfd946bc00c5d49. Change-Id: Ifa1121ba743c17d7223058e780ad03211565e3ff Reviewed-by: David Faure --- src/widgets/doc/src/model-view-programming.qdoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index 84819e8c1a..f6b7c80656 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -2073,10 +2073,12 @@ model's structure, perhaps involving internal reorganization, sorting of data or any other structural change, it is necessary to perform the following sequence: + \list \li Emit the \l{QAbstractItemModel::layoutAboutToBeChanged()}{layoutAboutToBeChanged()} signal \li Update internal data which represents the structure of the model. \li Update persistent indexes using \l{QAbstractItemModel::changePersistentIndexList()}{changePersistentIndexList()} \li Emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} signal. + \endlist This sequence can be used for any structural update in lieu of the more high-level and convenient protected methods. For example, if a model of From 1b1686d194731d940a40112635647536ac8ee676 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 22 Nov 2016 15:35:24 +0100 Subject: [PATCH 215/304] Fix mouse extra button mapping on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously extra mouse buttons apart from left, right and middle buttons, were mapped incorrectly with an offset of -1. This resulted in the first extra button being recognized as the middle button, the second extra button as the first extra button, etc. Fix consists in using a binary shift with proper offset to create the corresponding Qt::MouseButton value. [ChangeLog][macOS] Fixed extra mouse buttons to be mapped to correct Qt::MouseButton values. Change-Id: I9e6084586cd4737a172b7706a805211f0edff749 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 01fbb7bad2..3ab6b641fa 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -281,16 +281,8 @@ NSRect qt_mac_flipRect(const QRect &rect) Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum) { - if (buttonNum == 0) - return Qt::LeftButton; - if (buttonNum == 1) - return Qt::RightButton; - if (buttonNum == 2) - return Qt::MiddleButton; - if (buttonNum >= 3 && buttonNum <= 31) { // handle XButton1 and higher via logical shift - return Qt::MouseButton(uint(Qt::MiddleButton) << (buttonNum - 3)); - } - // else error: buttonNum too high, or negative + if (buttonNum >= 0 && buttonNum <= 31) + return Qt::MouseButton(1 << buttonNum); return Qt::NoButton; } From 91e5c7e1da6d2a939b7a34cd9c166e76192bf53b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 21 Nov 2016 15:32:04 +0100 Subject: [PATCH 216/304] Inform user that a non-prefix build can't be used on other machines This implies that using tools like windeployqt and macdeployqt will not generate a working standalone application. Change-Id: I002cf6e527e479ccbee2f18df8766648196d6232 Reviewed-by: Andy Shaw Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_configure.prf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 4056b4d05a..1f7fb1b292 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1874,6 +1874,7 @@ pfx = $$[QT_INSTALL_PREFIX] equals(pfx, $$[QT_INSTALL_PREFIX/get]) { logn("Once everything is built, Qt is installed.") logn("You should NOT run '$$QMAKE_MAKE_NAME install'.") + logn("Note that this build cannot be deployed to other machines or devices.") } else { logn("Once everything is built, you must run '$$QMAKE_MAKE_NAME install'.") logn("Qt will be installed into '$$system_path($$pfx)'.") From 6a3e728e9b60f0201b0319b4b8de52ac5e282091 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Mon, 23 Jan 2017 22:12:59 +0100 Subject: [PATCH 217/304] Fix possible loss of data warning warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data while compiling class template member function 'QVarLengthArray::QVarLengthArray(std::initializer_list)' Change-Id: I36f5ef65ec1f511eac7f3ad1a4717d18f7dc9ce4 Reviewed-by: Timur Pocheptsov --- src/corelib/tools/qvarlengtharray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 1530299303..bb5ae78d2b 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -77,7 +77,7 @@ public: : a(Prealloc), s(0), ptr(reinterpret_cast(array)) { if (args.size()) - append(args.begin(), args.size()); + append(args.begin(), int(args.size())); } #endif From e0f0850cd48b92ae3beb33b65a3ac936d8f38b08 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 23 Jan 2017 16:07:36 +0100 Subject: [PATCH 218/304] Use context as glyph cache key in GL paint engine Switch from ctx->shareGroup() to ctx. The original intention to use the same cache instance for sharing GL contexts is reasonable, but can only work when there are only shareable resources involved. The FBO used by QOpenGLTextureGlyphCache is not one of these. Text rendering in Qt Quick already uses the same approach and uses per-context glyph caches. Change-Id: Ie7e521769f28b4902ca714eb029acfbf52814309 Task-number: QTBUG-58276 Reviewed-by: Joni Poikelin Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/opengl/qopenglpaintengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 5c05a05d80..90652a5ab8 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1664,7 +1664,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly QOpenGL2PaintEngineState *s = q->state(); - void *cacheKey = ctx->shareGroup(); + void *cacheKey = ctx; // use context, not the shareGroup() -> the GL glyph cache uses FBOs which may not be shareable bool recreateVertexArrays = false; QTransform glyphCacheTransform; From 9170cf9f1d57b6c31d58511b04759942d640b57c Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 22 Jan 2017 17:33:45 +0100 Subject: [PATCH 219/304] Remove use of deprecated QRegExp from QLibraryInfo This patch replaces QRegExp by QString search and replace. Change-Id: I11165afa45f8f9a856e6fb9b64929e4bdacb913d Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qlibraryinfo.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 0de8b50900..03ee0730db 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -530,14 +530,24 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) } #endif - // expand environment variables in the form $(ENVVAR) - int rep; - QRegExp reg_var(QLatin1String("\\$\\(.*\\)")); - reg_var.setMinimal(true); - while((rep = reg_var.indexIn(ret)) != -1) { - ret.replace(rep, reg_var.matchedLength(), - QString::fromLocal8Bit(qgetenv(ret.midRef(rep + 2, - reg_var.matchedLength() - 3).toLatin1().constData()).constData())); + int startIndex = 0; + forever { + startIndex = ret.indexOf(QLatin1Char('$'), startIndex); + if (startIndex < 0) + break; + if (ret.length() < startIndex + 3) + break; + if (ret.at(startIndex + 1) != QLatin1Char('(')) { + startIndex++; + continue; + } + int endIndex = ret.indexOf(QLatin1Char(')'), startIndex + 2); + if (endIndex < 0) + break; + QStringRef envVarName = ret.midRef(startIndex + 2, endIndex - startIndex - 2); + QString value = QString::fromLocal8Bit(qgetenv(envVarName.toLocal8Bit().constData())); + ret.replace(startIndex, endIndex - startIndex + 1, value); + startIndex += value.length(); } config->endGroup(); From 992bffdba587a1885e844570a0d04b15cda9fa3f Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 23:39:52 +0100 Subject: [PATCH 220/304] Doc: Fixed old text still mentioning QRegExp The example has already been ported to QRegularExpression however part of the documentation still referred to the QRegExp class. This patch updates the documentation to match the new version of the code. Change-Id: Id433d0b28deae0c4f702c0c54d2704174f8c7689 Reviewed-by: Sze Howe Koh --- examples/widgets/doc/src/icons.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/widgets/doc/src/icons.qdoc b/examples/widgets/doc/src/icons.qdoc index d3bf508f2c..42d823975b 100644 --- a/examples/widgets/doc/src/icons.qdoc +++ b/examples/widgets/doc/src/icons.qdoc @@ -741,8 +741,8 @@ whitespace and one or several digits again. The first digits of the regular expression are captured using - parentheses. This enables us to use the QRegExp::cap() or - QRegExp::capturedTexts() functions to extract the matched + parentheses. This enables us to use the QRegularExpressionMatch::captured() + or QRegularExpressionMatch::capturedTexts() functions to extract the matched characters. If the first and second numbers of the spin box value differ (e.g., "16 x 24"), we use the first number. From bb42a6741f7af19c8c8a1fa67c827b06000ec28c Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 01:14:34 +0100 Subject: [PATCH 221/304] Example: migrate licensewizard example to use QRegularExpression Update the licensewizard example to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: Ib6e0ee9ec802e83540b1c37846b99378395fe0ec Reviewed-by: Sze Howe Koh --- examples/widgets/dialogs/licensewizard/licensewizard.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/widgets/dialogs/licensewizard/licensewizard.cpp b/examples/widgets/dialogs/licensewizard/licensewizard.cpp index e145a18e2c..6dbb894ad8 100644 --- a/examples/widgets/dialogs/licensewizard/licensewizard.cpp +++ b/examples/widgets/dialogs/licensewizard/licensewizard.cpp @@ -54,6 +54,8 @@ #include "licensewizard.h" +QString emailRegExp = QStringLiteral(".+@.+"); + //! [0] //! [1] //! [2] LicenseWizard::LicenseWizard(QWidget *parent) : QWizard(parent) @@ -189,7 +191,7 @@ EvaluatePage::EvaluatePage(QWidget *parent) emailLabel = new QLabel(tr("&Email address:")); emailLineEdit = new QLineEdit; - emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this)); + emailLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(emailRegExp), this)); emailLabel->setBuddy(emailLineEdit); //! [21] @@ -264,7 +266,7 @@ DetailsPage::DetailsPage(QWidget *parent) emailLabel = new QLabel(tr("&Email address:")); emailLineEdit = new QLineEdit; - emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this)); + emailLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(emailRegExp), this)); emailLabel->setBuddy(emailLineEdit); postalLabel = new QLabel(tr("&Postal address:")); From 0a96d8fb38b85134a8879404fcd05b899dbf59e5 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 01:06:43 +0100 Subject: [PATCH 222/304] Example: migrate the classwizard example to use QRegularExpression Update the classwizard example to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: I125664549e249c4156f8c664fac7648f1c41f9d5 Reviewed-by: Sze Howe Koh --- examples/widgets/dialogs/classwizard/classwizard.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/widgets/dialogs/classwizard/classwizard.cpp b/examples/widgets/dialogs/classwizard/classwizard.cpp index d6c7c7a546..3eab2f5fb2 100644 --- a/examples/widgets/dialogs/classwizard/classwizard.cpp +++ b/examples/widgets/dialogs/classwizard/classwizard.cpp @@ -363,9 +363,10 @@ void CodeStylePage::initializePage() baseIncludeLabel->setEnabled(!baseClass.isEmpty()); baseIncludeLineEdit->setEnabled(!baseClass.isEmpty()); + QRegularExpression rx("Q[A-Z].*"); if (baseClass.isEmpty()) { baseIncludeLineEdit->clear(); - } else if (QRegExp("Q[A-Z].*").exactMatch(baseClass)) { + } else if (rx.match(baseClass).hasMatch()) { baseIncludeLineEdit->setText('<' + baseClass + '>'); } else { baseIncludeLineEdit->setText('"' + baseClass.toLower() + ".h\""); From 64e977cfac2fbe93fc234d3e134d126591d4c821 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 21 Jan 2017 00:29:28 +0900 Subject: [PATCH 223/304] Fix build without features.temporaryfile Change-Id: I3f26f122a20aa8e59baaf3f33b89cc776865ff8b Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qsettings.cpp | 4 ++-- .../compose/generator/qtablegenerator.cpp | 9 ++++++++- src/testlib/qtestcase.cpp | 2 ++ src/testlib/qtestcase.h | 2 ++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 8c67d97afa..e12da68671 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1460,7 +1460,7 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo) ensureAllSectionsParsed(confFile); ParsedSettingsMap mergedKeys = confFile->mergedKeyMap(); -#ifndef QT_BOOTSTRAPPED +#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(temporaryfile) QSaveFile sf(confFile->name); #else QFile sf(confFile->name); @@ -1488,7 +1488,7 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo) ok = writeFunc(sf, tempOriginalKeys); } -#ifndef QT_BOOTSTRAPPED +#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(temporaryfile) if (ok) ok = sf.commit(); #endif diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp index bd25992457..ca9f7af127 100644 --- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp +++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp @@ -194,8 +194,11 @@ static QVector loadCache(const QComposeCacheFileHeader &co static bool saveCache(const QComposeCacheFileHeader &info, const QVector &vec) { const QString filePath = getCacheFilePath(); +#if QT_CONFIG(temporaryfile) QSaveFile outputFile(filePath); - +#else + QFile outputFile(filePath); +#endif if (!outputFile.open(QIODevice::WriteOnly)) return false; const char *data = reinterpret_cast(&info); @@ -207,7 +210,11 @@ static bool saveCache(const QComposeCacheFileHeader &info, const QVector QTest::qExtractTestData(const QString &dirName) return result; } +#endif // QT_CONFIG(temporaryfile) /*! \internal */ diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 4c226830e9..57e0486686 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -283,7 +283,9 @@ namespace QTest Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const QRegularExpression &messagePattern); #endif +#if QT_CONFIG(temporaryfile) Q_TESTLIB_EXPORT QSharedPointer qExtractTestData(const QString &dirName); +#endif Q_TESTLIB_EXPORT QString qFindTestData(const char* basepath, const char* file = Q_NULLPTR, int line = 0, const char* builddir = Q_NULLPTR); Q_TESTLIB_EXPORT QString qFindTestData(const QString& basepath, const char* file = Q_NULLPTR, int line = 0, const char* builddir = Q_NULLPTR); From 0c415793b9622eef2148fdd21a2f3c2394a78d99 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 25 May 2016 11:51:17 +0200 Subject: [PATCH 224/304] Windows QPA: More fine-grained suppression of geometry/state change events When switching windows from fullscreen to maximized, move and resize events are triggered when changing the window decorations, ending up in QWindowsWindow::handleResized(), QWindowsWindow::handleMoved() which then may call handleGeometryChange(). Change 917ef5787444403ce0f7f035e27b1740c7672e34 blocks the emission of events depending on flag WithinSetStyle from handleGeometryChange() for Windows CE. This has issues which become visible when switching from fullscreen to maximized repeatedly: - State change events are still sent from QWindowsWindow::handleResized(), QWindowsWindow::handleMoved() when changing the window style programmatically causing the maximized state to be lost after a few cycles(QTBUG-53368). - Geometry change events are actually needed on the desktop for proper redrawing (QTBUG-53577). Make this more fine-grained by suppressing all state changed events while WithinSetStyle is set and allowing geometry changes. Amends 917ef5787444403ce0f7f035e27b1740c7672e34. Task-number: QTBUG-53368 Task-number: QTBUG-53577 Change-Id: Icc8dc935cfc29b314aab2d6fac02c97174c79c3e Reviewed-by: Oliver Wolff --- .../platforms/windows/qwindowswindow.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 5edf40b886..fb69936772 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1488,18 +1488,22 @@ void QWindowsWindow::handleResized(int wParam) case SIZE_MAXHIDE: // Some other window affected. case SIZE_MAXSHOW: return; - case SIZE_MINIMIZED: - handleWindowStateChange(Qt::WindowMinimized); + case SIZE_MINIMIZED: // QTBUG-53577, prevent state change events during programmatic state change + if (!testFlag(WithinSetStyle)) + handleWindowStateChange(Qt::WindowMinimized); return; case SIZE_MAXIMIZED: - handleWindowStateChange(Qt::WindowMaximized); + if (!testFlag(WithinSetStyle)) + handleWindowStateChange(Qt::WindowMaximized); handleGeometryChange(); break; case SIZE_RESTORED: - if (isFullScreen_sys()) - handleWindowStateChange(Qt::WindowFullScreen); - else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen)) - handleWindowStateChange(Qt::WindowNoState); + if (!testFlag(WithinSetStyle)) { + if (isFullScreen_sys()) + handleWindowStateChange(Qt::WindowFullScreen); + else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen)) + handleWindowStateChange(Qt::WindowNoState); + } handleGeometryChange(); break; } @@ -1507,9 +1511,6 @@ void QWindowsWindow::handleResized(int wParam) void QWindowsWindow::handleGeometryChange() { - //Prevent recursive resizes for Windows CE - if (testFlag(WithinSetStyle)) - return; const QRect previousGeometry = m_data.geometry; m_data.geometry = geometry_sys(); QPlatformWindow::setGeometry(m_data.geometry); From 447ca99191a8659c3b4aa57847f674a49a18f41c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 20 Jan 2017 14:41:46 +0100 Subject: [PATCH 225/304] Fix printsupport compilation with -no-feature... Change-Id: I881e736aefd4068965edb2a57f4436ee43d2bb93 Reviewed-by: Lars Knoll --- src/printsupport/configure.json | 8 +++++++- src/printsupport/kernel/qplatformprintdevice.cpp | 8 ++++++++ src/printsupport/widgets/qcupsjobwidget_p.h | 2 +- src/printsupport/widgets/widgets.pri | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/printsupport/configure.json b/src/printsupport/configure.json index 439f2dbdd8..a4855212fd 100644 --- a/src/printsupport/configure.json +++ b/src/printsupport/configure.json @@ -31,6 +31,12 @@ "condition": "libs.cups", "output": [ "privateFeature", "feature" ] }, + "cupsjobwidget": { + "label": "CUPS job control widget", + "section": "Widgets", + "condition": "features.cups && features.calendarwidget && features.datetimeedit && features.groupbox", + "output": [ "privateFeature", "feature" ] + }, "printer": { "label": "QPrinter", "purpose": "Provides a printer backend of QPainter.", @@ -49,7 +55,7 @@ "label": "QPrintDialog", "purpose": "Provides a dialog widget for specifying printer configuration.", "section": "Dialogs", - "condition": "features.printer && features.combobox && features.buttongroup && features.spinbox && features.treeview && features.tabwidget", + "condition": "features.printer && features.combobox && features.buttongroup && features.spinbox && features.treeview && features.tabwidget && features.datetimeedit", "output": [ "publicFeature", "feature" ] }, "printpreviewdialog": { diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp index eabd7e7295..cbb67aefdc 100644 --- a/src/printsupport/kernel/qplatformprintdevice.cpp +++ b/src/printsupport/kernel/qplatformprintdevice.cpp @@ -302,7 +302,11 @@ QPrint::InputSlot QPlatformPrintDevice::defaultInputSlot() const { QPrint::InputSlot input; input.key = QByteArrayLiteral("Auto"); +#if QT_CONFIG(printdialog) input.name = QPrintDialog::tr("Automatic"); +#else + input.name = QString::fromLatin1("Automatic"); +#endif input.id = QPrint::Auto; return input; } @@ -322,7 +326,11 @@ QPrint::OutputBin QPlatformPrintDevice::defaultOutputBin() const { QPrint::OutputBin output; output.key = QByteArrayLiteral("Auto"); +#if QT_CONFIG(printdialog) output.name = QPrintDialog::tr("Automatic"); +#else + output.name = QString::fromLatin1("Automatic"); +#endif output.id = QPrint::AutoOutputBin; return output; } diff --git a/src/printsupport/widgets/qcupsjobwidget_p.h b/src/printsupport/widgets/qcupsjobwidget_p.h index 5320818f30..288aeac1aa 100644 --- a/src/printsupport/widgets/qcupsjobwidget_p.h +++ b/src/printsupport/widgets/qcupsjobwidget_p.h @@ -56,7 +56,7 @@ #include #include -#if !defined(QT_NO_PRINTER) && !defined(QT_NO_CUPS) +#if !defined(QT_NO_PRINTER) && !defined(QT_NO_CUPS) && !defined(QT_NO_DATETIMEEDIT) #include QT_BEGIN_NAMESPACE diff --git a/src/printsupport/widgets/widgets.pri b/src/printsupport/widgets/widgets.pri index 8a98da1718..505983778e 100644 --- a/src/printsupport/widgets/widgets.pri +++ b/src/printsupport/widgets/widgets.pri @@ -1,11 +1,11 @@ HEADERS += widgets/qprintpreviewwidget.h SOURCES += widgets/qprintpreviewwidget.cpp -unix:!darwin:qtConfig(cups) { +unix:!darwin:qtConfig(cups):qtConfig(cupsjobwidget) { HEADERS += widgets/qcupsjobwidget_p.h SOURCES += widgets/qcupsjobwidget.cpp FORMS += widgets/qcupsjobwidget.ui - INCLUDEPATH += $$PWD } +INCLUDEPATH += $$PWD From d82e23e775c74f9993f9b8599c928e56abde6808 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 20 Jan 2017 14:41:46 +0100 Subject: [PATCH 226/304] Make sure features are defined before testing them Include the file defining the feature before testing whether the feature exists. Also use the new feature macro to make sure this bug doesn't happen again. Change-Id: I204836fee59b143a7ce7d256a7aed223c4d0ceb1 Reviewed-by: Lars Knoll --- src/widgets/dialogs/qfontdialog.cpp | 8 ++++---- src/widgets/itemviews/qcolumnview.cpp | 8 ++++---- src/widgets/styles/qstylesheetstyle.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 3a833e85c0..955e93a26f 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -38,10 +38,10 @@ ****************************************************************************/ #include "qwindowdefs.h" - -#ifndef QT_NO_FONTDIALOG - #include "qfontdialog.h" + +#if QT_CONFIG(fontdialog) + #include "qfontdialog_p.h" #include @@ -1051,4 +1051,4 @@ QT_END_NAMESPACE #include "qfontdialog.moc" #include "moc_qfontdialog.cpp" -#endif // QT_NO_FONTDIALOG +#endif // QT_CONFIG(fontdialog) diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 6c7c914bc0..ea9bbb0fb9 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -38,10 +38,10 @@ ****************************************************************************/ #include - -#ifndef QT_NO_COLUMNVIEW - #include "qcolumnview.h" + +#if QT_CONFIG(columnview) + #include "qcolumnview_p.h" #include "qcolumnviewgrip_p.h" @@ -1170,4 +1170,4 @@ QT_END_NAMESPACE #include "moc_qcolumnview.cpp" -#endif // QT_NO_COLUMNVIEW +#endif // QT_CONFIG(columnview) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 68ee8c22d3..d4f15b1315 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -38,10 +38,10 @@ ****************************************************************************/ #include - -#ifndef QT_NO_STYLE_STYLESHEET - #include "qstylesheetstyle_p.h" + +#if QT_CONFIG(style_stylesheet) + #include "private/qcssutil_p.h" #include #include @@ -6024,4 +6024,4 @@ QT_END_NAMESPACE #include "moc_qstylesheetstyle_p.cpp" -#endif // QT_NO_STYLE_STYLESHEET +#endif // QT_CONFIG(style_stylesheet) From 7cafa85a49d1b2fcafb21d647c94f01a9351a9b9 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 24 Jan 2017 15:51:05 +0100 Subject: [PATCH 227/304] Remove reimplementations of removed features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid the "marked ‘override’, but does not override" compile error. Change-Id: I4b125f1951614045781f3059fbc5cb65dd26775c Reviewed-by: Lars Knoll --- src/widgets/widgets/qabstractspinbox.cpp | 6 ++---- src/widgets/widgets/qabstractspinbox.h | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 494e30c7c7..8ccad5c35d 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1246,11 +1246,9 @@ void QAbstractSpinBox::timerEvent(QTimerEvent *event) \reimp */ +#if QT_CONFIG(contextmenu) void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event) { -#ifdef QT_NO_CONTEXTMENU - Q_UNUSED(event); -#else Q_D(QAbstractSpinBox); QPointer menu = d->edit->createStandardContextMenu(); @@ -1286,8 +1284,8 @@ void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event) } } event->accept(); -#endif // QT_NO_CONTEXTMENU } +#endif // QT_CONFIG(contextmenu) /*! \reimp diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index ac46894a27..b60178b94c 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -142,7 +142,9 @@ protected: #endif void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; +#if QT_CONFIG(contextmenu) void contextMenuEvent(QContextMenuEvent *event) override; +#endif void changeEvent(QEvent *event) override; void closeEvent(QCloseEvent *event) override; void hideEvent(QHideEvent *event) override; From 27792ea09897e41d52a9842af89b8d48cbac08ac Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 24 Jan 2017 16:11:56 +0100 Subject: [PATCH 228/304] Fix style compilation with -no-feature-... Change-Id: Ic7fadf0622f98d339322a4a1d4d5c36908f4f7f6 Reviewed-by: Lars Knoll --- src/widgets/styles/qcommonstyle.cpp | 2 ++ src/widgets/styles/qfusionstyle.cpp | 17 ++++++++++++++++- src/widgets/styles/qpixmapstyle.cpp | 19 +++++++++++++++---- src/widgets/styles/qstylesheetstyle.cpp | 7 ++++++- src/widgets/styles/qwindowsstyle.cpp | 2 ++ 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 690c811140..7971bd0b8b 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5224,9 +5224,11 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_Splitter_OpaqueResize: ret = true; break; +#if QT_CONFIG(itemviews) case SH_ItemView_ScrollMode: ret = QAbstractItemView::ScrollPerItem; break; +#endif default: ret = 0; break; diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index c2b4ef382b..898a14d7fb 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1097,6 +1097,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } painter->restore(); break; +#if QT_CONFIG(toolbar) case CE_ToolBar: if (const QStyleOptionToolBar *toolBar = qstyleoption_cast(option)) { // Reserve the beveled appearance only for mainwindow toolbars @@ -1217,6 +1218,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio painter->setPen(oldPen); } break; +#endif // QT_CONFIG(toolbar) case CE_DockWidgetTitle: painter->save(); if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast(option)) { @@ -1550,7 +1552,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio bool ignoreCheckMark = false; int checkcol = qMax(menuItem->maxIconWidth, 20); - if (qobject_cast(widget) || + if ( +#if QT_CONFIG(combobox) + qobject_cast(widget) || +#endif (option->styleObject && option->styleObject->property("_q_isComboBoxPopupItem").toBool())) ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate @@ -1607,8 +1612,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); QSize iconSize(smallIconSize, smallIconSize); +#if QT_CONFIG(combobox) if (const QComboBox *combo = qobject_cast(widget)) iconSize = combo->iconSize(); +#endif if (checked) pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); else @@ -3018,10 +3025,12 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption painter->setPen(oldPen); } break; +#if QT_CONFIG(dial) case CC_Dial: if (const QStyleOptionSlider *dial = qstyleoption_cast(option)) QStyleHelper::drawDial(dial, painter); break; +#endif default: QCommonStyle::drawComplexControl(control, option, painter, widget); break; @@ -3217,9 +3226,11 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti } } else if (!menuItem->icon.isNull()) { +#if QT_CONFIG(combobox) if (const QComboBox *combo = qobject_cast(widget)) { newSize.setHeight(qMax(combo->iconSize().height() + 2, newSize.height())); } +#endif } newSize.setWidth(newSize.width() + 12); newSize.setWidth(qMax(newSize.width(), 120)); @@ -3252,7 +3263,9 @@ void QFusionStyle::polish(QWidget *widget) { QCommonStyle::polish(widget); if (qobject_cast(widget) +#if QT_CONFIG(combobox) || qobject_cast(widget) +#endif || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) @@ -3281,7 +3294,9 @@ void QFusionStyle::unpolish(QWidget *widget) { QCommonStyle::unpolish(widget); if (qobject_cast(widget) +#if QT_CONFIG(combobox) || qobject_cast(widget) +#endif || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index ce37065fb6..ac57adf862 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -147,6 +147,7 @@ void QPixmapStyle::polish(QWidget *widget) if (qobject_cast(widget)) widget->installEventFilter(this); +#if QT_CONFIG(combobox) if (QComboBox *cb = qobject_cast(widget)) { widget->installEventFilter(this); // NOTE: This will break if the private API of QComboBox changes drastically @@ -177,16 +178,18 @@ void QPixmapStyle::polish(QWidget *widget) #endif } } - +#endif // QT_CONFIG(combobox) if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) widget->installEventFilter(this); if (QAbstractScrollArea *scrollArea = qobject_cast(widget)) { scrollArea->viewport()->setAutoFillBackground(false); +#if QT_CONFIG(itemviews) if (QAbstractItemView *view = qobject_cast(scrollArea)) { view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); } +#endif #if QT_CONFIG(gestures) QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture); #endif @@ -211,8 +214,11 @@ void QPixmapStyle::unpolish(QApplication *application) */ void QPixmapStyle::unpolish(QWidget *widget) { - if (qobject_cast(widget) || - qobject_cast(widget)) { + if (qobject_cast(widget) +#if QT_CONFIG(combobox) + || qobject_cast(widget) +#endif + ) { widget->removeEventFilter(this); } @@ -256,9 +262,11 @@ void QPixmapStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *o drawRadioButton(option, painter, widget); break; case PE_PanelItemViewItem: +#if QT_CONFIG(listview) if (qobject_cast(widget)) drawPanelItemViewItem(option, painter, widget); else +#endif QCommonStyle::drawPrimitive(element, option, painter, widget); break; default: @@ -532,6 +540,7 @@ bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) } } +#if QT_CONFIG(combobox) if (QComboBox *comboBox = qobject_cast(watched)) { switch (event->type()) { case QEvent::MouseButtonPress: @@ -552,6 +561,7 @@ bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) default: ; } } +#endif // QT_CONFIG(combobox) if (qstrcmp(watched->metaObject()->className(),"QComboBoxPrivateContainer") == 0) { if (event->type() == QEvent::Show) { @@ -701,9 +711,10 @@ void QPixmapStyle::drawLineEdit(const QStyleOption *option, QPainter *painter, const QWidget *widget) const { // Don't draw for the line edit inside a combobox +#if QT_CONFIG(combobox) if (widget && qobject_cast(widget->parentWidget())) return; - +#endif const bool enabled = option->state & State_Enabled; const bool focused = option->state & State_HasFocus; ControlDescriptor control = enabled ? (focused ? LE_Focused : LE_Enabled) : LE_Disabled; diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index d4f15b1315..5a0b93474f 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4415,14 +4415,18 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op break; case PE_IndicatorColumnViewArrow: +#if QT_CONFIG(itemviews) if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast(opt)) { bool reverse = (viewOpt->direction == Qt::RightToLeft); pseudoElement = reverse ? PseudoElement_LeftArrow : PseudoElement_RightArrow; - } else { + } else +#endif + { pseudoElement = PseudoElement_RightArrow; } break; +#if QT_CONFIG(itemviews) case PE_IndicatorBranch: if (const QStyleOptionViewItem *vopt = qstyleoption_cast(opt)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_TreeViewBranch); @@ -4437,6 +4441,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } } return; +#endif // QT_CONFIG(itemviews) case PE_PanelTipLabel: if (!rule.hasDrawable()) diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index a8ee881a30..f9370a2cc7 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -815,6 +815,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->save(); doRestore = true; } +#if QT_CONFIG(itemviews) if (pe == PE_IndicatorViewItemCheck) { const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast(opt); p->setPen(itemViewOpt @@ -826,6 +827,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->setBrush(opt->palette.brush(QPalette::Button)); p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11); } +#endif // QT_CONFIG(itemviews) if (!(opt->state & State_Off)) { QLineF lines[7]; int i, xx, yy; From fcab7186668de71a7c0f9055fb75c98b906f5dc7 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 24 Jan 2017 16:37:25 +0100 Subject: [PATCH 229/304] Fix build with -no-feature-dockwidget Change-Id: Id484b54fd7191715e61ba6708247357b83159f28 Reviewed-by: Lars Knoll --- src/widgets/widgets/qmainwindowlayout.cpp | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 14d7f3d835..9e1af16625 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2172,7 +2172,9 @@ void QMainWindowLayout::animationFinished(QWidget *widget) savedState.clear(); currentGapPos.clear(); pluggingWidget = 0; - currentHoveredFloat = Q_NULLPTR; +#if QT_CONFIG(dockwidget) + currentHoveredFloat = nullptr; +#endif //applying the state will make sure that the currentGap is updated correctly //and all the geometries (especially the one from the central widget) is correct layoutState.apply(false); @@ -2408,8 +2410,16 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) void QMainWindowLayout::updateGapIndicator() { #ifndef QT_NO_RUBBERBAND - if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) || currentHoveredFloat) { - QWidget *expectedParent = currentHoveredFloat ? currentHoveredFloat.data() : parentWidget(); + if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) +#if QT_CONFIG(dockwidget) + || currentHoveredFloat +#endif + ) { + QWidget *expectedParent = +#if QT_CONFIG(dockwidget) + currentHoveredFloat ? currentHoveredFloat.data() : +#endif + parentWidget(); if (!gapIndicator) { gapIndicator = new QRubberBand(QRubberBand::Rectangle, expectedParent); // For accessibility to identify this special widget. @@ -2417,7 +2427,11 @@ void QMainWindowLayout::updateGapIndicator() } else if (gapIndicator->parent() != expectedParent) { gapIndicator->setParent(expectedParent); } - gapIndicator->setGeometry(currentHoveredFloat ? currentHoveredFloat->rect() : currentGapRect); + gapIndicator->setGeometry( +#if QT_CONFIG(dockwidget) + currentHoveredFloat ? currentHoveredFloat->rect() : +#endif + currentGapRect); gapIndicator->show(); gapIndicator->raise(); } else if (gapIndicator) { @@ -2540,12 +2554,14 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) updateGapIndicator(); } +#if QT_CONFIG(dockwidget) QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow() { QDockWidgetGroupWindow* f = new QDockWidgetGroupWindow(parentWidget(), Qt::Tool); new QDockWidgetGroupLayout(f); return f; } +#endif void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animate) { From 6d06d4b07c5fb1b51d6d1e216a0bcd6da2dedaf2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 24 Jan 2017 16:48:42 +0100 Subject: [PATCH 230/304] Fix build with -no-feature-graphicsview Change-Id: I9ae724ddf90efc9e951d475e3332083e6f8207d6 Reviewed-by: Lars Knoll --- src/widgets/graphicsview/graphicsview.pri | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/widgets/graphicsview/graphicsview.pri b/src/widgets/graphicsview/graphicsview.pri index b81f736ef4..7d10244634 100644 --- a/src/widgets/graphicsview/graphicsview.pri +++ b/src/widgets/graphicsview/graphicsview.pri @@ -1,4 +1,6 @@ # Qt graphicsview module + +qtConfig(graphicsview) { HEADERS += graphicsview/qgraphicsgridlayout.h \ graphicsview/qgraphicsitem.h \ graphicsview/qgraphicsitem_p.h \ @@ -53,3 +55,4 @@ SOURCES += graphicsview/qgraphicsgridlayout.cpp \ graphicsview/qsimplex_p.cpp \ graphicsview/qgraphicsanchorlayout_p.cpp \ graphicsview/qgraphicsanchorlayout.cpp +} From eae92384b0f59a7c27edd422e5b3f26c2d8b323c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 24 Jan 2017 17:38:11 +0100 Subject: [PATCH 231/304] Compile with -no-feature-itemviews Change-Id: I23506f06df35f124f5eb9fcc8426c63b407a0872 Reviewed-by: Lars Knoll --- src/widgets/configure.json | 2 +- src/widgets/itemviews/itemviews.pri | 11 ++++++++--- src/widgets/widgets/qabstractscrollarea.cpp | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 8acbffef6a..92a57534e6 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -504,7 +504,7 @@ "label": "QCompleter", "purpose": "Provides completions based on an item model.", "section": "Utilities", - "condition": "features.proxymodel", + "condition": "features.proxymodel && features.itemviews", "output": [ "publicFeature", "feature" ] }, "fscompleter": { diff --git a/src/widgets/itemviews/itemviews.pri b/src/widgets/itemviews/itemviews.pri index 245962d35f..d78bc4b40e 100644 --- a/src/widgets/itemviews/itemviews.pri +++ b/src/widgets/itemviews/itemviews.pri @@ -1,5 +1,6 @@ # Qt gui library, itemviews +qtConfig(itemviews) { HEADERS += \ itemviews/qabstractitemview.h \ itemviews/qabstractitemview_p.h \ @@ -27,8 +28,6 @@ HEADERS += \ itemviews/qitemeditorfactory_p.h \ itemviews/qtreewidgetitemiterator.h \ itemviews/qdatawidgetmapper.h \ - itemviews/qfileiconprovider.h \ - itemviews/qfileiconprovider_p.h \ itemviews/qcolumnviewgrip_p.h \ itemviews/qcolumnview.h \ itemviews/qcolumnview_p.h \ @@ -50,8 +49,14 @@ SOURCES += \ itemviews/qitemeditorfactory.cpp \ itemviews/qtreewidgetitemiterator.cpp \ itemviews/qdatawidgetmapper.cpp \ - itemviews/qfileiconprovider.cpp \ itemviews/qcolumnview.cpp \ itemviews/qcolumnviewgrip.cpp \ itemviews/qstyleditemdelegate.cpp +} +HEADERS += \ + itemviews/qfileiconprovider.h \ + itemviews/qfileiconprovider_p.h \ + +SOURCES += \ + itemviews/qfileiconprovider.cpp diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 5b31e4467f..35b9851cad 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -473,6 +473,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() // move the scrollbars away from top/left headers int vHeaderRight = 0; int hHeaderBottom = 0; +#if QT_CONFIG(itemviews) if ((vscrollOverlap > 0 && needv) || (hscrollOverlap > 0 && needh)) { const QList headers = q->findChildren(); if (headers.count() <= 2) { @@ -485,7 +486,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() } } } - +#endif // QT_CONFIG(itemviews) if (needh) { QRect horizontalScrollBarRect(QPoint(controlsRect.left() + vHeaderRight, cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom())); #if 0 // Used to be included in Qt4 for Q_WS_MAC From 056a35d02f683dba8deba5345477987c451c189c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 24 Jan 2017 18:00:16 +0100 Subject: [PATCH 232/304] Fix build with -no-feature-menu Change-Id: I8f9d5ef6b7f7102e56816677f1d3a5b5144b7083 Reviewed-by: Lars Knoll --- src/widgets/accessible/qaccessiblewidgets.cpp | 2 ++ src/widgets/accessible/simplewidgets.cpp | 6 ++++-- src/widgets/util/qsystemtrayicon.cpp | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index b814762168..4c48ecb465 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -85,7 +85,9 @@ QList childWidgets(const QWidget *widget) QString objectName = w->objectName(); if (!w->isWindow() && !qobject_cast(w) +#if QT_CONFIG(menu) && !qobject_cast(w) +#endif && objectName != QLatin1String("qt_rubberband") && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) { widgets.append(w); diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index e6fda103fb..0cfa9bfbb2 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -339,10 +339,12 @@ QStringList QAccessibleToolButton::actionNames() const { QStringList names; if (widget()->isEnabled()) { +#if QT_CONFIG(menu) if (toolButton()->menu()) names << showMenuAction(); if (toolButton()->popupMode() != QToolButton::InstantPopup) names << QAccessibleButton::actionNames(); +#endif } return names; } @@ -355,12 +357,12 @@ void QAccessibleToolButton::doAction(const QString &actionName) if (actionName == pressAction()) { button()->click(); } else if (actionName == showMenuAction()) { +#if QT_CONFIG(menu) if (toolButton()->popupMode() != QToolButton::InstantPopup) { toolButton()->setDown(true); -#ifndef QT_NO_MENU toolButton()->showMenu(); -#endif } +#endif } else { QAccessibleButton::doAction(actionName); } diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 630524aadb..f7464d50ec 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -693,10 +693,12 @@ void QSystemTrayIconPrivate::updateIcon_sys_qpa() void QSystemTrayIconPrivate::updateMenu_sys_qpa() { +#if QT_CONFIG(menu) if (menu) { addPlatformMenu(menu); qpa_sys->updateMenu(menu->platformMenu()); } +#endif } void QSystemTrayIconPrivate::updateToolTip_sys_qpa() @@ -729,6 +731,7 @@ void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &title, void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const { +#if QT_CONFIG(menu) if (menu->platformMenu()) return; // The platform menu already exists. @@ -745,6 +748,7 @@ void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const QPlatformMenu *platformMenu = qpa_sys->createMenu(); if (platformMenu) menu->setPlatformMenu(platformMenu); +#endif // QT_CONFIG(menu) } QT_END_NAMESPACE From a8a74fe81acab07bfe068bff398555804629a88c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 25 Jan 2017 11:21:32 +0100 Subject: [PATCH 233/304] Stabilize tst_QPropertyAnimation::noStartValue() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the qWait() and introduce a QTRY_COMPARE() checking for the end value first. Task-number: QTBUG-58402 Change-Id: I2d3758178de5f67881008f28c406076ad27c4a90 Reviewed-by: Jędrzej Nowacki --- .../animation/qpropertyanimation/tst_qpropertyanimation.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index c1a8fde504..b0b0a307e9 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -441,10 +441,8 @@ void tst_QPropertyAnimation::noStartValue() a.setDuration(250); a.start(); - QTest::qWait(300); - - QTRY_COMPARE(o.values.first(), 42); - QCOMPARE(o.values.last(), 420); + QTRY_COMPARE(o.values.value(o.values.size() - 1, -1), 420); + QCOMPARE(o.values.first(), 42); } void tst_QPropertyAnimation::noStartValueWithLoop() From 69e233d2ba4a3e8762726aa3a168777f1df460c4 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 17 Jan 2017 14:48:08 +0300 Subject: [PATCH 234/304] Avoid detaching temporary objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found with clazy [detaching-temporary]: - don't call QList::first() on temporary - don't call QString::operator[]() on temporary - don't call QByteArray::data() on temporary Change-Id: I390962ef6020e4fcb0b0e447a63eed1e314d18a4 Reviewed-by: Anton Kudryavtsev Reviewed-by: Sérgio Martins --- src/corelib/io/qfsfileengine_unix.cpp | 2 +- src/network/access/qnetworkdiskcache.cpp | 2 +- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 2 +- src/tools/uic/main.cpp | 2 +- src/widgets/widgets/qcalendarwidget.cpp | 2 +- src/widgets/widgets/qmenubar.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index b2e3df79b8..ca5af924e9 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -629,7 +629,7 @@ QString QFSFileEngine::fileName(FileName file) const bool QFSFileEngine::isRelativePath() const { Q_D(const QFSFileEngine); - return d->fileEntry.filePath().length() ? d->fileEntry.filePath()[0] != QLatin1Char('/') : true; + return d->fileEntry.filePath().length() ? d->fileEntry.filePath().at(0) != QLatin1Char('/') : true; } uint QFSFileEngine::ownerId(FileOwner own) const diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index ce3b773c64..d72791c1f0 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -606,7 +606,7 @@ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url) QCryptographicHash hash(QCryptographicHash::Sha1); hash.addData(cleanUrl.toEncoded()); // convert sha1 to base36 form and return first 8 bytes for use as string - QByteArray id = QByteArray::number(*(qlonglong*)hash.result().data(), 36).left(8); + const QByteArray id = QByteArray::number(*(qlonglong*)hash.result().constData(), 36).left(8); // generates /<8-char filname.d> uint code = (uint)id.at(id.length()-1) % 16; QString pathFragment = QString::number(code, 16) + QLatin1Char('/') diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 70c4aa563c..6561e95a0d 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -1398,7 +1398,7 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS sendReply(connection, message, QVariant::fromValue( QDBusVariant(QVariant::fromValue(QSpiObjectReference(connection, QDBusObjectPath(path)))))); } else if (function == QLatin1String("GetChildAtIndex")) { - int index = message.arguments().first().toInt(); + const int index = message.arguments().at(0).toInt(); if (index < 0) { sendReply(connection, message, QVariant::fromValue( QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL)))); diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index e2399cd1fd..fca604690e 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -115,7 +115,7 @@ int runUic(int argc, char *argv[]) QString inputFile; if (!parser.positionalArguments().isEmpty()) - inputFile = parser.positionalArguments().first(); + inputFile = parser.positionalArguments().at(0); else // reading from stdin driver.option().headerProtection = false; diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index b0ded70c4a..da4850a816 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -765,7 +765,7 @@ bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e) if (m_widget) { if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { QKeyEvent* ke = (QKeyEvent*)e; - if ((ke->text().length() > 0 && ke->text()[0].isPrint()) || m_dateFrame) { + if ((ke->text().length() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) { applyDate(); emit editingFinished(); diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index ce43740524..cec5d512fd 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1119,7 +1119,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) int clashCount = 0; QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; { - QChar c = e->text()[0].toUpper(); + const QChar c = e->text().at(0).toUpper(); for(int i = 0; i < d->actions.size(); ++i) { if (d->actionRects.at(i).isNull()) continue; From 6bf9f49072233b4eef9afac2720ef282c65b6948 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 09:38:12 +0100 Subject: [PATCH 235/304] Fix build with -no-feature-menubar Change-Id: I23b23fcaf6fcc655d38a06495127b108975f4a58 Reviewed-by: Lars Knoll --- src/widgets/accessible/qaccessiblemenu.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index 4a684e01f9..ae50bbaef0 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -117,7 +117,11 @@ QAccessibleInterface *QAccessibleMenu::parent() const parentCandidates << menu()->parentWidget(); parentCandidates << menuAction->associatedWidgets(); foreach (QWidget *w, parentCandidates) { - if (qobject_cast(w) || qobject_cast(w)) { + if (qobject_cast(w) +#if QT_CONFIG(menubar) + || qobject_cast(w) +#endif + ) { if (w->actions().indexOf(menuAction) != -1) return getOrCreateMenu(w, menuAction); } @@ -348,13 +352,16 @@ void QAccessibleMenuItem::doAction(const QString &actionName) if (actionName == pressAction()) { m_action->trigger(); } else if (actionName == showMenuAction()) { +#if QT_CONFIG(menubar) if (QMenuBar *bar = qobject_cast(owner())) { if (m_action->menu() && m_action->menu()->isVisible()) { m_action->menu()->hide(); } else { bar->setActiveAction(m_action); } - } else if (QMenu *menu = qobject_cast(owner())){ + } else +#endif + if (QMenu *menu = qobject_cast(owner())){ if (m_action->menu() && m_action->menu()->isVisible()) { m_action->menu()->hide(); } else { From cabf2950f7bb25cee06a92202f47692df1c37847 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 09:58:13 +0100 Subject: [PATCH 236/304] Fix build with -no-feature-rubberband Change-Id: Ida6698c4868507ccbf5b4c5e3eb1d2f5a7109f53 Reviewed-by: Lars Knoll --- src/widgets/widgets/qmdiarea.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 9b39743281..6b23e22bc1 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1533,6 +1533,7 @@ void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor) Q_ASSERT(indexToHighlighted >= 0); } +#if QT_CONFIG(rubberband) void QMdiAreaPrivate::showRubberBandFor(QMdiSubWindow *subWindow) { if (!subWindow || !rubberBand) @@ -1546,7 +1547,7 @@ void QMdiAreaPrivate::showRubberBandFor(QMdiSubWindow *subWindow) rubberBand->raise(); rubberBand->show(); } - +#endif // QT_CONFIG(rubberBand) /*! \internal \since 4.4 From 2ac7fb78b9928a7bac133e474d483b14e65d0a65 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 09:59:41 +0100 Subject: [PATCH 237/304] Fix styles compilation with features removed, round 2 Change-Id: I8f09a8844e5edc1ad3e3dfd39eca9f3b42c5c828 Reviewed-by: Lars Knoll --- src/widgets/styles/qfusionstyle.cpp | 35 +++++++++++++++++++- src/widgets/styles/qpixmapstyle.cpp | 44 ++++++++++++++++++++----- src/widgets/styles/qstylehelper.cpp | 2 +- src/widgets/styles/qstylesheetstyle.cpp | 2 ++ 4 files changed, 72 insertions(+), 11 deletions(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 898a14d7fb..e08cd3ac70 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -453,6 +453,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, drawPrimitive(PE_IndicatorArrowRight, option, painter, widget); break; } +#if QT_CONFIG(tabbar) case PE_FrameTabBarBase: if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast(option)) { @@ -489,6 +490,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, painter->restore(); } return; +#endif // QT_CONFIG(tabbar) case PE_PanelScrollAreaCorner: { painter->save(); QColor alphaOutline = outline; @@ -938,6 +940,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, case PE_FrameTabWidget: painter->save(); painter->fillRect(option->rect.adjusted(0, 0, -1, -1), tabFrameColor); +#if QT_CONFIG(tabwidget) if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast(option)) { QColor borderColor = outline.lighter(110); QRect rect = option->rect.adjusted(0, 0, -1, -1); @@ -960,6 +963,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, painter->drawRect(rect.adjusted(1, 1, -1, -1)); } +#endif // QT_CONFIG(tabwidget) painter->restore(); break ; @@ -1057,6 +1061,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } break; } +#if QT_CONFIG(rubberband) case CE_RubberBand: if (qstyleoption_cast(option)) { QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight); @@ -1082,6 +1087,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio painter->restore(); } break; +#endif //QT_CONFIG(rubberband) case CE_SizeGrip: painter->save(); { @@ -1800,6 +1806,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } painter->restore(); break; +#if QT_CONFIG(tabbar) case CE_TabBarTabShape: painter->save(); if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { @@ -1915,6 +1922,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } painter->restore(); break; +#endif //QT_CONFIG(tabbar) default: QCommonStyle::drawControl(element,option,painter,widget); break; @@ -2000,6 +2008,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } painter->restore(); break; +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { QPixmap cache; @@ -2150,6 +2159,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption painter->drawPixmap(spinBox->rect.topLeft(), cache); } break; +#endif // QT_CONFIG(spinbox) case CC_TitleBar: painter->save(); if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast(option)) { @@ -2410,6 +2420,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } painter->restore(); break; +#if QT_CONFIG(slider) case CC_ScrollBar: painter->save(); if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { @@ -2718,6 +2729,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } painter->restore(); break;; +#endif // QT_CONFIG(slider) case CC_ComboBox: painter->save(); if (const QStyleOptionComboBox *comboBox = qstyleoption_cast(option)) { @@ -2815,6 +2827,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } painter->restore(); break; +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); @@ -3025,6 +3038,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption painter->setPen(oldPen); } break; +#endif // QT_CONFIG(slider) #if QT_CONFIG(dial) case CC_Dial: if (const QStyleOptionSlider *dial = qstyleoption_cast(option)) @@ -3266,11 +3280,19 @@ void QFusionStyle::polish(QWidget *widget) #if QT_CONFIG(combobox) || qobject_cast(widget) #endif +#if QT_CONFIG(progressbar) || qobject_cast(widget) +#endif +#if QT_CONFIG(scrollbar) || qobject_cast(widget) +#endif +#if QT_CONFIG(splitter) || qobject_cast(widget) +#endif || qobject_cast(widget) +#if QT_CONFIG(spinbox) || qobject_cast(widget) +#endif || (widget->inherits("QDockSeparator")) || (widget->inherits("QDockWidgetSeparator")) ) { @@ -3297,11 +3319,19 @@ void QFusionStyle::unpolish(QWidget *widget) #if QT_CONFIG(combobox) || qobject_cast(widget) #endif +#if QT_CONFIG(progressbar) || qobject_cast(widget) +#endif +#if QT_CONFIG(scrollbar) || qobject_cast(widget) +#endif +#if QT_CONFIG(splitter) || qobject_cast(widget) +#endif || qobject_cast(widget) +#if QT_CONFIG(spinbox) || qobject_cast(widget) +#endif || (widget->inherits("QDockSeparator")) || (widget->inherits("QDockWidgetSeparator")) ) { @@ -3326,6 +3356,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget); switch (control) { +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); @@ -3376,6 +3407,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom } } break; +#endif // QT_CONFIG(slider) +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) { int center = spinbox->rect.height() / 2; @@ -3413,7 +3446,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom rect = visualRect(spinbox->direction, spinbox->rect, rect); } break; - +#endif // QT_CONFIG(spinbox) case CC_GroupBox: if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) { rect = option->rect; diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index ac57adf862..a947f5d079 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -129,12 +129,14 @@ void QPixmapStyle::polish(QWidget *widget) Q_D(QPixmapStyle); // Don't fill the interior of the QTextEdit +#if QT_CONFIG(textedit) if (qobject_cast(widget)) { QPalette p = widget->palette(); p.setBrush(QPalette::Base, Qt::NoBrush); widget->setPalette(p); } - +#endif +#if QT_CONFIG(progressbar) if (QProgressBar *pb = qobject_cast(widget)) { // Center the text in the progress bar pb->setAlignment(Qt::AlignCenter); @@ -143,10 +145,11 @@ void QPixmapStyle::polish(QWidget *widget) font.setPixelSize(d->descriptors.value(PB_HBackground).size.height()/2); pb->setFont(font); } - +#endif +#if QT_CONFIG(slider) if (qobject_cast(widget)) widget->installEventFilter(this); - +#endif #if QT_CONFIG(combobox) if (QComboBox *cb = qobject_cast(widget)) { widget->installEventFilter(this); @@ -182,6 +185,7 @@ void QPixmapStyle::polish(QWidget *widget) if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) widget->installEventFilter(this); +#if QT_CONFIG(scrollarea) if (QAbstractScrollArea *scrollArea = qobject_cast(widget)) { scrollArea->viewport()->setAutoFillBackground(false); #if QT_CONFIG(itemviews) @@ -194,10 +198,11 @@ void QPixmapStyle::polish(QWidget *widget) QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture); #endif } - +#endif // QT_CONFIG(scrollarea) +#if QT_CONFIG(scrollbar) if (qobject_cast(widget)) widget->setAttribute(Qt::WA_OpaquePaintEvent, false); - +#endif QCommonStyle::polish(widget); } @@ -214,7 +219,12 @@ void QPixmapStyle::unpolish(QApplication *application) */ void QPixmapStyle::unpolish(QWidget *widget) { - if (qobject_cast(widget) + if ( +#if QT_CONFIG(slider) + qobject_cast(widget) +#else + false +#endif #if QT_CONFIG(combobox) || qobject_cast(widget) #endif @@ -225,7 +235,7 @@ void QPixmapStyle::unpolish(QWidget *widget) if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) widget->removeEventFilter(this); -#if QT_CONFIG(gestures) +#if QT_CONFIG(gestures) && QT_CONFIG(scrollarea) if (QAbstractScrollArea *scrollArea = qobject_cast(widget)) QScroller::ungrabGesture(scrollArea->viewport()); #endif @@ -251,10 +261,12 @@ void QPixmapStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *o drawLineEdit(option, painter, widget); break; case PE_Frame: +#if QT_CONFIG(textedit) case PE_FrameDefaultButton: if (qobject_cast(widget)) drawTextEdit(option, painter, widget); break; +#endif case PE_IndicatorCheckBox: drawCheckBox(option, painter, widget); break; @@ -412,11 +424,13 @@ int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, case PM_ButtonShiftVertical: return 0; case PM_DefaultFrameWidth: +#if QT_CONFIG(textedit) if (qobject_cast(widget)) { const QPixmapStyleDescriptor &desc = d->descriptors.value(LE_Enabled); return qMax(qMax(desc.margins.left(), desc.margins.right()), qMax(desc.margins.top(), desc.margins.bottom())); } +#endif return 0; case PM_IndicatorWidth: return d->pixmaps.value(CB_Enabled).pixmap.width(); @@ -438,6 +452,7 @@ int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, return qMax(qMax(pix.margins.left(), pix.margins.right()), qMax(pix.margins.top(), pix.margins.bottom())); } +#if QT_CONFIG(slider) case PM_SliderThickness: if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { @@ -478,6 +493,7 @@ int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, ? desc.size.height() : desc.size.width(); } break; +#endif // QT_CONFIG(slider) case PM_ScrollBarSliderMin: return 0; default: ; @@ -528,7 +544,7 @@ QStyle::SubControl QPixmapStyle::hitTestComplexControl(QStyle::ComplexControl co bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) { Q_D(QPixmapStyle); - +#if QT_CONFIG(slider) if (QSlider *slider = qobject_cast(watched)) { switch (event->type()) { case QEvent::MouseButtonPress: @@ -539,7 +555,7 @@ bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) default: ; } } - +#endif // QT_CONFIG(slider) #if QT_CONFIG(combobox) if (QComboBox *comboBox = qobject_cast(watched)) { switch (event->type()) { @@ -859,6 +875,7 @@ void QPixmapStyle::drawProgressBarFill(const QStyleOption *option, void QPixmapStyle::drawSlider(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { +#if QT_CONFIG(slider) Q_D(const QPixmapStyle); const QStyleOptionSlider *slider = qstyleoption_cast(option); @@ -908,6 +925,7 @@ void QPixmapStyle::drawSlider(const QStyleOptionComplex *option, painter->drawPixmap(handle, d->pixmaps.value(pix).pixmap); } } +#endif // QT_CONFIG(slider) } void QPixmapStyle::drawComboBox(const QStyleOptionComplex *option, @@ -934,6 +952,7 @@ void QPixmapStyle::drawComboBox(const QStyleOptionComplex *option, void QPixmapStyle::drawScrollBar(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { +#if QT_CONFIG(slider) if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { // Do not draw the scrollbar @@ -945,6 +964,7 @@ void QPixmapStyle::drawScrollBar(const QStyleOptionComplex *option, ? SB_Horizontal : SB_Vertical; drawCachedPixmap(control, rect, painter); } +#endif // QT_CONFIG(slider) } QSize QPixmapStyle::pushButtonSizeFromContents(const QStyleOption *option, @@ -1003,6 +1023,7 @@ QSize QPixmapStyle::sliderSizeFromContents(const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const { +#if QT_CONFIG(slider) Q_D(const QPixmapStyle); const QStyleOptionSlider *slider = qstyleoption_cast(option); @@ -1018,6 +1039,9 @@ QSize QPixmapStyle::sliderSizeFromContents(const QStyleOption *option, return QSize(result.width(), desc.size.height()); else return QSize(desc.size.width(), result.height()); +#else // QT_CONFIG(slider) + return QSize(); +#endif // QT_CONFIG(slider) } QSize QPixmapStyle::comboBoxSizeFromContents(const QStyleOption *option, @@ -1085,6 +1109,7 @@ QRect QPixmapStyle::comboBoxSubControlRect(const QStyleOptionComplex *option, QRect QPixmapStyle::scrollBarSubControlRect(const QStyleOptionComplex *option, QStyle::SubControl sc, const QWidget *) const { +#if QT_CONFIG(slider) if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { int length = (slider->orientation == Qt::Horizontal) @@ -1131,6 +1156,7 @@ QRect QPixmapStyle::scrollBarSubControlRect(const QStyleOptionComplex *option, } } } +#endif // QT_CONFIG(slider) return QRect(); } diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 602421725f..9b381c383b 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -411,7 +411,7 @@ void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rec QColor backgroundColor(const QPalette &pal, const QWidget* widget) { -#ifndef QT_NO_SCROLLBAR +#if QT_CONFIG(scrollarea) if (qobject_cast(widget) && widget->parent() && qobject_cast(widget->parent()->parent())) return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base); diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 5a0b93474f..d9d270643c 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4903,6 +4903,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op QSize sz = rule.adjustSize(csz); switch (ct) { +#if QT_CONFIG(spinbox) case CT_SpinBox: // ### hopelessly broken QAbstractSpinBox (part 1) if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(opt)) { // Add some space for the up/down buttons @@ -4920,6 +4921,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op return sz; } break; +#endif // QT_CONFIG(spinbox) case CT_ToolButton: if (rule.hasBox() || !rule.hasNativeBorder() || !rule.baseStyleCanDraw()) sz += QSize(3, 3); // ### broken QToolButton From 2bbeebf80c127979d1859c8486774df22be4c3f2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 10:10:07 +0100 Subject: [PATCH 238/304] Fix build with -no-feature-textedit Change-Id: I4a75c134803043180c57287ca352e26e3422204c Reviewed-by: Lars Knoll --- src/widgets/configure.json | 2 +- src/widgets/dialogs/qmessagebox.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 92a57534e6..84500bff21 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -435,7 +435,7 @@ "label": "QInputDialog", "purpose": "Provides a simple convenience dialog to get a single value from the user.", "section": "Dialogs", - "condition": "features.combobox && features.spinbox && features.stackedwidget", + "condition": "features.combobox && features.spinbox && features.stackedwidget && features.textedit", "output": [ "publicFeature", "feature" ] }, "errormessage": { diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 57b3f47863..98d070e493 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -336,8 +336,10 @@ void QMessageBoxPrivate::setupLayout() #else grid->addWidget(buttonBox, grid->rowCount(), 0, 1, grid->columnCount()); #endif +#if QT_CONFIG(textedit) if (detailsText) grid->addWidget(detailsText, grid->rowCount(), 0, 1, grid->columnCount()); +#endif grid->setSizeConstraint(QLayout::SetNoConstraint); q->setLayout(grid); @@ -2654,7 +2656,9 @@ void QMessageBoxPrivate::helperPrepareShow(QPlatformDialogHelper *) options->setWindowTitle(q->windowTitle()); options->setText(q->text()); options->setInformativeText(q->informativeText()); +#if QT_CONFIG(textedit) options->setDetailedText(q->detailedText()); +#endif options->setIcon(helperIcon(q->icon())); options->setStandardButtons(helperStandardButtons(q)); } From 0f6cfd2217163e5851d16d3c0846d6dc37624762 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 11:16:50 +0100 Subject: [PATCH 239/304] Fix build with -no-feature-slider Change-Id: I36e5c850068c2f9ac2ae078a3734ddb88d88c532 Reviewed-by: Lars Knoll --- src/widgets/accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/rangecontrols_p.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index dfc8c84836..da184fd90d 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -94,9 +94,9 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QScrollBar")) { iface = new QAccessibleScrollBar(widget); #endif +#ifndef QT_NO_SLIDER } else if (classname == QLatin1String("QAbstractSlider")) { iface = new QAccessibleAbstractSlider(widget); -#ifndef QT_NO_SLIDER } else if (classname == QLatin1String("QSlider")) { iface = new QAccessibleSlider(widget); #endif diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h index 28f613462d..c0b010c292 100644 --- a/src/widgets/accessible/rangecontrols_p.h +++ b/src/widgets/accessible/rangecontrols_p.h @@ -143,6 +143,7 @@ protected: }; #endif // QT_NO_SPINBOX +#if QT_CONFIG(slider) class QAccessibleAbstractSlider: public QAccessibleWidget, public QAccessibleValueInterface { public: @@ -159,6 +160,7 @@ public: protected: QAbstractSlider *abstractSlider() const; }; +#endif // QT_CONFIG(slider) #ifndef QT_NO_SCROLLBAR class QAccessibleScrollBar : public QAccessibleAbstractSlider From 624b67c6fb3c833ffe94cc2a52a2d1164eef839e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 12:01:01 +0100 Subject: [PATCH 240/304] Fix build with -no-feature-tabwidget Change-Id: I0fbabdfec763f1647bf85582afe088a3e5b42e1f Reviewed-by: Lars Knoll --- src/widgets/widgets/qmainwindowlayout.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 9e1af16625..8eb1eaec18 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1021,7 +1021,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, } } break; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabwidget) case QDockAreaLayout::FloatingDockWidgetTabMarker: { auto dockWidgets = allMyDockWidgets(mainWindow); @@ -1045,7 +1045,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, floatingTab->show(); } break; -#endif // QT_NO_TABBAR +#endif // QT_CONFIG(tabwidget) #endif // QT_NO_DOCKWIDGET #ifndef QT_NO_TOOLBAR @@ -2012,7 +2012,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) dwgw->layoutInfo()->remove(path); } currentGapRect = QRect(); - +#if QT_CONFIG(tabwidget) if (QDockWidget *dropTo = qobject_cast(currentHoveredFloat)) { //dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two tabs QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow(); @@ -2030,7 +2030,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) dropTo->d_func()->plug(QRect()); currentHoveredFloat = floatingTabs; } - +#endif // QT_CONFIG(tabwidget) QDockWidgetGroupWindow *dwgw = qobject_cast(currentHoveredFloat); Q_ASSERT(dwgw); Q_ASSERT(dwgw->layoutInfo()->tabbed); // because floating group should always be tabbed @@ -2362,7 +2362,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) if (QDockWidget *dw = qobject_cast(widget)) { Q_ASSERT(path.constFirst() == 1); bool actualGroup = false; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabwidget) if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3) { QDockAreaLayoutItem &parentItem = layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2)); if (parentItem.subinfo && parentItem.subinfo->tabbed) { @@ -2383,7 +2383,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) savedState = layoutState; } } -#endif // QT_NO_TABBAR +#endif // QT_CONFIG(tabwidget) if (!actualGroup) { dw->d_func()->unplug(r); } @@ -2554,7 +2554,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) updateGapIndicator(); } -#if QT_CONFIG(dockwidget) +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow() { QDockWidgetGroupWindow* f = new QDockWidgetGroupWindow(parentWidget(), Qt::Tool); @@ -2565,8 +2565,7 @@ QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow() void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animate) { -#ifndef QT_NO_DOCKWIDGET -#ifndef QT_NO_TABBAR +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) QSet used = newState.dockAreaLayout.usedTabBars(); foreach (QDockWidgetGroupWindow *dwgw, parent()->findChildren(QString(), Qt::FindDirectChildrenOnly)) { @@ -2594,8 +2593,7 @@ void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animat for (int i = 0; i < QInternal::DockCount; ++i) newState.dockAreaLayout.docks[i].reparentWidgets(parentWidget()); -#endif // QT_NO_TABBAR -#endif // QT_NO_DOCKWIDGET +#endif // QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) newState.apply(dockOptions & QMainWindow::AnimatedDocks && animate); } From b0b726f8c7d8b17853962262fefd6e0b56de2b92 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 12:09:51 +0100 Subject: [PATCH 241/304] Fix build with -no-feature-tabbar Change-Id: I97c5345f2627743876aa05a94ffc03f2a6012b6c Reviewed-by: Lars Knoll --- src/widgets/widgets/qdockarealayout.cpp | 2 ++ src/widgets/widgets/qmainwindowlayout.cpp | 25 +++++++++++++++++++---- src/widgets/widgets/qmainwindowlayout_p.h | 2 +- src/widgets/widgets/qmdiarea.cpp | 2 ++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index ad19e5d5f9..30eaa73b9e 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -3175,6 +3175,7 @@ void QDockAreaLayout::resizeDocks(const QList &docks, while (path.size() > 1) { QDockAreaLayoutInfo *info = this->info(path); +#if QT_CONFIG(tabbar) if (!info->tabbed && info->o == o) { info->item_list[path.constLast()].size = size; int totalSize = 0; @@ -3187,6 +3188,7 @@ void QDockAreaLayout::resizeDocks(const QList &docks, } size = totalSize; } +#endif // QT_CONFIG(tabbar) path.removeLast(); } diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 8eb1eaec18..72e06e4efa 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -125,8 +125,11 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayoutInfo &layout, QSt << layout.rect.height() << " min size: " << minSize.width() << ',' << minSize.height() << " orient:" << layout.o +#if QT_CONFIG(tabbar) << " tabbed:" << layout.tabbed - << " tbshape:" << layout.tabBarShape << '\n'; + << " tbshape:" << layout.tabBarShape +#endif + << '\n'; indent += QLatin1String(" "); @@ -226,7 +229,9 @@ public: if (li->isEmpty()) return; int fw = frameWidth(); +#if QT_CONFIG(tabbar) li->reparentWidgets(parentWidget()); +#endif li->rect = r.adjusted(fw, fw, -fw, -fw); li->fitItems(); li->apply(false); @@ -317,6 +322,7 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const { QDockAreaLayoutInfo *info = layoutInfo(); QDockWidget *dw = 0; +#if QT_CONFIG(tabbar) if (info->tabBar && info->tabBar->currentIndex() >= 0) { int i = info->tabIndexToListIndex(info->tabBar->currentIndex()); if (i >= 0) { @@ -325,6 +331,7 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const dw = qobject_cast(item.widgetItem->widget()); } } +#endif if (!dw) { for (int i = 0; !dw && i < info->item_list.count(); ++i) { const QDockAreaLayoutItem &item = info->item_list.at(i); @@ -373,8 +380,10 @@ void QDockWidgetGroupWindow::destroyOrHideIfEmpty() if (!wasHidden) dw->show(); } +#if QT_CONFIG(tabbar) foreach (QTabBar *tb, findChildren(QString(), Qt::FindDirectChildrenOnly)) tb->setParent(parentWidget()); +#endif deleteLater(); } @@ -1802,10 +1811,10 @@ bool QMainWindowLayout::endSeparatorMove(const QPoint&) void QMainWindowLayout::raise(QDockWidget *widget) { +#ifndef QT_NO_TABBAR QDockAreaLayoutInfo *info = dockInfo(widget); if (info == 0) return; -#ifndef QT_NO_TABBAR if (!info->tabbed) return; info->setCurrentTab(widget); @@ -2031,6 +2040,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) currentHoveredFloat = floatingTabs; } #endif // QT_CONFIG(tabwidget) +#if QT_CONFIG(tabbar) QDockWidgetGroupWindow *dwgw = qobject_cast(currentHoveredFloat); Q_ASSERT(dwgw); Q_ASSERT(dwgw->layoutInfo()->tabbed); // because floating group should always be tabbed @@ -2042,6 +2052,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) globalRect.moveTopLeft(dwgw->mapToGlobal(globalRect.topLeft())); pluggingWidget = widget; widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks); +#endif // QT_CONFIG(tabbar) return true; } #endif @@ -2120,7 +2131,9 @@ void QMainWindowLayout::animationFinished(QWidget *widget) if (QDockWidgetGroupWindow *dropTo = qobject_cast(currentHoveredFloat)) { parentInfo = dropTo->layoutInfo(); +#if QT_CONFIG(tabbar) Q_ASSERT(parentInfo->tabbed); +#endif path = parentInfo->indexOf(widget); Q_ASSERT(path.size() == 1); } else { @@ -2129,7 +2142,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) parentInfo = layoutState.dockAreaLayout.info(path); Q_ASSERT(parentInfo); } - +#if QT_CONFIG(tabbar) if (parentInfo->tabbed) { // merge the two tab widgets int idx = path.constLast(); @@ -2143,15 +2156,19 @@ void QMainWindowLayout::animationFinished(QWidget *widget) parentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data() : parentWidget()); parentInfo->updateTabBar(); parentInfo->setCurrentTabId(currentId); - } else { + } else +#endif // QT_CONFIG(tabbar) + { QDockAreaLayoutItem &item = layoutState.dockAreaLayout.item(path); Q_ASSERT(item.widgetItem->widget() == dwgw); delete item.widgetItem; item.widgetItem = 0; item.subinfo = new QDockAreaLayoutInfo(qMove(*info)); *info = QDockAreaLayoutInfo(); +#if QT_CONFIG(tabbar) item.subinfo->reparentWidgets(parentWidget()); item.subinfo->setTabBarShape(parentInfo->tabBarShape); +#endif } dwgw->destroyOrHideIfEmpty(); } diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 40336caeba..857a05eb8e 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -231,9 +231,9 @@ public: void raise(QDockWidget *widget); void setVerticalTabsEnabled(bool enabled); bool restoreDockWidget(QDockWidget *dockwidget); - QDockAreaLayoutInfo *dockInfo(QWidget *w); #ifndef QT_NO_TABBAR + QDockAreaLayoutInfo *dockInfo(QWidget *w); bool _documentMode; bool documentMode() const; void setDocumentMode(bool enabled); diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 6b23e22bc1..18cb823702 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1539,9 +1539,11 @@ void QMdiAreaPrivate::showRubberBandFor(QMdiSubWindow *subWindow) if (!subWindow || !rubberBand) return; +#if QT_CONFIG(tabbar) if (viewMode == QMdiArea::TabbedView) rubberBand->setGeometry(tabBar->tabRect(childWindows.indexOf(subWindow))); else +#endif rubberBand->setGeometry(subWindow->geometry()); rubberBand->raise(); From 033fa96b6c89cc1be5cb2365e68bd1b01f91aad7 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 13:23:08 +0100 Subject: [PATCH 242/304] Fix build with -no-feature-toolbutton Change-Id: I16495548fa3ed24409883fadab08ddb8545efd0d Reviewed-by: Lars Knoll --- src/widgets/widgets/qlineedit.cpp | 2 ++ src/widgets/widgets/qlineedit_p.cpp | 9 ++++++++- src/widgets/widgets/qlineedit_p.h | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index ffe1ca1c66..e5e832ab98 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -2195,10 +2195,12 @@ void QLineEdit::changeEvent(QEvent *ev) update(); break; case QEvent::LayoutDirectionChange: +#if QT_CONFIG(toolbutton) for (const auto &e : d->trailingSideWidgets) { // Refresh icon to show arrow in right direction. if (e.flags & QLineEditPrivate::SideWidgetClearButton) static_cast(e.widget)->setIcon(d->clearButtonIcon()); } +#endif d->positionSideWidgets(); break; default: diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 7da1d911ee..9947d63279 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -313,6 +313,8 @@ void QLineEditPrivate::drag() #endif // QT_NO_DRAGANDDROP + +#if QT_CONFIG(toolbutton) QLineEditIconButton::QLineEditIconButton(QWidget *parent) : QToolButton(parent) , m_opacity(0) @@ -390,6 +392,7 @@ void QLineEditIconButton::updateCursor() setCursor(qFuzzyCompare(m_opacity, qreal(1.0)) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor()); #endif } +#endif // QT_CONFIG(toolbutton) void QLineEditPrivate::_q_textChanged(const QString &text) { @@ -397,7 +400,7 @@ void QLineEditPrivate::_q_textChanged(const QString &text) const int newTextSize = text.size(); if (!newTextSize || !lastTextSize) { lastTextSize = newTextSize; -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) && QT_CONFIG(toolbutton) const bool fadeIn = newTextSize > 0; for (const SideWidgetEntry &e : leadingSideWidgets) { if (e.flags & SideWidgetFadeInWithText) @@ -507,6 +510,7 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE flags |= SideWidgetCreatedByWidgetAction; } if (!w) { +#if QT_CONFIG(toolbutton) QLineEditIconButton *toolButton = new QLineEditIconButton(q); toolButton->setIcon(newAction->icon()); toolButton->setOpacity(lastTextSize > 0 || !(flags & SideWidgetFadeInWithText) ? 1 : 0); @@ -514,6 +518,9 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE QObject::connect(toolButton, SIGNAL(clicked()), q, SLOT(_q_clearButtonClicked())); toolButton->setDefaultAction(newAction); w = toolButton; +#else + return nullptr; +#endif } // If there is a 'before' action, it takes preference PositionIndexPair positionIndex = before ? findSideWidget(before) : PositionIndexPair(position, -1); diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 0a08aefab3..a903c003e6 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE class QLineEditPrivate; // QLineEditIconButton: This is a simple helper class that represents clickable icons that fade in with text - +#if QT_CONFIG(toolbutton) class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton { Q_OBJECT @@ -103,6 +103,7 @@ private: qreal m_opacity; }; +#endif // QT_CONFIG(toolbutton) class Q_AUTOTEST_EXPORT QLineEditPrivate : public QWidgetPrivate { From 08e8a02e518938261100f493eac8023597a2cc2b Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 13:29:15 +0100 Subject: [PATCH 243/304] Compile with -no-feature-tooltip Change-Id: I6093559dd7b8df578ebd050655fb9bd07e5f6809 Reviewed-by: Lars Knoll --- src/widgets/accessible/complexwidgets.cpp | 2 ++ src/widgets/accessible/simplewidgets.cpp | 2 ++ src/widgets/util/qsystemtrayicon_x11.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 463019dbd0..32ac732eb2 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -130,9 +130,11 @@ public: case QAccessible::Accelerator: str = qt_accHotKey(m_parent->tabText(m_index)); break; +#if QT_CONFIG(tooltip) case QAccessible::Description: str = m_parent->tabToolTip(m_index); break; +#endif case QAccessible::Help: str = m_parent->tabWhatsThis(m_index); break; diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 0cfa9bfbb2..a806cb7af6 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -550,9 +550,11 @@ QString QAccessibleGroupBox::text(QAccessible::Text t) const case QAccessible::Name: txt = qt_accStripAmp(groupBox()->title()); break; +#if QT_CONFIG(tooltip) case QAccessible::Description: txt = groupBox()->toolTip(); break; +#endif case QAccessible::Accelerator: txt = qt_accHotKey(groupBox()->title()); break; diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index ea0604b6ed..0bde31fd61 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -104,7 +104,9 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) , q(qIn) { setObjectName(QStringLiteral("QSystemTrayIconSys")); +#if QT_CONFIG(tooltip) setToolTip(q->toolTip()); +#endif setAttribute(Qt::WA_AlwaysShowToolTips, true); setAttribute(Qt::WA_QuitOnClose, false); const QSize size(22, 22); // Gnome, standard size From da21d20b85e4ab4e27ff620626fae52adced4af2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 13:36:14 +0100 Subject: [PATCH 244/304] Fix build with -no-feature-treewidget Make sure the feature is defined before testing it. Change-Id: I4d4b555c9f2629c8a3ca58cf52efff279f6a78f5 Reviewed-by: Lars Knoll --- src/widgets/itemviews/qtreewidgetitemiterator_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/itemviews/qtreewidgetitemiterator_p.h b/src/widgets/itemviews/qtreewidgetitemiterator_p.h index 4b6c7b0a57..e68f6103d3 100644 --- a/src/widgets/itemviews/qtreewidgetitemiterator_p.h +++ b/src/widgets/itemviews/qtreewidgetitemiterator_p.h @@ -53,8 +53,8 @@ #include -#ifndef QT_NO_TREEWIDGET #include "qtreewidgetitemiterator.h" +#if QT_CONFIG(treewidget) QT_BEGIN_NAMESPACE @@ -103,6 +103,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_TREEWIDGET +#endif // QT_CONFIG(treewidget) #endif //QTREEWIDGETITEMITERATOR_P_H From 195298326f0d8aa75e7034a11c13060b81435855 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 25 Jan 2017 13:52:44 +0100 Subject: [PATCH 245/304] Fix build with -no-feature-whatsthis Change-Id: I2f31357e91b01f826ef44710f477b80fde1f3fbf Reviewed-by: Lars Knoll --- src/widgets/accessible/complexwidgets.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 32ac732eb2..ea3b88468b 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -135,9 +135,11 @@ public: str = m_parent->tabToolTip(m_index); break; #endif +#if QT_CONFIG(whatsthis) case QAccessible::Help: str = m_parent->tabWhatsThis(m_index); break; +#endif default: break; } From d3671555cc013df266a33a256100610d30681dfd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 24 Jan 2017 13:36:09 -0800 Subject: [PATCH 246/304] Rename "interface" to "iface:" there's a #define in windows.h Change-Id: Ibe5b1b60c6ea47e19612fffd149cd2d07116584b Reviewed-by: Jake Petroules --- src/plugins/bearer/qnetworksession_impl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp index 7756709e55..847479047f 100644 --- a/src/plugins/bearer/qnetworksession_impl.cpp +++ b/src/plugins/bearer/qnetworksession_impl.cpp @@ -210,10 +210,10 @@ QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const if (!engine || state != QNetworkSession::Connected || !publicConfig.isValid()) return QNetworkInterface(); - QString interface = engine->getInterfaceFromId(activeConfig.identifier()); - if (interface.isEmpty()) + QString iface = engine->getInterfaceFromId(activeConfig.identifier()); + if (iface.isEmpty()) return QNetworkInterface(); - return QNetworkInterface::interfaceFromName(interface); + return QNetworkInterface::interfaceFromName(iface); } #endif From 374a173d1417a9f8c313088420cb1b792fe45977 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Jan 2017 15:14:45 +0100 Subject: [PATCH 247/304] Improve QTest::qWait() precision and switch to QDeadlineTimer Do not wait up to the timeout ms after already having waited several times. At the same time upgrade to using the QDeadlineTimer which is designed for this purpose. Change-Id: Iaf5e4f4655605d5143ce91040c6eb6706752e504 Reviewed-by: Thiago Macieira --- src/testlib/qtestsystem.h | 36 +++++++++---------- .../corelib/tools/qtimeline/tst_qtimeline.cpp | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index 4973412f9b..b38cd2bdb4 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -42,7 +42,7 @@ #include #include -#include +#include #ifdef QT_GUI_LIB # include #endif @@ -58,27 +58,29 @@ namespace QTest { Q_ASSERT(QCoreApplication::instance()); - QElapsedTimer timer; - timer.start(); + QDeadlineTimer timer(ms); + int remaining = ms; do { - QCoreApplication::processEvents(QEventLoop::AllEvents, ms); + QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); - QTest::qSleep(10); - } while (timer.elapsed() < ms); + remaining = timer.remainingTime(); + if (remaining <= 0) + break; + QTest::qSleep(qMin(10, remaining)); + remaining = timer.remainingTime(); + } while (remaining > 0); } #ifdef QT_GUI_LIB inline static bool qWaitForWindowActive(QWindow *window, int timeout = 5000) { - QElapsedTimer timer; - timer.start(); - while (!window->isActive()) { - int remaining = timeout - int(timer.elapsed()); - if (remaining <= 0) - break; + QDeadlineTimer timer(timeout); + int remaining = timeout; + while (!window->isActive() && remaining > 0) { QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); QTest::qSleep(10); + remaining = timer.remainingTime(); } // Try ensuring the platform window receives the real position. // (i.e. that window->pos() reflects reality) @@ -99,15 +101,13 @@ namespace QTest inline static bool qWaitForWindowExposed(QWindow *window, int timeout = 5000) { - QElapsedTimer timer; - timer.start(); - while (!window->isExposed()) { - int remaining = timeout - int(timer.elapsed()); - if (remaining <= 0) - break; + QDeadlineTimer timer(timeout); + int remaining = timeout; + while (!window->isExposed() && remaining > 0) { QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); QTest::qSleep(10); + remaining = timer.remainingTime(); } return window->isExposed(); } diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index 383f357206..b68c582732 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -189,7 +189,7 @@ void tst_QTimeLine::frameRate() void tst_QTimeLine::value() { - QTimeLine timeLine(5000); + QTimeLine timeLine(4500); // Should be at least 5% under 5000ms QCOMPARE(timeLine.currentValue(), 0.0); // Default speed From f823af43f243b1848fd4a838847317d0ff6d4fdf Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 10 Nov 2016 14:57:04 +0100 Subject: [PATCH 248/304] QVariant of nullptr should always be null Implements isNull for QVariants of a nullptr so they always return true to isNull(), instead of depending on how they were constructed. Task-number: QTBUG-58296 Change-Id: Ibddec795cdadedef7e17d22c265c29e752d8f99f Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qvariant_p.h | 22 ++++++++++++++++++- .../corelib/kernel/qvariant/tst_qvariant.cpp | 11 ++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index bf88def438..487949431c 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -177,6 +177,26 @@ inline void v_clear(QVariant::Private *d, T* = 0) } +template +struct PrimitiveIsNull +{ +public: + static bool isNull(const QVariant::Private *d) + { + return d->is_null; + } +}; + +template <> +struct PrimitiveIsNull +{ +public: + static bool isNull(const QVariant::Private *) + { + return true; + } +}; + template class QVariantComparator { template::IsAccepted> @@ -268,7 +288,7 @@ class QVariantIsNull { static bool isNull(const QVariant::Private *d) { - return d->is_null; + return PrimitiveIsNull::isNull(d); } }; diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 75fa424ab1..3a51e67768 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -400,6 +400,17 @@ void tst_QVariant::isNull() QVERIFY( !varLL.isNull() ); QVariant var7(QString::null); QVERIFY(var7.isNull()); + var7 = QVariant::fromValue(QString::null); + QVERIFY(var7.isNull()); + + QVariant var8(QMetaType::Nullptr, nullptr); + QVERIFY(var8.isNull()); + var8 = QVariant::fromValue(nullptr); + QVERIFY(var8.isNull()); + QVariant var9 = QVariant(QJsonValue(QJsonValue::Null)); + QVERIFY(var9.isNull()); + var9 = QVariant::fromValue(QJsonValue(QJsonValue::Null)); + QVERIFY(var9.isNull()); } void tst_QVariant::swap() From 4d3a35f63788fa5ff7a11a5bb7bd6176bd2ac70e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 23 Jan 2017 13:42:49 +0100 Subject: [PATCH 249/304] Make wheelScrollLines a QStyleHint The number of lines to scroll on a wheel click have previously been a QPlatformTheme hint and QApplication setting, this patch moves it to QStyleHint so it may be easier read by QGuiApplications. Change-Id: I80673c7b99d78c6407b1202b3742e1cb5fef0583 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qplatformintegration.cpp | 2 ++ src/gui/kernel/qplatformintegration.h | 3 ++- src/gui/kernel/qstylehints.cpp | 31 +++++++++++++++++++++++++ src/gui/kernel/qstylehints.h | 4 ++++ src/widgets/kernel/qapplication.cpp | 14 ++++------- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index fd7f475bee..fe1861e08b 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -409,6 +409,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return QPlatformTheme::defaultThemeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick); case UiEffects: return QPlatformTheme::defaultThemeHint(QPlatformTheme::UiEffects); + case WheelScrollLines: + return QPlatformTheme::defaultThemeHint(QPlatformTheme::WheelScrollLines); } return 0; diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 22a834f0e1..466b3348bd 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -157,7 +157,8 @@ public: TabFocusBehavior, ReplayMousePressOutsidePopup, ItemViewActivateItemOnSingleClick, - UiEffects + UiEffects, + WheelScrollLines, }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 22c077da41..85c0768e35 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -78,6 +78,7 @@ public: , m_cursorFlashTime(-1) , m_tabFocusBehavior(-1) , m_uiEffects(-1) + , m_wheelScrollLines(-1) {} int m_mouseDoubleClickInterval; @@ -88,6 +89,7 @@ public: int m_cursorFlashTime; int m_tabFocusBehavior; int m_uiEffects; + int m_wheelScrollLines; }; /*! @@ -495,4 +497,33 @@ void QStyleHints::setUseHoverEffects(bool useHoverEffects) emit useHoverEffectsChanged(useHoverEffects); } +/*! + \property QStyleHints::wheelScrollLines + \brief Number of lines to scroll by default for each wheel click. + + \since 5.9 +*/ +int QStyleHints::wheelScrollLines() const +{ + Q_D(const QStyleHints); + if (d->m_wheelScrollLines > 0) + return d->m_wheelScrollLines; + return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt(); +} + +/*! + Sets the \a wheelScrollLines. + \internal + \sa wheelScrollLines() + \since 5.9 +*/ +void QStyleHints::setWheelScrollLines(int scrollLines) +{ + Q_D(QStyleHints); + if (d->m_wheelScrollLines == scrollLines) + return; + d->m_wheelScrollLines = scrollLines; + emit wheelScrollLinesChanged(scrollLines); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index fb55cc7ed6..b9bf428edd 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -71,6 +71,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL) Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL) Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL) + Q_PROPERTY(int wheelScrollLines READ wheelScrollLines NOTIFY wheelScrollLinesChanged FINAL) public: void setMouseDoubleClickInterval(int mouseDoubleClickInterval); @@ -99,6 +100,8 @@ public: bool singleClickActivation() const; bool useHoverEffects() const; void setUseHoverEffects(bool useHoverEffects); + int wheelScrollLines() const; + void setWheelScrollLines(int scrollLines); Q_SIGNALS: void cursorFlashTimeChanged(int cursorFlashTime); @@ -109,6 +112,7 @@ Q_SIGNALS: void startDragTimeChanged(int startDragTime); void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior); void useHoverEffectsChanged(bool useHoverEffects); + void wheelScrollLinesChanged(int scrollLines); private: friend class QGuiApplication; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6258605a65..84891be7f8 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -408,7 +408,6 @@ QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input foc QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show() QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus #ifndef QT_NO_WHEELEVENT -int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll QPointer QApplicationPrivate::wheel_widget; #endif bool qt_in_tab_key_event = false; @@ -642,19 +641,12 @@ void QApplicationPrivate::initialize() if (qEnvironmentVariableIntValue("QT_USE_NATIVE_WINDOWS") > 0) QCoreApplication::setAttribute(Qt::AA_NativeWindows); -#ifndef QT_NO_WHEELEVENT - QApplicationPrivate::wheel_scroll_lines = 3; -#endif - if (qt_is_gui_used) initializeMultitouch(); if (QApplication::desktopSettingsAware()) if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt(); -#ifndef QT_NO_WHEELEVENT - QApplicationPrivate::wheel_scroll_lines = theme->themeHint(QPlatformTheme::WheelScrollLines).toInt(); -#endif } is_app_running = true; // no longer starting up @@ -4049,16 +4041,18 @@ int QApplication::keyboardInputInterval() or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}. By default, this property has a value of 3. + + \sa QStyleHints::wheelScrollLines() */ #ifndef QT_NO_WHEELEVENT int QApplication::wheelScrollLines() { - return QApplicationPrivate::wheel_scroll_lines; + return styleHints()->wheelScrollLines(); } void QApplication::setWheelScrollLines(int lines) { - QApplicationPrivate::wheel_scroll_lines = lines; + styleHints()->setWheelScrollLines(lines); } #endif From 51dafeda8c833134acf7da40f7ad58cec349ee30 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 25 Jan 2017 07:22:04 -0800 Subject: [PATCH 250/304] linux-icc: always compile applications as position-independent execs The problem isn't the compiler, but the linker, so we ought to turn this flag on for all ELF-based systems where we compile Qt with -Bsymbolic, but so far only the Intel compiler has been affected. We can turn it on as needed for other systems. The cause of the problem is the way that ICC materializes the pointer- to-member-function: it stores the full 2*sizeof(void*) data in an anonymous variable, so that it can load it in one go, such as one 16- byte SSE aligned load on 64-bit systems. That relocation in a data variable gets turned into a fixed-position copy relocation by the linker, which breaks the signal-identification mechanism. GCC and Clang are likely to be affected if anyone did: static const auto destroyed = &QObject::destroyed; QObject::connect(obj, destroyed, [](){}); Task-number: QTBUG-52439 Change-Id: I0d69eaf61af149db9574fffd149d0cfb08459c33 Reviewed-by: Olivier Goffart (Woboq GmbH) --- mkspecs/linux-icc/qmake.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf index 2c66e80db4..8ca2767061 100644 --- a/mkspecs/linux-icc/qmake.conf +++ b/mkspecs/linux-icc/qmake.conf @@ -79,6 +79,7 @@ QMAKE_LINK = icpc QMAKE_LINK_SHLIB = icpc QMAKE_LFLAGS = QMAKE_LFLAGS_RELEASE = +QMAKE_LFLAGS_APP = -pie QMAKE_LFLAGS_DEBUG = QMAKE_LFLAGS_SHLIB = -shared -shared-intel QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB From deef2d4e70c54ffe71304575e56095dd25cd55eb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Jan 2017 14:04:14 -0800 Subject: [PATCH 251/304] Fix warning about not calling the base class copy constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit error: base class ‘class QBasicAtomicPointer’ should be explicitly initialized in the copy constructor [-Werror=extra] Change-Id: I2bc52f3c7a574209b213fffd149b4b71f3006be5 Reviewed-by: Marc Mutz --- src/corelib/thread/qatomic.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index bbfc11f6c0..f9eacbf6f0 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -176,6 +176,9 @@ public: } #endif inline QAtomicPointer(const QAtomicPointer &other) Q_DECL_NOTHROW +#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS + : QBasicAtomicPointer() +#endif { this->storeRelease(other.loadAcquire()); } From dcfeeef91ef17f15adb3f961f1abce3ef169b263 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Jan 2017 14:01:00 -0800 Subject: [PATCH 252/304] Remove the -no-rtti option from configure It only applied to Windows (not MSVC, like the help said) and the build was broken with this option. So remove it, as we clearly never test this. [ChangeLog][Windows] The -no-rtti configure option was removed, as Qt 5.8 fails to build under that condition. To disable RTTI on user code, add to your .pro file: CONFIG += rtti_off. Change-Id: I2bc52f3c7a574209b213fffd149aae1b8d0cf9df Reviewed-by: Oswald Buddenhagen --- config_help.txt | 1 - configure.json | 7 ------- mkspecs/features/win32/default_pre.prf | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/config_help.txt b/config_help.txt index f711a01cb8..5ebeaf5af3 100644 --- a/config_help.txt +++ b/config_help.txt @@ -99,7 +99,6 @@ Build options: -c++std .... Select C++ standard [c++1z/c++14/c++11] (Not supported with MSVC) - -rtti ................ Build with Runtime Type Information [yes] (MSVC only) -sse2 ................ Use SSE2 instructions [auto] -sse3/-ssse3/-sse4.1/-sse4.2/-avx/-avx2/-avx512 diff --git a/configure.json b/configure.json index f9abdae8ca..7d04f0a516 100644 --- a/configure.json +++ b/configure.json @@ -107,7 +107,6 @@ "reduce-relocations": { "type": "boolean", "name": "reduce_relocations" }, "release": { "type": "enum", "name": "debug", "values": { "yes": "no", "no": "yes" } }, "rpath": "boolean", - "rtti": "boolean", "sanitize": "sanitize", "sdk": "string", "separate-debug-info": { "type": "boolean", "name": "separate_debug_info" }, @@ -554,12 +553,6 @@ "autoDetect": false, "output": [ { "type": "varAppend", "name": "EXTRA_RPATHS", "value": "input.rpaths" } ] }, - "rtti": { - "label": "Build with RTTI", - "comment": "mkspecs/features/win32/default_pre.prf sets no-rtti. Follow default behavior of configure.exe by overriding with rtti.", - "condition": "config.win32", - "output": [ "publicConfig" ] - }, "force_asserts": { "label": "Force assertions", "autoDetect": false, diff --git a/mkspecs/features/win32/default_pre.prf b/mkspecs/features/win32/default_pre.prf index bdb72c0d89..a9b247e113 100644 --- a/mkspecs/features/win32/default_pre.prf +++ b/mkspecs/features/win32/default_pre.prf @@ -1,2 +1,2 @@ -CONFIG = rtti_off incremental_off windows $$CONFIG +CONFIG = incremental_off windows $$CONFIG load(default_pre) From dfd7a0e41153315625883619a4abe84db1d29769 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 19 Dec 2016 11:28:40 -0800 Subject: [PATCH 253/304] Doc: add a note that UniqueConnection does not work for lambdas Task-number: QTBUG-52438 Change-Id: I3e4e5051937c40319d6efffd1491bef6feb6776e Reviewed-by: Martin Smith Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 63b02d2c0c..c44e4b16b1 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2614,6 +2614,9 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM (exact same signal to the exact same slot on the same objects), the connection will fail and connect will return an invalid QMetaObject::Connection. + \note Qt::UniqueConnections do not work for lambdas, non-member functions + and functors; they only apply to connecting to member functions. + The optional \a type parameter describes the type of connection to establish. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery @@ -4665,7 +4668,10 @@ void qDeleteInEventHandler(QObject *o) Creates a connection of a given \a type from \a signal in \a sender object to \a functor to be placed in a specific event - loop of \a context, and returns a handle to the connection + loop of \a context, and returns a handle to the connection. + + \note Qt::UniqueConnections do not work for lambdas, non-member functions + and functors; they only apply to connecting to member functions. The signal must be a function declared as a signal in the header. The slot function can be any function or functor that can be connected From 3b8f3fb327fd80217e1caf7fbb8d2d41576edc3b Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 25 Jan 2017 20:19:43 +0200 Subject: [PATCH 254/304] QEventDispatcherWin32: remove tailings of Windows CE code It was automatically merged from 5.6 branch. Qt 5.8 does not support Windows CE. Change-Id: I6968f50ef568035c224851d595d6c057128491a7 Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qeventdispatcher_win.cpp | 22 --------------------- src/corelib/kernel/qeventdispatcher_win_p.h | 2 -- 2 files changed, 24 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 1a0efae2dc..88dbe8e4f7 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -96,9 +96,7 @@ QEventDispatcherWin32Private::QEventDispatcherWin32Private() : threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0), getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0), wakeUps(0) -#ifndef Q_OS_WINCE , activateNotifiersPosted(false) -#endif { } @@ -179,11 +177,9 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA QSockNot *sn = dict ? dict->value(wp) : 0; if (sn) { -#ifndef Q_OS_WINCE d->doWsaAsyncSelect(sn->fd, 0); d->active_fd[sn->fd].selected = false; d->postActivateSocketNotifiers(); -#endif if (type < 3) { QEvent event(QEvent::SockAct); QCoreApplication::sendEvent(sn->obj, &event); @@ -194,7 +190,6 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA } } return 0; -#ifndef Q_OS_WINCE } else if (message == WM_QT_ACTIVATENOTIFIERS) { Q_ASSERT(d != 0); @@ -209,7 +204,6 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA } d->activateNotifiersPosted = false; return 0; -#endif // !Q_OS_WINCE } else if (message == WM_QT_SENDPOSTEDEVENTS // we also use a Windows timer to send posted events when the message queue is full || (message == WM_TIMER @@ -444,13 +438,11 @@ void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket, long event) WSAAsyncSelect(socket, internalHwnd, event ? int(WM_QT_SOCKETNOTIFIER) : 0, event); } -#ifndef Q_OS_WINCE void QEventDispatcherWin32Private::postActivateSocketNotifiers() { if (!activateNotifiersPosted) activateNotifiersPosted = PostMessage(internalHwnd, WM_QT_ACTIVATENOTIFIERS, 0, 0); } -#endif // !Q_OS_WINCE void QEventDispatcherWin32::createInternalHwnd() { @@ -704,22 +696,16 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier) QSFDict::iterator it = d->active_fd.find(sockfd); if (it != d->active_fd.end()) { QSockFd &sd = it.value(); -#ifndef Q_OS_WINCE if (sd.selected) { d->doWsaAsyncSelect(sockfd, 0); sd.selected = false; } -#endif // !Q_OS_WINCE sd.event |= event; } else { d->active_fd.insert(sockfd, QSockFd(event)); } -#ifndef Q_OS_WINCE d->postActivateSocketNotifiers(); -#else - d->doWsaAsyncSelect(sockfd, event); -#endif } void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier) @@ -748,7 +734,6 @@ void QEventDispatcherWin32::doUnregisterSocketNotifier(QSocketNotifier *notifier QSFDict::iterator it = d->active_fd.find(sockfd); if (it != d->active_fd.end()) { QSockFd &sd = it.value(); -#ifndef Q_OS_WINCE if (sd.selected) d->doWsaAsyncSelect(sockfd, 0); const long event[3] = { FD_READ | FD_CLOSE | FD_ACCEPT, FD_WRITE | FD_CONNECT, FD_OOB }; @@ -759,13 +744,6 @@ void QEventDispatcherWin32::doUnregisterSocketNotifier(QSocketNotifier *notifier sd.selected = false; d->postActivateSocketNotifiers(); } -#else - const long event[3] = { FD_READ | FD_CLOSE | FD_ACCEPT, FD_WRITE | FD_CONNECT, FD_OOB }; - sd.event ^= event[type]; - d->doWsaAsyncSelect(sockfd, sd.event); - if (sd.event == 0) - d->active_fd.erase(it); -#endif // !Q_OS_WINCE } QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index 773315c04f..df1513a43a 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -185,10 +185,8 @@ public: QSNDict sn_write; QSNDict sn_except; QSFDict active_fd; -#ifndef Q_OS_WINCE bool activateNotifiersPosted; void postActivateSocketNotifiers(); -#endif void doWsaAsyncSelect(int socket, long event); QList winEventNotifierList; From ffecbfc980c97290a66a2b569ee663c97c8c1298 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 24 Jan 2017 21:13:41 +0100 Subject: [PATCH 255/304] Re-enable shader disk cache for Integrity Task-number: QTBUG-58183 Change-Id: Ic1be5db6922259cbef867720e95261d46a5ccaef Reviewed-by: Kimmo Ollila Reviewed-by: Andy Nichols --- src/gui/opengl/qopenglshaderprogram.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 0d0f40efee..c9552fd321 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -3739,11 +3739,6 @@ QOpenGLProgramBinarySupportCheck::QOpenGLProgramBinarySupportCheck(QOpenGLContex : QOpenGLSharedResource(context->shareGroup()), m_supported(false) { -// Shader cache is disabled for INTEGRITY as the driver doesn't handle -// unaligned data. -#if defined(Q_OS_INTEGRITY) - return; -#endif if (QCoreApplication::testAttribute(Qt::AA_DisableShaderDiskCache)) { qCDebug(DBG_SHADER_CACHE, "Shader cache disabled via app attribute"); return; From 17e672a67ed2ba6c8ec3952ff4ab255cb45fcce6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 11 Nov 2016 13:33:20 +0100 Subject: [PATCH 256/304] Use QImage::reinterpretAsFormat in QPixmap Use the new QImage method instead of operating on private API. At the same time the code is improved to ensure the QImage is detached. Change-Id: Ia015c0bb18d7bc62da38397594730254843e5a0d Reviewed-by: Eirik Aavitsland --- src/gui/image/qpixmap_raster.cpp | 23 ++++++---------- src/gui/image/qpixmap_raster_p.h | 2 +- tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 28 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 741f7713da..54a5b94840 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -135,7 +134,7 @@ bool QRasterPlatformPixmap::fromData(const uchar *buffer, uint len, const char * if (image.isNull()) return false; - createPixmapForImage(image, flags, /* inplace = */true); + createPixmapForImage(std::move(image), flags); return !isNull(); } @@ -143,13 +142,13 @@ void QRasterPlatformPixmap::fromImage(const QImage &sourceImage, Qt::ImageConversionFlags flags) { QImage image = sourceImage; - createPixmapForImage(image, flags, /* inplace = */false); + createPixmapForImage(std::move(image), flags); } void QRasterPlatformPixmap::fromImageInPlace(QImage &sourceImage, Qt::ImageConversionFlags flags) { - createPixmapForImage(sourceImage, flags, /* inplace = */true); + createPixmapForImage(std::move(sourceImage), flags); } void QRasterPlatformPixmap::fromImageReader(QImageReader *imageReader, @@ -160,7 +159,7 @@ void QRasterPlatformPixmap::fromImageReader(QImageReader *imageReader, if (image.isNull()) return; - createPixmapForImage(image, flags, /* inplace = */true); + createPixmapForImage(std::move(image), flags); } // from qbackingstore.cpp @@ -301,7 +300,7 @@ int QRasterPlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const return 0; } -void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace) +void QRasterPlatformPixmap::createPixmapForImage(QImage sourceImage, Qt::ImageConversionFlags flags) { QImage::Format format; if (flags & Qt::NoFormatConversion) @@ -335,16 +334,10 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC if (format == QImage::Format_RGB32 && (sourceImage.format() == QImage::Format_ARGB32 || sourceImage.format() == QImage::Format_ARGB32_Premultiplied)) { - inPlace = inPlace && sourceImage.isDetached(); - image = sourceImage; - if (!inPlace) - image.detach(); - if (image.d) - image.d->format = QImage::Format_RGB32; - } else if (inPlace && sourceImage.d->convertInPlace(format, flags)) { - image = sourceImage; + image = std::move(sourceImage); + image.reinterpretAsFormat(QImage::Format_RGB32); } else { - image = sourceImage.convertToFormat(format, flags); + image = std::move(sourceImage).convertToFormat(format, flags); } if (image.d) { diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index 95e018eb35..6ea965a324 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -85,7 +85,7 @@ public: protected: int metric(QPaintDevice::PaintDeviceMetric metric) const Q_DECL_OVERRIDE; - void createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace); + void createPixmapForImage(QImage sourceImage, Qt::ImageConversionFlags flags); void setImage(const QImage &image); QImage image; static QImage::Format systemOpaqueFormat(); diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index ad7de09c48..72609d4095 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -99,6 +99,7 @@ private slots: void task_51271(); void convertFromImageNoDetach(); + void convertFromImageNoDetach2(); void convertFromImageDetach(); void convertFromImageCacheKey(); @@ -766,6 +767,33 @@ void tst_QPixmap::convertFromImageNoDetach() QCOMPARE(constOrig.bits(), constCopy.bits()); } +void tst_QPixmap::convertFromImageNoDetach2() +{ + QPixmap randomPixmap(10, 10); + if (randomPixmap.handle()->classId() != QPlatformPixmap::RasterClass) + QSKIP("Test only valid for raster pixmaps"); + + //first get the screen format + QImage::Format screenFormat = randomPixmap.toImage().format(); + QVERIFY(screenFormat != QImage::Format_Invalid); + if (screenFormat != QImage::Format_RGB32 && + screenFormat != QImage::Format_ARGB32_Premultiplied) + QSKIP("Test only valid for platforms with RGB32 pixmaps"); + + QImage orig(100,100, QImage::Format_ARGB32_Premultiplied); + orig.fill(Qt::white); + + const uchar *origBits = orig.constBits(); + + QPixmap pix = QPixmap::fromImage(std::move(orig)); + QImage copy = pix.toImage(); + + QVERIFY(!copy.hasAlphaChannel()); + QCOMPARE(copy.format(), QImage::Format_RGB32); + + QCOMPARE(origBits, copy.constBits()); +} + void tst_QPixmap::convertFromImageDetach() { QImage img(10,10, QImage::Format_RGB32); From fa15162700a18ff243de46954bb613988c199ce7 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 24 Jan 2017 17:06:03 +0100 Subject: [PATCH 257/304] Fix QString comparison on Aarch64 There was an off-by-one error in the while loop for aarch64: we start counting at 0 for the first position, so the last valid input position is "a+7", not 8. This wasn't covered by the tests, nor was the SSE2 version, so now there are also tests for both versions. Change-Id: I7eb8c5708e6179f45ea56885b0e66e1a37969c1d Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/tools/qstring.cpp | 2 +- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index a727f5168c..fb79ab0e47 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -496,7 +496,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l) if (l >= 8) { const QChar *end = a + l; const uint16x8_t mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 }; - while (a + 8 < end) { + while (a + 7 < end) { uint16x8_t da = vld1q_u16(reinterpret_cast(a)); uint16x8_t db = vld1q_u16(reinterpret_cast(b)); diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 414ba2d8cf..6ed7b74277 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -6070,6 +6070,14 @@ void tst_QString::compare_data() lower += QChar(QChar::lowSurrogate(0x10428)); QTest::newRow("data8") << upper << lower << -1 << 0; + QTest::newRow("vectorized-boundaries-7") << QString("1234567") << QString("abcdefg") << -1 << -1; + QTest::newRow("vectorized-boundaries-8") << QString("12345678") << QString("abcdefgh") << -1 << -1; + QTest::newRow("vectorized-boundaries-9") << QString("123456789") << QString("abcdefghi") << -1 << -1; + + QTest::newRow("vectorized-boundaries-15") << QString("123456789012345") << QString("abcdefghiklmnop") << -1 << -1; + QTest::newRow("vectorized-boundaries-16") << QString("1234567890123456") << QString("abcdefghiklmnopq") << -1 << -1; + QTest::newRow("vectorized-boundaries-17") << QString("12345678901234567") << QString("abcdefghiklmnopqr") << -1 << -1; + // embedded nulls // These don't work as of now. It's OK that these don't work since \0 is not a valid unicode /*QTest::newRow("data10") << QString(QByteArray("\0", 1)) << QString(QByteArray("\0", 1)) << 0 << 0; From e0b55e8b1cdfea3dcb22b949632e4f5bcc200a76 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 23 Jan 2017 16:56:29 +0100 Subject: [PATCH 258/304] Make our redirect policies STS-aware This patch changes the way we ensure NoLessSafeRedirectsPolicy and also the way we create actual redirect requests: https->http redirect is now reported as InsecureRedirectError (under NoLessSafeRedirectsPolicy) only if STS is disabled or we were redirected to a host whithout Strict Transport Security policy. Otherwise, we replace 'http' scheme with 'https' and explicitly set port 80 with port 443 as defined by HTTP Strict Transport Security policy. This scheme/port replacement will affect both NoLessSafeRedirectsPolicy and UserVerifiedRedirectsPolicy (SameOriginRedirectsPolicy does not allow any scheme change and we continue to report such redirects as InsecureRedirectError). Change-Id: Ib370b830e5fb6a0fec503d6fa3a0dec771c4b741 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnection.cpp | 11 ++++---- src/network/access/qnetworkreplyhttpimpl.cpp | 28 +++++++++++++++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 327eaf91bc..fd3cbbe36e 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -552,12 +552,11 @@ QUrl QHttpNetworkConnectionPrivate::parseRedirectResponse(QAbstractSocket *socke if (redirectUrl.scheme() == QLatin1String("http") || redirectUrl.scheme() == QLatin1String("https")) { switch (reply->request().redirectsPolicy()) { case QNetworkRequest::NoLessSafeRedirectsPolicy: - // Check if we're doing an unsecure redirect (https -> http) - if (priorUrl.scheme() == QLatin1String("https") - && redirectUrl.scheme() == QLatin1String("http")) { - emitReplyError(socket, reply, QNetworkReply::InsecureRedirectError); - return QUrl(); - } + // Here we could handle https->http redirects as InsecureProtocolError. + // However, if HSTS is enabled and redirectUrl.host() is a known STS + // host, then we'll replace its scheme and this won't downgrade protocol, + // after all. We cannot access QNAM's STS cache from here, so delegate + // this check to QNetworkReplyHttpImpl. break; case QNetworkRequest::SameOriginRedirectsPolicy: if (priorUrl.host() != redirectUrl.host() diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 7d863ef53c..ece08acc6b 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1135,16 +1135,40 @@ void QNetworkReplyHttpImplPrivate::onRedirected(const QUrl &redirectUrl, int htt if (isFinished) return; + const QString schemeBefore(url.scheme()); if (httpRequest.isFollowRedirects()) // update the reply's url as it could've changed url = redirectUrl; - redirectRequest = createRedirectRequest(originalRequest, redirectUrl, maxRedirectsRemaining); + if (managerPrivate->stsEnabled && managerPrivate->stsCache.isKnownHost(url)) { + // RFC6797, 8.3: + // The UA MUST replace the URI scheme with "https" [RFC2818], + // and if the URI contains an explicit port component of "80", + // then the UA MUST convert the port component to be "443", or + // if the URI contains an explicit port component that is not + // equal to "80", the port component value MUST be preserved; + // otherwise, if the URI does not contain an explicit port + // component, the UA MUST NOT add one. + url.setScheme(QLatin1String("https")); + if (url.port() == 80) + url.setPort(443); + } + + const bool isLessSafe = schemeBefore == QLatin1String("https") + && url.scheme() == QLatin1String("http"); + if (httpRequest.redirectsPolicy() == QNetworkRequest::NoLessSafeRedirectsPolicy + && isLessSafe) { + error(QNetworkReply::InsecureRedirectError, + QCoreApplication::translate("QHttp", "Insecure redirect")); + return; + } + + redirectRequest = createRedirectRequest(originalRequest, url, maxRedirectsRemaining); operation = getRedirectOperation(operation, httpStatus); if (httpRequest.redirectsPolicy() != QNetworkRequest::UserVerifiedRedirectsPolicy) followRedirect(); - emit q->redirected(redirectUrl); + emit q->redirected(url); } void QNetworkReplyHttpImplPrivate::followRedirect() From a9603a4088ec055c3d1588c14e09e14bf7e2a0e8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 10:22:59 +0100 Subject: [PATCH 259/304] tst_qgraphicsview: use new QTest::addRow() more ... for calculated test data names. That involved removing the leading ", " from test name literals (folding it into the format string) and porting from some QString code to QByteArray to make the result usable with addRow(), which does not support %ls... Change-Id: Icb2344778203f10939ae46b9e46872101f3878a9 Reviewed-by: Friedemann Kleint Reviewed-by: Edward Welbourne --- .../qgraphicsview/tst_qgraphicsview.cpp | 8 +- .../qgraphicsview/tst_qgraphicsview_2.cpp | 210 +++++++++--------- 2 files changed, 109 insertions(+), 109 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index c8bdcbde09..5ab24d6878 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -2885,7 +2885,7 @@ public: void tst_QGraphicsView::scrollBarRanges() { - QFETCH(QString, style); + QFETCH(QByteArray, style); QFETCH(QSize, viewportSize); QFETCH(QRectF, sceneRect); QFETCH(ScrollBarCount, sceneRectOffsetFactors); @@ -2898,7 +2898,7 @@ void tst_QGraphicsView::scrollBarRanges() QFETCH(ExpectedValueDescription, vmax); QFETCH(bool, useStyledPanel); - if (useStyledPanel && style == QStringLiteral("Macintosh") && platformName == QStringLiteral("cocoa")) + if (useStyledPanel && style == "Macintosh" && platformName == QStringLiteral("cocoa")) QSKIP("Insignificant on OSX"); QScopedPointer stylePtr; @@ -2909,10 +2909,10 @@ void tst_QGraphicsView::scrollBarRanges() view.setTransform(transform); view.setFrameStyle(useStyledPanel ? QFrame::StyledPanel : QFrame::NoFrame); - if (style == QString("motif")) + if (style == "motif") stylePtr.reset(new FauxMotifStyle); else - stylePtr.reset(QStyleFactory::create(style)); + stylePtr.reset(QStyleFactory::create(QLatin1String(style))); view.setStyle(stylePtr.data()); view.setStyleSheet(" "); // enables style propagation ;-) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp index 875f671e76..9550655868 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp @@ -44,9 +44,8 @@ Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(Qt::ScrollBarPolicy) Q_DECLARE_METATYPE(ScrollBarCount) -static void _scrollBarRanges_addTestData(const QString &style, bool styled) +static void _scrollBarRanges_addTestData(const QByteArray &style, bool styled) { - const QString styleString = styled ? style + ", Styled" : style; const int viewWidth = 250; const int viewHeight = 100; @@ -59,7 +58,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription hmin, hmax, vmin, vmax; } data [] = { { - ", 1", + "1", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -71,7 +70,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 2", + "2", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -83,7 +82,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 3", + "3", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -95,7 +94,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 1, 1), }, { - ", 4", + "4", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -107,7 +106,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 5", + "5", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -119,7 +118,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 6", + "6", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -131,7 +130,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 7", + "7", QRectF(0, 0, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -143,7 +142,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1, 1, 1), }, { - ", 8", + "8", QRectF(0, 0, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -155,7 +154,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1, 1, 1), }, { - ", 9", + "9", QRectF(0, 0, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -167,7 +166,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(101, 1, 1), }, { - ", 10", + "10", QRectF(-101, -101, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -179,7 +178,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 11", + "11", QRectF(-101, -101, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -191,7 +190,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 12", + "12", QRectF(-101, -101, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -203,7 +202,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 13", + "13", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -215,7 +214,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 2, 1), }, { - ", 14", + "14", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -227,7 +226,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 2, 1), }, { - ", 15", + "15", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 1, 1), 1, @@ -239,7 +238,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 2, 1), }, { - ", 16", + "16", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -251,7 +250,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 17", + "17", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -263,7 +262,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 18", + "18", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(-1, -1, 1, 1), 1, @@ -275,7 +274,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 1 x2", + "1 x2", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -287,7 +286,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 2 x2", + "2 x2", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -299,7 +298,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 3 x2", + "3 x2", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -311,7 +310,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight + 200, 1, 1), }, { - ", 4 x2", + "4 x2", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -323,7 +322,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200, 1, 1), }, { - ", 5 x2", + "5 x2", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -335,7 +334,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200, 1, 1), }, { - ", 6 x2", + "6 x2", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -347,7 +346,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 1 No ScrollBars", + "1 No ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -359,7 +358,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 2 No ScrollBars", + "2 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -371,7 +370,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 3 No ScrollBars", + "3 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -383,7 +382,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100), }, { - ", 4 No ScrollBars", + "4 No ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -395,7 +394,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 5 No ScrollBars", + "5 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -407,7 +406,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 6 No ScrollBars", + "6 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -419,7 +418,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 7 No ScrollBars", + "7 No ScrollBars", QRectF(0, 0, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -431,7 +430,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1), }, { - ", 8 No ScrollBars", + "8 No ScrollBars", QRectF(0, 0, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -443,7 +442,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1), }, { - ", 9 No ScrollBars", + "9 No ScrollBars", QRectF(0, 0, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -455,7 +454,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(101), }, { - ", 10 No ScrollBars", + "10 No ScrollBars", QRectF(-101, -101, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -467,7 +466,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 11 No ScrollBars", + "11 No ScrollBars", QRectF(-101, -101, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -479,7 +478,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 12 No ScrollBars", + "12 No ScrollBars", QRectF(-101, -101, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -491,7 +490,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 13 No ScrollBars", + "13 No ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -503,7 +502,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1), }, { - ", 14 No ScrollBars", + "14 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -515,7 +514,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1), }, { - ", 15 No ScrollBars", + "15 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 1, 1), 1, @@ -527,7 +526,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 1), }, { - ", 16 No ScrollBars", + "16 No ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -539,7 +538,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 17 No ScrollBars", + "17 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -551,7 +550,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 18 No ScrollBars", + "18 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(-1, -1, 1, 1), 1, @@ -563,7 +562,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 1 x2 No ScrollBars", + "1 x2 No ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -575,7 +574,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 2 x2 No ScrollBars", + "2 x2 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -587,7 +586,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 3 x2 No ScrollBars", + "3 x2 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -599,7 +598,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight + 200), }, { - ", 4 x2 No ScrollBars", + "4 x2 No ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -611,7 +610,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200), }, { - ", 5 x2 No ScrollBars", + "5 x2 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -623,7 +622,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200), }, { - ", 6 x2 No ScrollBars", + "6 x2 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -635,7 +634,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 1 Always ScrollBars", + "1 Always ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -647,7 +646,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 2 Always ScrollBars", + "2 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -659,7 +658,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 3 Always ScrollBars", + "3 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -671,7 +670,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 1, 1), }, { - ", 4 Always ScrollBars", + "4 Always ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -683,7 +682,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 5 Always ScrollBars", + "5 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -695,7 +694,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 6 Always ScrollBars", + "6 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -707,7 +706,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 7 Always ScrollBars", + "7 Always ScrollBars", QRectF(0, 0, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -719,7 +718,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1, 1, 1), }, { - ", 8 Always ScrollBars", + "8 Always ScrollBars", QRectF(0, 0, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -731,7 +730,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1, 1, 1), }, { - ", 9 Always ScrollBars", + "9 Always ScrollBars", QRectF(0, 0, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -743,7 +742,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(101, 1, 1), }, { - ", 10 Always ScrollBars", + "10 Always ScrollBars", QRectF(-101, -101, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -755,7 +754,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 11 Always ScrollBars", + "11 Always ScrollBars", QRectF(-101, -101, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -767,7 +766,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 12 Always ScrollBars", + "12 Always ScrollBars", QRectF(-101, -101, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -779,7 +778,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 13 Always ScrollBars", + "13 Always ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -791,7 +790,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 2, 1), }, { - ", 14 Always ScrollBars", + "14 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -803,7 +802,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 2, 1), }, { - ", 15 Always ScrollBars", + "15 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 1, 1), 1, @@ -815,7 +814,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 2, 1), }, { - ", 16 Always ScrollBars", + "16 Always ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -827,7 +826,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 17 Always ScrollBars", + "17 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -839,7 +838,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 18 Always ScrollBars", + "18 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(-1, -1, 1, 1), 1, @@ -851,7 +850,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 1 x2 Always ScrollBars", + "1 x2 Always ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -863,7 +862,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 2 x2 Always ScrollBars", + "2 x2 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -875,7 +874,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 3 x2 Always ScrollBars", + "3 x2 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -887,7 +886,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight + 200, 1, 1), }, { - ", 4 x2 Always ScrollBars", + "4 x2 Always ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -899,7 +898,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200, 1, 1), }, { - ", 5 x2 Always ScrollBars", + "5 x2 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -911,7 +910,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200, 1, 1), }, { - ", 6 x2 Always ScrollBars", + "6 x2 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -923,7 +922,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 1 Vertical Only", + "1 Vertical Only", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -935,7 +934,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 2 Vertical Only", + "2 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -947,7 +946,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 3 Vertical Only", + "3 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -959,7 +958,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100), }, { - ", 4 Vertical Only", + "4 Vertical Only", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -971,7 +970,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 5 Vertical Only", + "5 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -983,7 +982,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 6 Vertical Only", + "6 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -995,7 +994,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 7 Vertical Only", + "7 Vertical Only", QRectF(0, 0, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -1007,7 +1006,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1), }, { - ", 8 Vertical Only", + "8 Vertical Only", QRectF(0, 0, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -1019,7 +1018,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1), }, { - ", 9 Vertical Only", + "9 Vertical Only", QRectF(0, 0, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -1031,7 +1030,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(101), }, { - ", 10 Vertical Only", + "10 Vertical Only", QRectF(-101, -101, viewWidth + 1, viewHeight +1), ScrollBarCount(0, 0, 0, 0), 1, @@ -1043,7 +1042,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 11 Vertical Only", + "11 Vertical Only", QRectF(-101, -101, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -1055,7 +1054,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 12 Vertical Only", + "12 Vertical Only", QRectF(-101, -101, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -1067,7 +1066,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 13 Vertical Only", + "13 Vertical Only", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -1079,7 +1078,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1), }, { - ", 14 Vertical Only", + "14 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -1091,7 +1090,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1), }, { - ", 15 Vertical Only", + "15 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 1, 1), 1, @@ -1103,7 +1102,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 1), }, { - ", 16 Vertical Only", + "16 Vertical Only", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -1115,7 +1114,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 17 Vertical Only", + "17 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -1127,7 +1126,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 18 Vertical Only", + "18 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(-1, -1, 1, 1), 1, @@ -1139,7 +1138,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 1 x2 Vertical Only", + "1 x2 Vertical Only", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -1151,7 +1150,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 2 x2 Vertical Only", + "2 x2 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -1163,7 +1162,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 3 x2 Vertical Only", + "3 x2 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -1175,7 +1174,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight + 200), }, { - ", 4 x2 Vertical Only", + "4 x2 Vertical Only", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -1187,7 +1186,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200), }, { - ", 5 x2 Vertical Only", + "5 x2 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -1199,7 +1198,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200), }, { - ", 6 x2 Vertical Only", + "6 x2 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -1215,7 +1214,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) const QSize viewSize(viewWidth, viewHeight); for (const Data &e : data) { - QTest::newRow(qPrintable(styleString + QLatin1String(e.name))) + QTest::addRow("%s%s, %s", style.data(), styled ? ", Styled" : "", e.name) << style << viewSize << e.sceneRect << e.sceneRectOffsetFactors @@ -1229,7 +1228,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) void _scrollBarRanges_data() { - QTest::addColumn("style"); + QTest::addColumn("style"); QTest::addColumn("viewportSize"); QTest::addColumn("sceneRect"); QTest::addColumn("sceneRectOffsetFactors"); @@ -1242,14 +1241,15 @@ void _scrollBarRanges_data() QTest::addColumn("vmax"); QTest::addColumn("useStyledPanel"); - foreach (const QString &style, QStyleFactory::keys()) { - _scrollBarRanges_addTestData(style, false); - _scrollBarRanges_addTestData(style, true); + const auto styles = QStyleFactory::keys(); + for (const QString &style : styles) { + _scrollBarRanges_addTestData(style.toLatin1(), false); + _scrollBarRanges_addTestData(style.toLatin1(), true); } const QScreen *screen = QGuiApplication::primaryScreen(); if (screen && qFuzzyCompare((double)screen->logicalDotsPerInchX(), 96.0)) { - _scrollBarRanges_addTestData(QString("motif"), false); - _scrollBarRanges_addTestData(QString("motif"), true); + _scrollBarRanges_addTestData("motif", false); + _scrollBarRanges_addTestData("motif", true); } } From 1f814caca3836c43a415c219ef57b1d046321635 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 10:39:50 +0100 Subject: [PATCH 260/304] Plug memleaks in tst_QAbstractItemView Styles need to be deleted manually... Change-Id: Ic4193d22a57801127e994062cade7cb9ef6f34d8 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../itemviews/qabstractitemview/tst_qabstractitemview.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index bd6733e2d0..426db265ae 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -1567,7 +1567,7 @@ void tst_QAbstractItemView::testChangeEditorState() QTableView view; view.setEditTriggers(QAbstractItemView::CurrentChanged); - view.setItemDelegate(new StateChangeDelegate); + view.setItemDelegate(new StateChangeDelegate(&view)); view.setModel(&model); centerOnScreen(&view); moveCursorAway(&view); @@ -1941,7 +1941,8 @@ void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode() QCOMPARE(view.horizontalScrollMode(), styleScrollMode); // Change style, get new value - view.setStyle(new ScrollModeProxyStyle(styleScrollMode)); + ScrollModeProxyStyle proxyStyle1(styleScrollMode); + view.setStyle(&proxyStyle1); auto proxyScrollMode = static_cast(view.style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, &view, 0)); QVERIFY(styleScrollMode != proxyScrollMode); QCOMPARE(view.verticalScrollMode(), proxyScrollMode); @@ -1953,7 +1954,8 @@ void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode() QCOMPARE(view.horizontalScrollMode(), proxyScrollMode); // Change style, won't change value for vertical, will change for horizontal - view.setStyle(new ScrollModeProxyStyle(proxyScrollMode)); + ScrollModeProxyStyle proxyStyle2(proxyScrollMode); + view.setStyle(&proxyStyle2); QCOMPARE(view.verticalScrollMode(), proxyScrollMode); QCOMPARE(view.horizontalScrollMode(), styleScrollMode); } From 9064d0b8a8da8ddb2223c405e5a1359288d49714 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 11:34:57 +0100 Subject: [PATCH 261/304] tst_QTreeWidget: plug memleaks Taken QTreeWidgetItems need to be deleted, as do items created without a parent, and widgets without parent. Change-Id: I7ffa69903af9a1b92ba308f9f9416aec1d6d975f Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../itemviews/qtreewidget/tst_qtreewidget.cpp | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index fcffaa0eb9..f20805f97e 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -554,16 +554,16 @@ void tst_QTreeWidget::removeChild() QFETCH(int, childCount); QFETCH(int, removeAt); - QTreeWidgetItem *root = new QTreeWidgetItem; + const QScopedPointer root(new QTreeWidgetItem); for (int i = 0; i < childCount; ++i) - new QTreeWidgetItem(root, QStringList(QString::number(i))); + new QTreeWidgetItem(root.data(), QStringList(QString::number(i))); QCOMPARE(root->childCount(), childCount); for (int j = 0; j < childCount; ++j) QCOMPARE(root->child(j)->text(0), QString::number(j)); - QTreeWidgetItem *remove = root->child(removeAt); - root->removeChild(remove); + const QScopedPointer remove(root->child(removeAt)); + root->removeChild(remove.data()); QCOMPARE(root->childCount(), childCount - 1); for (int k = 0; k < childCount; ++k) { @@ -574,7 +574,6 @@ void tst_QTreeWidget::removeChild() else if (k > removeAt) QCOMPARE(root->child(k - 1)->text(0), QString::number(k)); } - delete root; } void tst_QTreeWidget::setItemHidden() @@ -1954,9 +1953,9 @@ void tst_QTreeWidget::itemData() void tst_QTreeWidget::enableDisable() { - QTreeWidgetItem *itm = new QTreeWidgetItem(); + const QScopedPointer itm(new QTreeWidgetItem); for (int i = 0; i < 10; ++i) - new QTreeWidgetItem(itm); + new QTreeWidgetItem(itm.data()); // make sure all items are enabled QVERIFY(itm->flags() & Qt::ItemIsEnabled); @@ -2720,7 +2719,10 @@ void tst_QTreeWidget::setDisabled() children.append(new QTreeWidgetItem()); children.append(new QTreeWidgetItem()); children.append(new QTreeWidgetItem()); - i1 = top->takeChild(0); + { + const QScopedPointer taken(top->takeChild(0)); + QCOMPARE(taken.data(), i1); + } top->addChildren(children); QCOMPARE(top->child(0)->isDisabled(), false); @@ -2732,16 +2734,21 @@ void tst_QTreeWidget::setDisabled() QCOMPARE(top->child(1)->isDisabled(), true); QCOMPARE(top->child(1)->isDisabled(), true); - children = top->takeChildren(); - QCOMPARE(children.at(0)->isDisabled(), false); - QCOMPARE(children.at(1)->isDisabled(), false); - QCOMPARE(children.at(1)->isDisabled(), false); + struct Deleter { + QList items; + explicit Deleter(QList items) : items(std::move(items)) {} + ~Deleter() { qDeleteAll(items); } + }; + const Deleter takenChildren(top->takeChildren()); + QCOMPARE(takenChildren.items[0]->isDisabled(), false); + QCOMPARE(takenChildren.items[1]->isDisabled(), false); + QCOMPARE(takenChildren.items[1]->isDisabled(), false); } void tst_QTreeWidget::removeSelectedItem() { - QTreeWidget *w = new QTreeWidget(); + const QScopedPointer w(new QTreeWidget); w->setSortingEnabled(true); QTreeWidgetItem *first = new QTreeWidgetItem(); @@ -2767,15 +2774,13 @@ void tst_QTreeWidget::removeSelectedItem() QCOMPARE(selModel->hasSelection(), true); QCOMPARE(selModel->selectedRows().count(), 1); - QTreeWidgetItem *taken = w->takeTopLevelItem(2); + const QScopedPointer taken(w->takeTopLevelItem(2)); QCOMPARE(taken->text(0), QLatin1String("C")); QCOMPARE(selModel->hasSelection(), false); QCOMPARE(selModel->selectedRows().count(), 0); QItemSelection sel = selModel->selection(); QCOMPARE(selModel->isSelected(w->model()->index(0,0)), false); - - delete w; } class AnotherTreeWidget : public QTreeWidget @@ -2934,11 +2939,11 @@ void tst_QTreeWidget::sortAndSelect() void tst_QTreeWidget::defaultRowSizes() { - QTreeWidget *tw = new QTreeWidget(); + const QScopedPointer tw(new QTreeWidget); tw->setIconSize(QSize(50, 50)); tw->setColumnCount(6); for (int i=0; i<10; ++i) { - QTreeWidgetItem *it = new QTreeWidgetItem(tw); + auto it = new QTreeWidgetItem(tw.data()); for (int j=0; jcolumnCount() - 1; ++j) { it->setText(j, "This is a test"); } From 7e6e92063324e589aa01928efae72b16f2823481 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 11:45:25 +0100 Subject: [PATCH 262/304] Plug memleaks in tst_QTreeView Forgot to delete QAIMs without parent. Change-Id: I9c914e841123ee250fb977c45a84870463288d9b Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 80ef0879cc..e2886cfcfe 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -3796,25 +3796,24 @@ void tst_QTreeView::task248022_changeSelection() void tst_QTreeView::task245654_changeModelAndExpandAll() { QTreeView view; - QStandardItemModel *model = new QStandardItemModel; + QScopedPointer model(new QStandardItemModel); QStandardItem *top = new QStandardItem("top"); QStandardItem *sub = new QStandardItem("sub"); top->appendRow(sub); model->appendRow(top); - view.setModel(model); + view.setModel(model.data()); view.expandAll(); QApplication::processEvents(); QVERIFY(view.isExpanded(top->index())); //now let's try to delete the model //then repopulate and expand again - delete model; - model = new QStandardItemModel; + model.reset(new QStandardItemModel); top = new QStandardItem("top"); sub = new QStandardItem("sub"); top->appendRow(sub); model->appendRow(top); - view.setModel(model); + view.setModel(model.data()); view.expandAll(); QApplication::processEvents(); QVERIFY(view.isExpanded(top->index())); From e4b19bfb94630c7da37d150955ccc246498966cf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 15:04:34 +0100 Subject: [PATCH 263/304] Plug memleaks in tst_QHeaderView The char* returned from QTest::toString() calls must be manually delete[]ed. Change-Id: Iad078e8741e3e97693b1a417693f414b3fb3ec09 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 1078dcc2e9..7bfec2831d 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -2523,7 +2523,8 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare const bool sanity_checks = true; if (sanity_checks) { QString msg = QString("sanity problem at ") + sline; - char *verifytext = QTest::toString(msg); + const QScopedArrayPointer holder(QTest::toString(msg)); + const auto verifytext = holder.data(); QVERIFY2(m_tableview->model()->rowCount() == view->count() , verifytext); QVERIFY2(view->visualIndex(lastindex + 1) <= 0, verifytext); // there is no such index in model @@ -2555,7 +2556,8 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare msg += istr(chk_visual) + istr(chk_logical) + istr(chk_sizes) + istr(chk_hidden_size) + istr(chk_lookup_visual) + istr(chk_lookup_logical) + istr(header_lenght, false) + "};"; - char *verifytext = QTest::toString(msg); + const QScopedArrayPointer holder(QTest::toString(msg)); + const auto verifytext = holder.data(); QVERIFY2(chk_visual == x[0], verifytext); QVERIFY2(chk_logical == x[1], verifytext); From e15cb86b3bc2cb1ed777a741f4b9e23fdb829249 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 15:07:46 +0100 Subject: [PATCH 264/304] Plug remaining memleaks in tests/auto/widgets/itemviews ... on Linux AMD64 builds. Pass QObject parents to QObjects otherwise leaked. Change-Id: Ia4f0ad2fdc4ef62a3d35a2cfca74965f79692da3 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp | 2 +- tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 2 +- tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index 0720a4f766..5b353bb2ae 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -1350,7 +1350,7 @@ void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck() } QTableView view; view.setModel(&model); - view.setItemDelegate(new TestItemDelegate); + view.setItemDelegate(new TestItemDelegate(&view)); view.show(); view.selectAll(); QVERIFY(QTest::qWaitForWindowExposed(&view)); diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 6eed21abb2..a89f8f3c8a 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -1488,7 +1488,7 @@ void tst_QListView::task203585_selectAll() //we make sure that "select all" doesn't select the hidden items QListView view; view.setSelectionMode(QAbstractItemView::ExtendedSelection); - view.setModel(new QStringListModel( QStringList() << "foo")); + view.setModel(new QStringListModel(QStringList() << "foo", &view)); view.setRowHidden(0, true); view.selectAll(); QVERIFY(view.selectionModel()->selectedIndexes().isEmpty()); diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index eb93e4c167..6547bb8985 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -1629,7 +1629,7 @@ void tst_QListWidget::QTBUG14363_completerWithAnyKeyPressedEditTriggers() { QListWidget listWidget; listWidget.setEditTriggers(QAbstractItemView::AnyKeyPressed); - listWidget.setItemDelegate(new ItemDelegate); + listWidget.setItemDelegate(new ItemDelegate(&listWidget)); QListWidgetItem *item = new QListWidgetItem(QLatin1String("select an item (don't start editing)"), &listWidget); item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable); new QListWidgetItem(QLatin1String("try to type the letter 'c'"), &listWidget); From 940d667eb41958de120ee759323c67bd7385af0d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 4 Oct 2016 19:49:58 +0200 Subject: [PATCH 265/304] Plug leaks in tests/auto/dbus In tst_QDBusMetaObject::types(), hold a QMetaObject obtained from QDBusMetaObject::createMetaObject() in a QScopedPointer instead of leaking it. Use correct return value type. This fixes the remaining errors in GCC 6.1 Linux ASan runs of tests/auto/dbus. Change-Id: I1df7f8e42d45f40ecf381fe7b684a8ab5ebee675 Reviewed-by: Alex Blasche Reviewed-by: Thiago Macieira --- tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp b/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp index cb1c9401ba..a4afae4b46 100644 --- a/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp +++ b/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp @@ -370,8 +370,7 @@ void tst_QDBusMetaObject::types() QDBusError error; - QMetaObject *result = QDBusMetaObject::createMetaObject("local.Interface", xml, - map, error); + const QScopedPointer result(QDBusMetaObject::createMetaObject("local.Interface", xml, map, error)); QVERIFY2(result, qPrintable(error.message())); QCOMPARE(result->enumeratorCount(), 0); From 9ba16336c51c5843db7c39df30853449972f8ead Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 20:57:16 +0200 Subject: [PATCH 266/304] QGuiApplication: fix misleading code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The comment says "don't send event if nothing changed", but the condition it is attached to reads if (velocityOnly), which is totally opaque. Change the variable name to stationaryTouchPointChangedVelocity and drop the then-branch of the if, because it is duplicated in the following default case of the switch. The comment makes sense again, and GCC 7 is happy, too, because this whole issue was pointed out by its -Wimplicit-fallthrough, which is why I added the fall-through attribute, too. Change-Id: I0631a381095f8897c55d9440304f6aefbc021a9a Reviewed-by: Shawn Rutledge Reviewed-by: Sérgio Martins --- src/gui/kernel/qguiapplication.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 71f27db6b7..3ba0d59102 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2472,7 +2472,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To QWindow *window = e->window.data(); typedef QPair > StatesAndTouchPoints; QHash windowsNeedingEvents; - bool velocityOnly = false; + bool stationaryTouchPointChangedVelocity = false; for (int i = 0; i < e->points.count(); ++i) { QTouchEvent::TouchPoint touchPoint = e->points.at(i); @@ -2552,7 +2552,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To if (touchPoint.state() == Qt::TouchPointStationary) { if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) { touchInfo.touchPoint.setVelocity(touchPoint.velocity()); - velocityOnly = true; + stationaryTouchPointChangedVelocity = true; } } else { touchInfo.touchPoint = touchPoint; @@ -2590,10 +2590,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To break; case Qt::TouchPointStationary: // don't send the event if nothing changed - if (velocityOnly) - eventType = QEvent::TouchUpdate; - else + if (!stationaryTouchPointChangedVelocity) continue; + Q_FALLTHROUGH(); default: eventType = QEvent::TouchUpdate; break; From b6967d0c11a6f559350c105973780445e253d6b3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 13 Jan 2017 09:56:59 +0100 Subject: [PATCH 267/304] XCB QPA: Fix QScreen::grabWindow(0) to return the current screen Previously, the code queried the window to be grabbed for the geometry and thus returned the entire virtual desktop for multi screen setups. Use the QPlatformScreen's geometry in case of WID = 0. Task-number: QTBUG-58110 Change-Id: I3a9c0b0b3ea057f5e58f272f5c3fd40fafc073ba Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbscreen.cpp | 121 ++++++++++++----------- 1 file changed, 61 insertions(+), 60 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index d8facdbb84..0ad9c97521 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -678,85 +678,88 @@ void QXcbScreen::updateRefreshRate(xcb_randr_mode_t mode) } } -QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) const +static xcb_get_geometry_reply_t *getGeometryUnchecked(xcb_connection_t *connection, xcb_window_t window) +{ + const xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(connection, window); + return xcb_get_geometry_reply(connection, geometry_cookie, NULL); +} + +static inline bool translate(xcb_connection_t *connection, xcb_window_t child, xcb_window_t parent, + int *x, int *y) +{ + const xcb_translate_coordinates_cookie_t translate_cookie = + xcb_translate_coordinates_unchecked(connection, child, parent, *x, *y); + xcb_translate_coordinates_reply_t *translate_reply = + xcb_translate_coordinates_reply(connection, translate_cookie, NULL); + if (!translate_reply) + return false; + *x = translate_reply->dst_x; + *y = translate_reply->dst_y; + free(translate_reply); + return true; +} + +QPixmap QXcbScreen::grabWindow(WId window, int xIn, int yIn, int width, int height) const { if (width == 0 || height == 0) return QPixmap(); - // TODO: handle multiple screens + int x = xIn; + int y = yIn; QXcbScreen *screen = const_cast(this); xcb_window_t root = screen->root(); - if (window == 0) - window = root; - - xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), window); - - xcb_get_geometry_reply_t *reply = - xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL); - - if (!reply) { + xcb_get_geometry_reply_t *rootReply = getGeometryUnchecked(xcb_connection(), root); + if (!rootReply) return QPixmap(); + + const quint8 rootDepth = rootReply->depth; + free(rootReply); + + QSize windowSize; + quint8 effectiveDepth = 0; + if (window) { + xcb_get_geometry_reply_t *windowReply = getGeometryUnchecked(xcb_connection(), window); + if (!windowReply) + return QPixmap(); + windowSize = QSize(windowReply->width, windowReply->height); + effectiveDepth = windowReply->depth; + free(windowReply); + if (effectiveDepth == rootDepth) { + // if the depth of the specified window and the root window are the + // same, grab pixels from the root window (so that we get the any + // overlapping windows and window manager frames) + + // map x and y to the root window + if (!translate(xcb_connection(), window, root, &x, &y)) + return QPixmap(); + + window = root; + } + } else { + window = root; + effectiveDepth = rootDepth; + windowSize = m_geometry.size(); + x += m_geometry.x(); + y += m_geometry.y(); } if (width < 0) - width = reply->width - x; + width = windowSize.width() - xIn; if (height < 0) - height = reply->height - y; - - geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), root); - xcb_get_geometry_reply_t *root_reply = - xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL); - - if (!root_reply) { - free(reply); - return QPixmap(); - } - - if (reply->depth == root_reply->depth) { - // if the depth of the specified window and the root window are the - // same, grab pixels from the root window (so that we get the any - // overlapping windows and window manager frames) - - // map x and y to the root window - xcb_translate_coordinates_cookie_t translate_cookie = - xcb_translate_coordinates_unchecked(xcb_connection(), window, root, x, y); - - xcb_translate_coordinates_reply_t *translate_reply = - xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, NULL); - - if (!translate_reply) { - free(reply); - free(root_reply); - return QPixmap(); - } - - x = translate_reply->dst_x; - y = translate_reply->dst_y; - - window = root; - - free(translate_reply); - free(reply); - reply = root_reply; - } else { - free(root_reply); - root_reply = 0; - } + height = windowSize.height() - yIn; xcb_get_window_attributes_reply_t *attributes_reply = xcb_get_window_attributes_reply(xcb_connection(), xcb_get_window_attributes_unchecked(xcb_connection(), window), NULL); - if (!attributes_reply) { - free(reply); + if (!attributes_reply) return QPixmap(); - } const xcb_visualtype_t *visual = screen->visualForId(attributes_reply->visual); free(attributes_reply); xcb_pixmap_t pixmap = xcb_generate_id(xcb_connection()); - xcb_create_pixmap(xcb_connection(), reply->depth, pixmap, window, width, height); + xcb_create_pixmap(xcb_connection(), effectiveDepth, pixmap, window, width, height); uint32_t gc_value_mask = XCB_GC_SUBWINDOW_MODE; uint32_t gc_value_list[] = { XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS }; @@ -766,9 +769,7 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) xcb_copy_area(xcb_connection(), window, pixmap, gc, x, y, 0, 0, width, height); - QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, reply->depth, visual); - - free(reply); + QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, effectiveDepth, visual); xcb_free_gc(xcb_connection(), gc); xcb_free_pixmap(xcb_connection(), pixmap); From a85ed40004e5bfe08b773737af176fbd22b529c9 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 25 Jan 2017 14:14:14 +0100 Subject: [PATCH 268/304] Doc: Documentation template: Bump copyright year Change-Id: Ic2dfce35f9bfabc94b170f3dfaa3172630918330 Reviewed-by: Leena Miettinen --- doc/global/config.qdocconf | 2 +- doc/global/html-footer-online.qdocconf | 2 +- doc/global/html-footer.qdocconf | 2 +- doc/global/qt-module-defaults-online.qdocconf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/global/config.qdocconf b/doc/global/config.qdocconf index ac9e7ac274..0c22d70529 100644 --- a/doc/global/config.qdocconf +++ b/doc/global/config.qdocconf @@ -3,7 +3,7 @@ dita.metadata.default.author = Qt Project dita.metadata.default.permissions = all dita.metadata.default.publisher = Qt Project -dita.metadata.default.copyryear = 2016 +dita.metadata.default.copyryear = 2017 dita.metadata.default.copyrholder = The Qt Company Ltd dita.metadata.default.audience = programmer diff --git a/doc/global/html-footer-online.qdocconf b/doc/global/html-footer-online.qdocconf index 86f75ab073..d6cf5d2122 100644 --- a/doc/global/html-footer-online.qdocconf +++ b/doc/global/html-footer-online.qdocconf @@ -78,7 +78,7 @@ HTML.footer += \ " \n" \ "\n" \ "\n" \ diff --git a/doc/global/html-footer.qdocconf b/doc/global/html-footer.qdocconf index d350bc4772..5a0fbd85e1 100644 --- a/doc/global/html-footer.qdocconf +++ b/doc/global/html-footer.qdocconf @@ -8,7 +8,7 @@ HTML.footer = \ "\n" \ "
\n" \ "

\n" \ - " © 2016 The Qt Company Ltd.\n" \ + " © 2017 The Qt Company Ltd.\n" \ " Documentation contributions included herein are the copyrights of\n" \ " their respective owners.
" \ " The documentation provided herein is licensed under the terms of the" \ diff --git a/doc/global/qt-module-defaults-online.qdocconf b/doc/global/qt-module-defaults-online.qdocconf index fb8c261804..15c193d698 100644 --- a/doc/global/qt-module-defaults-online.qdocconf +++ b/doc/global/qt-module-defaults-online.qdocconf @@ -5,7 +5,7 @@ HTML.footer = \ "

\n" \ "

\n" \ - " © 2016 The Qt Company Ltd.\n" \ + " © 2017 The Qt Company Ltd.\n" \ " Documentation contributions included herein are the copyrights of\n" \ " their respective owners. " \ " The documentation provided herein is licensed under the terms of the" \ From 8d752b5151c9890b76d50c4a479ab32dd0eca10c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 26 Jan 2017 10:28:41 +0100 Subject: [PATCH 269/304] Accept all formatting characters as valid input Amends 7896ae052ad2c0c6ae2ebfc64cc2f525185198a8. The previous change focused only on ZWJ and ZWNJ, but there are many other formatting characters that we need to support and that may be rejected by the German keyboard-hack. This opens up for all characters in the Other_Format category. Task-number: QTBUG-58364 Change-Id: Idd967a9ae5b12060c851f6030b7e019508561696 Reviewed-by: Simon Hausmann Reviewed-by: Lars Knoll --- src/gui/text/qinputcontrol.cpp | 6 ++--- .../text/qinputcontrol/tst_qinputcontrol.cpp | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qinputcontrol.cpp b/src/gui/text/qinputcontrol.cpp index af21ee86ee..2f7dcfcd2b 100644 --- a/src/gui/text/qinputcontrol.cpp +++ b/src/gui/text/qinputcontrol.cpp @@ -62,9 +62,9 @@ bool QInputControl::isAcceptableInput(const QKeyEvent *event) const const QChar c = text.at(0); - // ZWNJ and ZWJ. This needs to go before the next test, since CTRL+SHIFT is - // used to input it on Windows. - if (c == QChar(0x200C) || c == QChar(0x200D)) + // Formatting characters such as ZWNJ, ZWJ, RLM, etc. This needs to go before the + // next test, since CTRL+SHIFT is sometimes used to input it on Windows. + if (c.category() == QChar::Other_Format) return true; // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards diff --git a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp index ad5ba6affb..173e137d17 100644 --- a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp +++ b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp @@ -59,6 +59,28 @@ void tst_QInputControl::isAcceptableInput_data() QTest::newRow("printable-hebrew") << QString(QChar(0x2135)) << Qt::KeyboardModifiers() << true; QTest::newRow("private-use-area") << QString(QChar(0xE832)) << Qt::KeyboardModifiers() << true; QTest::newRow("multiple-printable") << QStringLiteral("foobar") << Qt::KeyboardModifiers() << true; + QTest::newRow("rlm") << QString(QChar(0x200F)) << Qt::KeyboardModifiers() << true; + QTest::newRow("rlm-with-ctrl") << QString(QChar(0x200F)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true; + QTest::newRow("rlm-with-ctrl-shift") << QString(QChar(0x200F)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true; + QTest::newRow("lrm") << QString(QChar(0x200E)) << Qt::KeyboardModifiers() << true; + QTest::newRow("lrm-with-ctrl") << QString(QChar(0x200E)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true; + QTest::newRow("lrm-with-ctrl-shift") << QString(QChar(0x200E)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true; + QTest::newRow("rlo") << QString(QChar(0x202E)) << Qt::KeyboardModifiers() << true; + QTest::newRow("rlo-with-ctrl") << QString(QChar(0x202E)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true; + QTest::newRow("rlo-with-ctrl-shift") << QString(QChar(0x202E)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true; + QTest::newRow("lro") << QString(QChar(0x202D)) << Qt::KeyboardModifiers() << true; + QTest::newRow("lro-with-ctrl") << QString(QChar(0x202D)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true; + QTest::newRow("lro-with-ctrl-shift") << QString(QChar(0x202D)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true; + QTest::newRow("lre") << QString(QChar(0x202B)) << Qt::KeyboardModifiers() << true; + QTest::newRow("lre-with-ctrl") << QString(QChar(0x202B)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true; + QTest::newRow("lre-with-ctrl-shift") << QString(QChar(0x202B)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true; + QTest::newRow("rle") << QString(QChar(0x202A)) << Qt::KeyboardModifiers() << true; + QTest::newRow("rle-with-ctrl") << QString(QChar(0x202A)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true; + QTest::newRow("rle-with-ctrl-shift") << QString(QChar(0x202A)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true; + QTest::newRow("pdf") << QString(QChar(0x202C)) << Qt::KeyboardModifiers() << true; + QTest::newRow("pdf-with-ctrl") << QString(QChar(0x202C)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true; + QTest::newRow("pdf-with-ctrl-shift") << QString(QChar(0x202C)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true; + } void tst_QInputControl::isAcceptableInput() From 798ed169d86a192c0e6efe63702992b26f7f0775 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Jan 2017 10:08:14 +0100 Subject: [PATCH 270/304] Fix printsupport dependencies This makes -no-feature-printer and -no-feature-combobox work. Change-Id: I1097ab0a81f1c92b808c3e36ced0db9117db559a Reviewed-by: Lars Knoll --- src/printsupport/configure.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/printsupport/configure.json b/src/printsupport/configure.json index a4855212fd..dfef0bcd6c 100644 --- a/src/printsupport/configure.json +++ b/src/printsupport/configure.json @@ -28,13 +28,13 @@ "label": "CUPS", "purpose": "Provides support for the Common Unix Printing System.", "section": "Painting", - "condition": "libs.cups", + "condition": "libs.cups && features.printer", "output": [ "privateFeature", "feature" ] }, "cupsjobwidget": { "label": "CUPS job control widget", "section": "Widgets", - "condition": "features.cups && features.calendarwidget && features.datetimeedit && features.groupbox", + "condition": "features.cups && features.calendarwidget && features.datetimeedit && features.groupbox && features.combobox", "output": [ "privateFeature", "feature" ] }, "printer": { From 0d3b3534ee2828f760c4c9e79afa7336e57e12f8 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Jan 2017 11:48:27 +0100 Subject: [PATCH 271/304] Fix build with -no-feature-lineedit Change-Id: I171aed5d134db88f211da0e1a6ce236e32f3c35c Reviewed-by: Lars Knoll --- src/widgets/accessible/rangecontrols.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp index 2f781fe619..602d0c7e11 100644 --- a/src/widgets/accessible/rangecontrols.cpp +++ b/src/widgets/accessible/rangecontrols.cpp @@ -81,10 +81,14 @@ QAbstractSpinBox *QAccessibleAbstractSpinBox::abstractSpinBox() const QAccessibleInterface *QAccessibleAbstractSpinBox::lineEditIface() const { +#if QT_CONFIG(lineedit) // QAccessibleLineEdit is only used to forward the text functions if (!lineEdit) lineEdit = new QAccessibleLineEdit(abstractSpinBox()->lineEdit()); return lineEdit; +#else + return nullptr; +#endif } QString QAccessibleAbstractSpinBox::text(QAccessible::Text t) const From 1327526d8eae28926b9cb9168d88df614fe87355 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Jan 2017 11:48:47 +0100 Subject: [PATCH 272/304] Remove duplicated feature definition The "spinbox" feature was defined twice, and in two different ways. Change-Id: Iabc8939036e2166c5c5a417181ae8fb244829123 Reviewed-by: Lars Knoll --- src/widgets/configure.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 84500bff21..e7007f71b7 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -173,7 +173,7 @@ "label": "QSpinBox", "purpose": "Provides spin boxes handling integers and discrete sets of values.", "section": "Widgets", - "condition": "features.spinwidget && features.lineedit && features.validator", + "condition": "features.lineedit && features.validator", "output": [ "publicFeature", "feature" ] }, "tabbar": { @@ -332,12 +332,6 @@ "condition": "features.graphicsview", "output": [ "publicFeature", "feature" ] }, - "spinbox": { - "label": "QSpinBox", - "purpose": "Provides spinbox control widgets.", - "section": "Widgets", - "output": [ "publicFeature", "feature" ] - }, "textedit": { "label": "QTextEdit", "purpose": "Supports rich text editing.", From 52d9fd74b13e7c730cd3f353bfbc7a64b15e9038 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 26 Jan 2017 14:26:39 +0100 Subject: [PATCH 273/304] Make custom colors in QColorDialog permanent [ChangeLog][QtWidgets][QColorDialog] Fixed long standing bug that prevented custom colors in QColorDialog to be stored in the settings. Task-number: QTBUG-58424 Change-Id: If3ee5eef75358d811f08e7ce52fb60622972ddd4 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qplatformdialoghelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index c36186b815..5890eb4fb6 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -278,7 +278,7 @@ void QColorDialogStaticData::readSettings() void QColorDialogStaticData::writeSettings() const { #ifndef QT_NO_SETTINGS - if (!customSet) { + if (customSet) { QSettings settings(QSettings::UserScope, QStringLiteral("QtProject")); for (int i = 0; i < int(CustomColorCount); ++i) settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), customRgb[i]); From 0feeb6f6d2cfaa964763ca1fcab65672812b4eef Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Mon, 9 Jan 2017 22:42:30 +0000 Subject: [PATCH 274/304] Fix dock widget having the wrong parent after a drag When dragging a dock widget from a floating group to the main window reparentWidgets() is supposed to be called. It's usually triggered by some unrelated event, like a LayoutRequest. Instead of relying on luck for reparentWidgets() to get called be explicit, otherwise the dock widget that was dropped into main window will still have as parent the floating group window. The item.skip() condition seems overly restrictive. Task-number: QTBUG-58036 Change-Id: I65b5699e1acb6ca9bedb10620daa055fa9d91943 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qdockarealayout.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 30eaa73b9e..b33f2dc798 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -2092,7 +2092,7 @@ void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent) const QDockAreaLayoutItem &item = item_list.at(i); if (item.flags & QDockAreaLayoutItem::GapItem) continue; - if (item.skip()) + if (!item.widgetItem && item.skip()) continue; if (item.subinfo) item.subinfo->reparentWidgets(parent); @@ -2608,7 +2608,9 @@ QLayoutItem *QDockAreaLayout::plug(const QList &path) Q_ASSERT(!path.isEmpty()); const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].plug(path.mid(1)); + QLayoutItem *item = docks[index].plug(path.mid(1)); + docks[index].reparentWidgets(mainWindow); + return item; } QLayoutItem *QDockAreaLayout::unplug(const QList &path) From c2cecf08d5abf8324fc066bde5f0a07f3e59a622 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 14 Jan 2017 09:11:57 +0100 Subject: [PATCH 275/304] QHostAddress: add missing op!=(SpecialAddress, QHostAddress) The equality operator was supplied, but this one was missing. [ChangeLog][QtNetwork][QHostAddress] Added op!=(SpecialAddress, QHostAddress). Change-Id: Iad9c55fa0ee7a8e97d5e4ea4be0605b8b74649d1 Reviewed-by: Thiago Macieira --- src/network/kernel/qhostaddress.cpp | 12 ++++++++++++ src/network/kernel/qhostaddress.h | 2 ++ .../network/kernel/qhostaddress/tst_qhostaddress.cpp | 1 + 3 files changed, 15 insertions(+) diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 5efd80619c..b8c0584a62 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1258,6 +1258,18 @@ uint qHash(const QHostAddress &key, uint seed) Q_DECL_NOTHROW \sa isEqual() */ + +/*! + \relates QHostAddress + \since 5.9 + \fn operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs) + + Returns \c false if special address \a lhs is the same as host address \a rhs; + otherwise returns \c true. + + \sa isEqual() +*/ + #ifndef QT_NO_DATASTREAM /*! \relates QHostAddress diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 3898fb02a8..fdbdbfc72c 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -161,6 +161,8 @@ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QHostAddress) inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2) { return address2 == address1; } +inline bool operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs) +{ return rhs != lhs; } #ifndef QT_NO_DEBUG_STREAM Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QHostAddress &); diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp index a715c38f32..bc3f5650ba 100644 --- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp +++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp @@ -274,6 +274,7 @@ void tst_QHostAddress::specialAddresses() QVERIFY(address == QHostAddress(address)); QVERIFY(!(QHostAddress(address) != QHostAddress(address))); QVERIFY(!(QHostAddress(address) != address)); + QVERIFY(!(address != QHostAddress(address))); { QHostAddress ha; From b9e510ff8fe21622c761b501609fbb5ef84ccdd9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 10 Jan 2017 15:25:11 +0100 Subject: [PATCH 276/304] QGradientCache: add some std::move() Change-Id: I8cbc1dd3cdd46e9741a301bf26b6fab396e374b6 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/painting/qpaintengine_raster.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 09177db2ab..fc4f2a9944 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4472,9 +4472,9 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode gradient.alphaColor = !brush.isOpaque() || alpha != 256; auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); - cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; + cachedGradient = std::move(cacheInfo); gradient.spread = g->spread(); @@ -4494,9 +4494,9 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode gradient.alphaColor = !brush.isOpaque() || alpha != 256; auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); - cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; + cachedGradient = std::move(cacheInfo); gradient.spread = g->spread(); @@ -4520,9 +4520,9 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode gradient.alphaColor = !brush.isOpaque() || alpha != 256; auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); - cachedGradient = cacheInfo; gradient.colorTable32 = cacheInfo->buffer32; gradient.colorTable64 = cacheInfo->buffer64; + cachedGradient = std::move(cacheInfo); gradient.spread = QGradient::RepeatSpread; From 2ccb7ecbca3f27663d96c7582e80c8af18500eda Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 16 Aug 2016 13:37:58 +0200 Subject: [PATCH 277/304] tests/auto/corelib/animation: clean up - port from inefficient QLists to QVector - mark types held in Qt containers (incl. QVariant) as Q_MOVABLE/PRIMITIVE_TYPE - remove pointless user-defined copy special members which prevent the class from having nothrow move special members Fixes errors reported by my local tree's static checks. Change-Id: If3910484cea81a8e2c5ab737908c9443f75782c5 Reviewed-by: Lars Knoll --- .../tst_qparallelanimationgroup.cpp | 3 +++ .../qpropertyanimation/tst_qpropertyanimation.cpp | 12 ++++-------- .../tst_qsequentialanimationgroup.cpp | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index a8d64f1cd9..18a6268ec0 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -786,6 +786,9 @@ struct AnimState { int time; int state; }; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(AnimState, Q_MOVABLE_TYPE); +QT_END_NAMESPACE #define Running QAbstractAnimation::Running #define Stopped QAbstractAnimation::Stopped diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index c1a8fde504..9e0648d194 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -427,7 +427,7 @@ public: void setOle(int v) { o = v; values << v; } int o; - QList values; + QVector values; }; void tst_QPropertyAnimation::noStartValue() @@ -674,19 +674,15 @@ struct Number Number(int n) : n(n) {} - Number(const Number &other) - : n(other.n){} - - Number &operator=(const Number &other) { - n = other.n; - return *this; - } bool operator==(const Number &other) const { return n == other.n; } int n; }; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(Number, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE Q_DECLARE_METATYPE(Number) diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 6d66f05835..06e9fe7a66 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -563,7 +563,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards() QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped); } -typedef QList StateList; +typedef QVector StateList; static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates) { From aab8e304ea66eaed990d5c53183e9547ce10190b Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Thu, 26 Jan 2017 13:19:29 +0000 Subject: [PATCH 278/304] Revert "Network (HTTPS): prevent recursion among ->close() methods" This reverts commit 556b2ee7737b1dfdbc5223e9a1230b5df6843a01. The reason for this is that this change appears to stop QtLocation from fetching tiles. Task-number: QTBUG-58303 Change-Id: I64cd3a17d24f10652bb68cee0267cc7ff1f9d479 Reviewed-by: Edward Welbourne --- .../access/qhttpnetworkconnectionchannel.cpp | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 094fd36637..668409a988 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -44,7 +44,6 @@ #include #include -#include #ifndef QT_NO_HTTP @@ -197,42 +196,41 @@ void QHttpNetworkConnectionChannel::init() void QHttpNetworkConnectionChannel::close() { - // socket can be 0 since the host lookup is done from qhttpnetworkconnection.cpp while - // there is no socket yet; we may also clear it, below or in abort, to avoid recursion. - const bool idle = !socket || socket->state() == QAbstractSocket::UnconnectedState; - const ChannelState final = idle ? IdleState : ClosingState; + if (!socket) + state = QHttpNetworkConnectionChannel::IdleState; + else if (socket->state() == QAbstractSocket::UnconnectedState) + state = QHttpNetworkConnectionChannel::IdleState; + else + state = QHttpNetworkConnectionChannel::ClosingState; + // pendingEncrypt must only be true in between connected and encrypted states pendingEncrypt = false; if (socket) { - QAbstractSocket *const detached = socket; - QScopedValueRollback rollback(socket, nullptr); - state = final; // Needed during close(), which may over-write it. - detached->close(); // Error states can cause recursion back to this method. + // socket can be 0 since the host lookup is done from qhttpnetworkconnection.cpp while + // there is no socket yet. + socket->close(); } - - // Set state *after* close(), to override any recursive call's idle setting: - state = final; } + void QHttpNetworkConnectionChannel::abort() { - // socket can be 0 since the host lookup is done from qhttpnetworkconnection.cpp while - // there is no socket yet; we may also clear it, below or in close, to avoid recursion. - const bool idle = !socket || socket->state() == QAbstractSocket::UnconnectedState; - const ChannelState final = idle ? IdleState : ClosingState; + if (!socket) + state = QHttpNetworkConnectionChannel::IdleState; + else if (socket->state() == QAbstractSocket::UnconnectedState) + state = QHttpNetworkConnectionChannel::IdleState; + else + state = QHttpNetworkConnectionChannel::ClosingState; + // pendingEncrypt must only be true in between connected and encrypted states pendingEncrypt = false; if (socket) { - QAbstractSocket *const detached = socket; - QScopedValueRollback rollback(socket, nullptr); - state = final; - detached->abort(); + // socket can be 0 since the host lookup is done from qhttpnetworkconnection.cpp while + // there is no socket yet. + socket->abort(); } - - // Set state *after* abort(), to override any recursive call's idle setting: - state = final; } From d03ba0e895a3719ce527f3d7ee9262fb26065332 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 17 Nov 2016 15:01:59 +0100 Subject: [PATCH 279/304] Optimize debug builds when -Og is available Enables optimizing with -Og if GCC has the option available, this should produce faster debug binaries without compromising debugability. Is a privateConfig to limit it to the default Qt build. Includes two fixes for false positives of maybe_uninitialized triggered by -Og on gcc 4.9. Change-Id: I466d7a4070295714189024369312e6cbd36cfacf Reviewed-by: Oswald Buddenhagen --- config_help.txt | 2 ++ configure.json | 16 ++++++++++++++++ mkspecs/common/gcc-base.conf | 1 + mkspecs/features/default_post.prf | 5 +++++ src/gui/text/qfontengine.cpp | 2 +- .../eglfs_x11/qeglfsx11integration.cpp | 2 +- 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config_help.txt b/config_help.txt index ab86873310..e5553025c5 100644 --- a/config_help.txt +++ b/config_help.txt @@ -72,6 +72,8 @@ Build options: -debug ............... Build Qt with debugging turned on [no] -debug-and-release ... Build two versions of Qt, with and without debugging turned on [yes] (Apple and Windows only) + -optimize-debug ...... Enable debug-friendly optimizations in debug builds + [auto] (Not supported with MSVC) -optimized-tools ..... Build optimized host tools even in debug build [no] -force-debug-info .... Create symbol files for release builds [no] -separate-debug-info . Split off debug information to separate files [no] diff --git a/configure.json b/configure.json index 4030d359ae..c293fbb676 100644 --- a/configure.json +++ b/configure.json @@ -93,6 +93,7 @@ "mp": { "type": "boolean", "name": "msvc_mp" }, "nomake": { "type": "addString", "values": [ "examples", "tests", "tools" ] }, "opensource": { "type": "void", "name": "commercial", "value": "no" }, + "optimize-debug": { "type": "boolean", "name": "optimize_debug" }, "optimized-qmake": { "type": "boolean", "name": "release_tools" }, "optimized-tools": { "type": "boolean", "name": "release_tools" }, "pch": { "type": "boolean", "name": "precompile_header" }, @@ -263,6 +264,11 @@ "type": "compilerSupportsFlag", "flag": "-fuse-ld=gold" }, + "optimize_debug": { + "label": "-Og support", + "type": "compilerSupportsFlag", + "flag": "-Og" + }, "enable_new_dtags": { "label": "new dtags support", "type": "linkerSupportsFlag", @@ -479,6 +485,11 @@ "condition": "!config.msvc && !config.integrity && tests.use_gold_linker", "output": [ "privateConfig", "useGoldLinker" ] }, + "optimize_debug": { + "label": "Optimize debug build", + "condition": "!config.msvc && (features.debug || features.debug_and_release) && tests.optimize_debug", + "output": [ "privateConfig" ] + }, "architecture": { "label": "Architecture", "output": [ "architecture" ] @@ -1078,6 +1089,11 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 "message": "Mode", "type": "buildMode" }, + { + "type": "feature", + "args": "optimize_debug", + "condition": "!config.msvc && (features.debug || features.debug_and_release)" + }, "shared", { "message": "Using C++ standard", diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index 6bb1e3fbe0..0ee8769bf2 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -33,6 +33,7 @@ QMAKE_CFLAGS_OPTIMIZE = -O2 QMAKE_CFLAGS_OPTIMIZE_FULL = -O3 +QMAKE_CFLAGS_OPTIMIZE_DEBUG = -Og QMAKE_CFLAGS += -pipe QMAKE_CFLAGS_DEPS += -M diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 7f5ab3a10c..e19e9c9760 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -47,6 +47,11 @@ optimize_full { } } +optimize_debug { + QMAKE_CFLAGS_DEBUG += $$QMAKE_CFLAGS_OPTIMIZE_DEBUG + QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_OPTIMIZE_DEBUG +} + debug { QMAKE_CFLAGS += $$QMAKE_CFLAGS_DEBUG QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_DEBUG diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 8d8ca1ba2c..596c79fd05 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1273,7 +1273,7 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy if (!qSafeFromBigEndian(maps + 8 * n, endPtr, &platformId)) return 0; - quint16 platformSpecificId; + quint16 platformSpecificId = 0; if (!qSafeFromBigEndian(maps + 8 * n + 2, endPtr, &platformSpecificId)) return 0; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 0a547b832f..64d0d9b515 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -114,7 +114,7 @@ void EventReader::run() { Qt::MouseButtons buttons; - xcb_generic_event_t *event; + xcb_generic_event_t *event = nullptr; while (running.load() && (event = xcb_wait_for_event(m_integration->connection()))) { uint response_type = event->response_type & ~0x80; switch (response_type) { From 6d5489f5df1220ac82d76bbee1f3caa93b34100d Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Wed, 25 Jan 2017 18:52:22 -0800 Subject: [PATCH 280/304] Apple: fix QMAKE_DEFAULT_INCDIRS so compiler invocations use the sysroot The compiler command line used to populate QMAKE_DEFAULT_INCDIRS must include the sysroot in order to generate the correct paths list. This fixes a regression introduced in afd8263 which in turn attempted to fix an earlier regression making it impossible to override the deployment target in user project files. Task-number: QTBUG-58325 Change-Id: I93e6b7ef90b2744dd2f03c77da31c692cb194976 Reviewed-by: Gabriel de Dietrich Reviewed-by: Oswald Buddenhagen --- mkspecs/features/toolchain.prf | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 15b0829235..6d96eaf689 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -29,7 +29,18 @@ isEmpty($${target_prefix}.INCDIRS) { cmd_prefix = "set LC_ALL=C&" cmd_suffix = "NUL" } - output = $$system("$$cmd_prefix $$QMAKE_CXX $$qtMakeExpand($$QMAKE_CXXFLAGS) -xc++ -E -v - 2>&1 $$cmd_suffix", lines) + + cxx_flags = $$QMAKE_CXXFLAGS + + # Manually inject the sysroot for Apple Platforms because its resolution + # normally does not happen until default_post.prf. This is especially + # important for moc to gain the correct default include directory list. + # While technically incorrect but without any likely practical effect, + # UIKit simulator platforms will see the device SDK's sysroot in + # QMAKE_DEFAULT_*DIRS, because they're handled in a single build pass. + darwin: cxx_flags += -isysroot $$QMAKE_MAC_SDK_PATH + + output = $$system("$$cmd_prefix $$QMAKE_CXX $$qtMakeExpand($$cxx_flags) -xc++ -E -v - 2>&1 $$cmd_suffix", lines) add_includes = false for (line, output) { line ~= s/^ *// # remove leading spaces From 20f7cfcbdab795b1730e3d1d14fc3833a7f5e705 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 26 Jan 2017 18:03:50 +0100 Subject: [PATCH 281/304] qnetworkproxy_mac - fix proxyAutoConfigCallback We have an invalid pointer dereference in our callback. Apple's docs are quite ambiguous, whatever we receive in our callback's 'client' parameter is our PACInfo, not clientContext's address. That's what we pass to CFNetworkExecuteProxyAutoConfigurationURL: "clientContext - A stream context containing a client info object and optionally retain and release callbacks for that object." This 'client info' is our PACInfo struct with 2 pointers. Now in a callback, 'client': "The client reference originally passed in the clientContext parameter of the ..." So apparently we should read this as "client info originally passed in ...." Otherwise incorrect cast results in invalid pointer (apparently the value of retain/release/copy pointers we carefully set to 0) and a crash on dereference. Task-number: QTBUG-56747 Change-Id: I89378f1582679638cd29a36c563e506d8f5af518 Reviewed-by: Gabriel de Dietrich --- src/network/kernel/qnetworkproxy_mac.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp index c13a472b90..92f91956b9 100644 --- a/src/network/kernel/qnetworkproxy_mac.cpp +++ b/src/network/kernel/qnetworkproxy_mac.cpp @@ -189,12 +189,19 @@ struct PACInfo { void proxyAutoConfigCallback(void *client, CFArrayRef proxylist, CFErrorRef error) { - PACInfo *info = reinterpret_cast(reinterpret_cast(client)->info); + Q_ASSERT(client); + + PACInfo *info = static_cast(client); info->done = true; - if (proxylist) + + if (error) { + CFRetain(error); + info->error = error; + } + if (proxylist) { CFRetain(proxylist); - info->proxies = proxylist; - info->error = error; + info->proxies = proxylist; + } } } // anon namespace From 9febc58d07cc19a7393b98fdafbc38ac25e52d6a Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Wed, 18 Jan 2017 21:54:26 +0900 Subject: [PATCH 282/304] Fix build without features.movie Change-Id: I244a618f8660262249455ee707b62e6355583a74 Reviewed-by: Lars Knoll --- src/gui/image/qmovie.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 1fdef4e230..55ddd839b7 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -170,11 +170,11 @@ \sa QMovie::stop() */ -#include "qglobal.h" +#include "qmovie.h" #ifndef QT_NO_MOVIE -#include "qmovie.h" +#include "qglobal.h" #include "qimage.h" #include "qimagereader.h" #include "qpixmap.h" From 02cc57f4edbae450ecfa8368052afa44f8aeee19 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 12 Jan 2017 14:10:53 +0100 Subject: [PATCH 283/304] QKeySequenceEdit: Allow for the case where pressing SHIFT+letter gives a different letter On some keyboard layouts it is possible that pressing SHIFT+letter does not give the upper case version of the character. So we depend on QKeyMapper here to give us the right keysequence as then it will compare against a shortcut created with this combination then. Task-number: QTBUG-57928 Task-number: QTBUG-57931 Change-Id: I9421f3ab4d3f8d1ee42f9680200d4b017d551057 Reviewed-by: Oliver Wolff --- src/widgets/widgets/qkeysequenceedit.cpp | 32 +++++++++++++++++------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 3252ce5941..4d86c7cfc7 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -43,6 +43,7 @@ #include "qboxlayout.h" #include "qlineedit.h" +#include QT_BEGIN_NAMESPACE @@ -80,15 +81,8 @@ void QKeySequenceEditPrivate::init() int QKeySequenceEditPrivate::translateModifiers(Qt::KeyboardModifiers state, const QString &text) { + Q_UNUSED(text); int result = 0; - // The shift modifier only counts when it is not used to type a symbol - // that is only reachable using the shift key anyway - if ((state & Qt::ShiftModifier) && (text.isEmpty() || - !text.at(0).isPrint() || - text.at(0).isLetterOrNumber() || - text.at(0).isSpace())) - result |= Qt::SHIFT; - if (state & Qt::ControlModifier) result |= Qt::CTRL; if (state & Qt::MetaModifier) @@ -272,7 +266,27 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) if (d->keyNum >= QKeySequencePrivate::MaxKeyCount) return; - nextKey |= d->translateModifiers(e->modifiers(), e->text()); + if (e->modifiers() & Qt::ShiftModifier) { + QList possibleKeys = QKeyMapper::possibleKeys(e); + int pkTotal = possibleKeys.count(); + if (!pkTotal) + return; + bool found = false; + for (int i = 0; i < possibleKeys.size(); ++i) { + if (possibleKeys.at(i) - nextKey == int(e->modifiers()) + || (possibleKeys.at(i) == nextKey && e->modifiers() == Qt::ShiftModifier)) { + nextKey = possibleKeys.at(i); + found = true; + break; + } + } + // Use as fallback + if (!found) + nextKey = possibleKeys.first(); + } else { + nextKey |= d->translateModifiers(e->modifiers(), e->text()); + } + d->key[d->keyNum] = nextKey; d->keyNum++; From 30d0e1770c3d917d5bdae5e8766e401b4f1b4c2b Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Fri, 20 Jan 2017 15:58:10 +0300 Subject: [PATCH 284/304] Use std::enable_if instead of QEnableIf Change-Id: Ideca8283141484cb6da47c50333f5c96e416f082 Reviewed-by: Edward Welbourne Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/concurrent/qtconcurrentrun.h | 24 +++++++++++----------- src/corelib/global/qnumeric_p.h | 4 ++-- src/corelib/global/qtypeinfo.h | 2 +- src/corelib/io/qdebug.h | 12 +++++------ src/corelib/kernel/qmetatype.h | 8 ++++---- src/corelib/kernel/qobject.h | 10 ++++----- src/corelib/kernel/qtimer.h | 16 +++++++-------- src/corelib/thread/qgenericatomic.h | 24 +++++++++++----------- src/corelib/thread/qthread_unix.cpp | 8 ++++---- src/corelib/tools/qarraydataops.h | 8 ++++---- src/corelib/tools/qmap.h | 4 ++-- src/corelib/tools/qsharedpointer_impl.h | 4 ++-- src/network/socket/qnativesocketengine_p.h | 4 ++-- src/testlib/qtestcase.h | 4 ++-- src/widgets/widgets/qmenu.h | 8 ++++---- src/widgets/widgets/qtoolbar.h | 8 ++++---- 16 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/concurrent/qtconcurrentrun.h b/src/concurrent/qtconcurrentrun.h index 4b45a02b50..8e7c495a0f 100644 --- a/src/concurrent/qtconcurrentrun.h +++ b/src/concurrent/qtconcurrentrun.h @@ -101,7 +101,7 @@ QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), con #if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION) template -auto run(Functor functor) -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +auto run(Functor functor) -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor()) result_type; return (new StoredFunctorCall0(functor))->start(); @@ -109,7 +109,7 @@ auto run(Functor functor) -> typename QtPrivate::QEnableIf auto run(Functor functor, const Arg1 &arg1) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1)) result_type; return (new StoredFunctorCall1(functor, arg1))->start(); @@ -117,7 +117,7 @@ auto run(Functor functor, const Arg1 &arg1) template auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1, arg2)) result_type; return (new StoredFunctorCall2(functor, arg1, arg2))->start(); @@ -125,7 +125,7 @@ auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2) template auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1, arg2, arg3)) result_type; return (new StoredFunctorCall3(functor, arg1, arg2, arg3))->start(); @@ -133,7 +133,7 @@ auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) template auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type; return (new StoredFunctorCall4(functor, arg1, arg2, arg3, arg4))->start(); @@ -141,7 +141,7 @@ auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, template auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type; return (new StoredFunctorCall5(functor, arg1, arg2, arg3, arg4, arg5))->start(); @@ -372,7 +372,7 @@ QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3, P #if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION) template -auto run(QThreadPool *pool, Functor functor) -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +auto run(QThreadPool *pool, Functor functor) -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor()) result_type; return (new StoredFunctorCall0(functor))->start(pool); @@ -380,7 +380,7 @@ auto run(QThreadPool *pool, Functor functor) -> typename QtPrivate::QEnableIf auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1)) result_type; return (new StoredFunctorCall1(functor, arg1))->start(pool); @@ -388,7 +388,7 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1) template auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1, arg2)) result_type; return (new StoredFunctorCall2(functor, arg1, arg2))->start(pool); @@ -396,7 +396,7 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2) template auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1, arg2, arg3)) result_type; return (new StoredFunctorCall3(functor, arg1, arg2, arg3))->start(pool); @@ -404,7 +404,7 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, template auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type; return (new StoredFunctorCall4(functor, arg1, arg2, arg3, arg4))->start(pool); @@ -412,7 +412,7 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, template auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) - -> typename QtPrivate::QEnableIf::Value, QFuture >::Type + -> typename std::enable_if::Value, QFuture>::type { typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type; return (new StoredFunctorCall5(functor, arg1, arg2, arg3, arg4, arg5))->start(pool); diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 01b8772ee1..62add95533 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -174,7 +174,7 @@ static inline bool qt_is_finite(float f) // Unsigned overflow math // namespace { -template inline typename QtPrivate::QEnableIf::value, bool>::Type +template inline typename std::enable_if::value, bool>::type add_overflow(T v1, T v2, T *r) { // unsigned additions are well-defined @@ -182,7 +182,7 @@ add_overflow(T v1, T v2, T *r) return v1 > T(v1 + v2); } -template inline typename QtPrivate::QEnableIf::value, bool>::Type +template inline typename std::enable_if::value, bool>::type mul_overflow(T v1, T v2, T *r) { // use the next biggest type diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 8aa5cb4fb4..53f6b3fff6 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -124,7 +124,7 @@ struct QTypeInfoQuery : public QTypeInfo // if QTypeInfo::isRelocatable exists, use it template -struct QTypeInfoQuery::isRelocatable || true>::Type> : public QTypeInfo +struct QTypeInfoQuery::isRelocatable || true>::type> : public QTypeInfo {}; /*! diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index abc2abeaec..61059dd694 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -365,7 +365,7 @@ Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaO Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name); template -typename QtPrivate::QEnableIf::Value, QDebug>::Type +typename std::enable_if::Value, QDebug>::type operator<<(QDebug dbg, T value) { const QMetaObject *obj = qt_getEnumMetaObject(value); @@ -374,9 +374,9 @@ operator<<(QDebug dbg, T value) } template -inline typename QtPrivate::QEnableIf< +inline typename std::enable_if< QtPrivate::IsQEnumHelper::Value || QtPrivate::IsQEnumHelper >::Value, - QDebug>::Type + QDebug>::type qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags &flags) { const QMetaObject *obj = qt_getEnumMetaObject(T()); @@ -385,9 +385,9 @@ qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags &flags) } template -inline typename QtPrivate::QEnableIf< +inline typename std::enable_if< !QtPrivate::IsQEnumHelper::Value && !QtPrivate::IsQEnumHelper >::Value, - QDebug>::Type + QDebug>::type qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags &flags) #else // !QT_NO_QOBJECT && !Q_QDOC template @@ -402,7 +402,7 @@ template inline QDebug operator<<(QDebug debug, const QFlags &flags) { // We have to use an indirection otherwise specialisation of some other overload of the - // operator<< the compiler would try to instantiate QFlags for the QEnableIf + // operator<< the compiler would try to instantiate QFlags for the std::enable_if return qt_QMetaEnum_flagDebugOperator_helper(debug, flags); } diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 7b0a9f986b..3674ebc1a1 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1413,17 +1413,17 @@ namespace QtPrivate static inline const QMetaObject *value() { return Q_NULLPTR; } }; template - struct MetaObjectForType::Value>::Type> + struct MetaObjectForType::Value>::type> { static inline const QMetaObject *value() { return &T::staticMetaObject; } }; template - struct MetaObjectForType::Value>::Type> + struct MetaObjectForType::Value>::type> { static inline const QMetaObject *value() { return &T::staticMetaObject; } }; template - struct MetaObjectForType::Value>::Type > + struct MetaObjectForType::Value>::type > { static inline const QMetaObject *value() { return qt_getEnumMetaObject(T()); } }; @@ -2009,7 +2009,7 @@ struct SharedPointerMetaTypeIdHelper, true> \ }; \ template \ struct MetaTypeSmartPointerHelper , \ - typename QEnableIf::Value >::Type> \ + typename std::enable_if::Value>::type> \ { \ static bool registerConverter(int id) \ { \ diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index d42eb2a13d..6941c55896 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -261,7 +261,7 @@ public: //connect to a function pointer (not a member) template - static inline typename QtPrivate::QEnableIf::ArgumentCount) >= 0, QMetaObject::Connection>::Type + static inline typename std::enable_if::ArgumentCount) >= 0, QMetaObject::Connection>::type connect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, Func2 slot) { return connect(sender, signal, sender, slot, Qt::DirectConnection); @@ -269,8 +269,8 @@ public: //connect to a function pointer (not a member) template - static inline typename QtPrivate::QEnableIf::ArgumentCount) >= 0 && - !QtPrivate::FunctionPointer::IsPointerToMemberFunction, QMetaObject::Connection>::Type + static inline typename std::enable_if::ArgumentCount) >= 0 && + !QtPrivate::FunctionPointer::IsPointerToMemberFunction, QMetaObject::Connection>::type connect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type = Qt::AutoConnection) { @@ -301,7 +301,7 @@ public: //connect to a functor template - static inline typename QtPrivate::QEnableIf::ArgumentCount == -1, QMetaObject::Connection>::Type + static inline typename std::enable_if::ArgumentCount == -1, QMetaObject::Connection>::type connect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, Func2 slot) { return connect(sender, signal, sender, slot, Qt::DirectConnection); @@ -309,7 +309,7 @@ public: //connect to a functor, with a "context" object defining in which event loop is going to be executed template - static inline typename QtPrivate::QEnableIf::ArgumentCount == -1, QMetaObject::Connection>::Type + static inline typename std::enable_if::ArgumentCount == -1, QMetaObject::Connection>::type connect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type = Qt::AutoConnection) { diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 96c7efd8f5..d3b1fd6a18 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -118,30 +118,30 @@ public: } // singleShot to a functor or function pointer (without context) template - static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && - !std::is_same::value, void>::Type + static inline typename std::enable_if::IsPointerToMemberFunction && + !std::is_same::value, void>::type singleShot(Duration interval, Func1 slot) { singleShot(interval, defaultTypeFor(interval), nullptr, slot); } template - static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && - !std::is_same::value, void>::Type + static inline typename std::enable_if::IsPointerToMemberFunction && + !std::is_same::value, void>::type singleShot(Duration interval, Qt::TimerType timerType, Func1 slot) { singleShot(interval, timerType, nullptr, slot); } // singleShot to a functor or function pointer (with context) template - static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && - !std::is_same::value, void>::Type + static inline typename std::enable_if::IsPointerToMemberFunction && + !std::is_same::value, void>::type singleShot(Duration interval, QObject *context, Func1 slot) { singleShot(interval, defaultTypeFor(interval), context, slot); } template - static inline typename QtPrivate::QEnableIf::IsPointerToMemberFunction && - !std::is_same::value, void>::Type + static inline typename std::enable_if::IsPointerToMemberFunction && + !std::is_same::value, void>::type singleShot(Duration interval, Qt::TimerType timerType, QObject *context, Func1 slot) { //compilation error if the slot has arguments. diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h index 06bb4bc8f1..5c4c02a2ec 100644 --- a/src/corelib/thread/qgenericatomic.h +++ b/src/corelib/thread/qgenericatomic.h @@ -283,7 +283,7 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndAndRelaxed(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndAndRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { // implement fetchAndAnd on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -294,7 +294,7 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndAndAcquire(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndAndAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { T tmp = BaseClass::fetchAndAndRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -302,21 +302,21 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndAndRelease(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndAndRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndAndRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndAndOrdered(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndAndOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndAndRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndOrRelaxed(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndOrRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { // implement fetchAndOr on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -327,7 +327,7 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndOrAcquire(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndOrAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { T tmp = BaseClass::fetchAndOrRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -335,21 +335,21 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndOrRelease(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndOrRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndOrRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndOrOrdered(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndOrOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndOrRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndXorRelaxed(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndXorRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { // implement fetchAndXor on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -360,7 +360,7 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndXorAcquire(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndXorAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { T tmp = BaseClass::fetchAndXorRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -368,14 +368,14 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndXorRelease(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndXorRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndXorRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndXorOrdered(T &_q_value, typename QtPrivate::QEnableIf::isIntegral, T>::Type operand) Q_DECL_NOTHROW + T fetchAndXorOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndXorRelaxed(_q_value, operand); diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index ba5f2dca95..c60742631b 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -211,25 +211,25 @@ static void clear_thread_data() } template -static typename QtPrivate::QEnableIf::isIntegral, Qt::HANDLE>::Type to_HANDLE(T id) +static typename std::enable_if::isIntegral, Qt::HANDLE>::type to_HANDLE(T id) { return reinterpret_cast(static_cast(id)); } template -static typename QtPrivate::QEnableIf::isIntegral, T>::Type from_HANDLE(Qt::HANDLE id) +static typename std::enable_if::isIntegral, T>::type from_HANDLE(Qt::HANDLE id) { return static_cast(reinterpret_cast(id)); } template -static typename QtPrivate::QEnableIf::isPointer, Qt::HANDLE>::Type to_HANDLE(T id) +static typename std::enable_if::isPointer, Qt::HANDLE>::type to_HANDLE(T id) { return id; } template -static typename QtPrivate::QEnableIf::isPointer, T>::Type from_HANDLE(Qt::HANDLE id) +static typename std::enable_if::isPointer, T>::type from_HANDLE(Qt::HANDLE id) { return static_cast(id); } diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 6bb8280ca8..47a19dd75d 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -411,18 +411,18 @@ struct QArrayOpsSelector template struct QArrayOpsSelector::isComplex && !QTypeInfo::isStatic - >::Type> + >::type> { typedef QPodArrayOps Type; }; template struct QArrayOpsSelector::isComplex && !QTypeInfo::isStatic - >::Type> + >::type> { typedef QMovableArrayOps Type; }; diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 3f4f034b4e..e6da2820f8 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -99,10 +99,10 @@ struct Q_CORE_EXPORT QMapNodeBase void setParent(QMapNodeBase *pp) { p = (p & Mask) | quintptr(pp); } template - static typename QtPrivate::QEnableIf::isComplex>::Type + static typename std::enable_if::isComplex>::type callDestructorIfNecessary(T &t) Q_DECL_NOTHROW { Q_UNUSED(t); t.~T(); } // Q_UNUSED: silence MSVC unused 't' warning template - static typename QtPrivate::QEnableIf::isComplex>::Type + static typename std::enable_if::isComplex>::type callDestructorIfNecessary(T &) Q_DECL_NOTHROW {} }; diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 5738413bfb..0d42c8a212 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -974,13 +974,13 @@ qobject_cast(const QWeakPointer &src) } template -QWeakPointer::Value, T>::Type> +QWeakPointer::Value, T>::type> qWeakPointerFromVariant(const QVariant &variant) { return QWeakPointer(qobject_cast(QtSharedPointer::weakPointerFromVariant_internal(variant).data())); } template -QSharedPointer::Value, T>::Type> +QSharedPointer::Value, T>::type> qSharedPointerFromVariant(const QVariant &variant) { return qSharedPointerObjectCast(QtSharedPointer::sharedPointerFromVariant_internal(variant)); diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 46c7ae5c55..4d1d8e1eb1 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -108,9 +108,9 @@ union qt_sockaddr { namespace { namespace SetSALen { - template void set(T *sa, typename QtPrivate::QEnableIf<(&T::sa_len, true), QT_SOCKLEN_T>::Type len) + template void set(T *sa, typename std::enable_if<(&T::sa_len, true), QT_SOCKLEN_T>::type len) { sa->sa_len = len; } - template void set(T *sin6, typename QtPrivate::QEnableIf<(&T::sin6_len, true), QT_SOCKLEN_T>::Type len) + template void set(T *sin6, typename std::enable_if<(&T::sin6_len, true), QT_SOCKLEN_T>::type len) { sin6->sin6_len = len; } template void set(T *, ...) {} } diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 058c0b3295..66f2b7c3c2 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -240,14 +240,14 @@ namespace QTest namespace Internal { template // Output registered enums - inline typename QtPrivate::QEnableIf::Value, char*>::Type toString(T e) + inline typename std::enable_if::Value, char*>::type toString(T e) { QMetaEnum me = QMetaEnum::fromType(); return qstrdup(me.valueToKey(int(e))); // int cast is necessary to support enum classes } template // Fallback - inline typename QtPrivate::QEnableIf::Value, char*>::Type toString(const T &) + inline typename std::enable_if::Value, char*>::type toString(const T &) { return Q_NULLPTR; } diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 5d218ac1ba..e9a5db1112 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -98,8 +98,8 @@ public: #else // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) template - inline typename QtPrivate::QEnableIf::value - && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::Type + inline typename std::enable_if::value + && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::type addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0) { QAction *result = addAction(text); @@ -126,8 +126,8 @@ public: } // addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context) template - inline typename QtPrivate::QEnableIf::value - && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::Type + inline typename std::enable_if::value + && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::type addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0) { QAction *result = addAction(actionIcon, text); diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index 0ea4d4afeb..e0f2d9b073 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -116,8 +116,8 @@ public: #else // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) template - inline typename QtPrivate::QEnableIf::value - && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::Type + inline typename std::enable_if::value + && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::type addAction(const QString &text, const Obj *object, Func1 slot) { QAction *result = addAction(text); @@ -134,8 +134,8 @@ public: } // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) template - inline typename QtPrivate::QEnableIf::value - && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::Type + inline typename std::enable_if::value + && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::type addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot) { QAction *result = addAction(actionIcon, text); From 1aea3c1229556d2a692194c615844579f315e3be Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Jan 2017 13:11:04 +0100 Subject: [PATCH 285/304] XCB: Use member initialization Shorten or remove constructors accordingly. Change-Id: I9c8bcf512c922c3c72be8a965d9557589bc9874f Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbclipboard.cpp | 5 - src/plugins/platforms/xcb/qxcbclipboard.h | 10 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 28 +----- src/plugins/platforms/xcb/qxcbconnection.h | 99 +++++++++---------- .../platforms/xcb/qxcbconnection_xi2.cpp | 14 +-- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 6 -- src/plugins/platforms/xcb/qxcbkeyboard.h | 14 +-- .../platforms/xcb/qxcbnativeinterface.cpp | 3 +- .../platforms/xcb/qxcbnativeinterface.h | 2 +- src/plugins/platforms/xcb/qxcbscreen.cpp | 11 --- src/plugins/platforms/xcb/qxcbscreen.h | 30 +++--- .../platforms/xcb/qxcbsystemtraytracker.cpp | 1 - .../platforms/xcb/qxcbsystemtraytracker.h | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 16 --- src/plugins/platforms/xcb/qxcbwindow.h | 42 ++++---- 15 files changed, 104 insertions(+), 179 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index cee011bbdf..6a5d40267a 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -267,11 +267,6 @@ const int QXcbClipboard::clipboard_timeout = 5000; QXcbClipboard::QXcbClipboard(QXcbConnection *c) : QXcbObject(c), QPlatformClipboard() - , m_requestor(XCB_NONE) - , m_owner(XCB_NONE) - , m_incr_active(false) - , m_clipboard_closing(false) - , m_incr_receive_time(0) { Q_ASSERT(QClipboard::Clipboard == 0); Q_ASSERT(QClipboard::Selection == 1); diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h index a0a4f4e5a1..bfeae13e10 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.h +++ b/src/plugins/platforms/xcb/qxcbclipboard.h @@ -102,14 +102,14 @@ private: QMimeData *m_clientClipboard[2]; xcb_timestamp_t m_timestamp[2]; - xcb_window_t m_requestor; - xcb_window_t m_owner; + xcb_window_t m_requestor = XCB_NONE; + xcb_window_t m_owner = XCB_NONE; static const int clipboard_timeout; - bool m_incr_active; - bool m_clipboard_closing; - xcb_timestamp_t m_incr_receive_time; + bool m_incr_active = false; + bool m_clipboard_closing = false; + xcb_timestamp_t m_incr_receive_time = 0; }; #endif // QT_NO_CLIPBOARD diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 915c29edcc..3444b21654 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -552,32 +552,10 @@ void QXcbConnection::initializeScreens() } QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName) - : m_connection(0) - , m_canGrabServer(canGrabServer) + : m_canGrabServer(canGrabServer) , m_defaultVisualId(defaultVisualId) - , m_primaryScreenNumber(0) , m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY")) , m_nativeInterface(nativeInterface) -#ifdef XCB_USE_XLIB - , m_xlib_display(0) -#endif - , xfixes_first_event(0) - , xrandr_first_event(0) - , xkb_first_event(0) - , has_xinerama_extension(false) - , has_shape_extension(false) - , has_randr_extension(false) - , has_input_shape(false) - , has_xkb(false) - , m_buttons(0) - , m_focusWindow(0) - , m_mouseGrabber(0) - , m_mousePressWindow(0) - , m_clientLeader(0) - , m_systemTrayTracker(0) - , m_glIntegration(Q_NULLPTR) - , m_xiGrab(false) - , m_qtSelectionOwner(0) { #ifdef XCB_USE_XLIB Display *dpy = XOpenDisplay(m_displayName.constData()); @@ -618,9 +596,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra initializeAllAtoms(); - m_time = XCB_CURRENT_TIME; - m_netWmUserTime = XCB_CURRENT_TIME; - if (!qEnvironmentVariableIsSet("QT_XCB_NO_XRANDR")) initializeXRandr(); if (!has_randr_extension) @@ -630,7 +605,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra initializeXRender(); #if defined(XCB_USE_XINPUT2) - m_xi2Enabled = false; initializeXInput2(); #endif initializeXShape(); diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 19c076e888..7f0d5cf2cc 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -551,10 +551,9 @@ private: void destroyScreen(QXcbScreen *screen); void initializeScreens(); bool compressEvent(xcb_generic_event_t *event, int currentIndex, QXcbEventArray *eventqueue) const; - #ifdef XCB_USE_XINPUT2 - bool m_xi2Enabled; - int m_xi2Minor; + bool m_xi2Enabled = false; + int m_xi2Minor = 2; void initializeXInput2(); void finalizeXInput2(); void xi2SetupDevices(); @@ -568,20 +567,17 @@ private: #endif // XCB_USE_XINPUT22 #ifndef QT_NO_TABLETEVENT struct TabletData { - TabletData() : deviceId(0), pointerType(QTabletEvent::UnknownPointer), - tool(QTabletEvent::Stylus), buttons(0), serialId(0), inProximity(false) { } - int deviceId; - QTabletEvent::PointerType pointerType; - QTabletEvent::TabletDevice tool; - Qt::MouseButtons buttons; - qint64 serialId; - bool inProximity; + int deviceId = 0; + QTabletEvent::PointerType pointerType = QTabletEvent::UnknownPointer; + QTabletEvent::TabletDevice tool = QTabletEvent::Stylus; + Qt::MouseButtons buttons = 0; + qint64 serialId = 0; + bool inProximity = false; struct ValuatorClassInfo { - ValuatorClassInfo() : minVal(0.), maxVal(0.), curVal(0.) { } - double minVal; - double maxVal; - double curVal; - int number; + double minVal = 0; + double maxVal = 0; + double curVal = 0; + int number = -1; }; QHash valuatorInfo; }; @@ -593,12 +589,13 @@ private: TabletData *tabletDataForDevice(int id); #endif // !QT_NO_TABLETEVENT struct ScrollingDevice { - ScrollingDevice() : deviceId(0), verticalIndex(0), horizontalIndex(0), orientations(0), legacyOrientations(0) { } - int deviceId; - int verticalIndex, horizontalIndex; - double verticalIncrement, horizontalIncrement; - Qt::Orientations orientations; - Qt::Orientations legacyOrientations; + int deviceId = 0; + int verticalIndex = 0; + int horizontalIndex = 0; + double verticalIncrement = 0; + double horizontalIncrement = 0; + Qt::Orientations orientations = 0; + Qt::Orientations legacyOrientations = 0; QPointF lastScrollPosition; }; void updateScrollingDevice(ScrollingDevice& scrollingDevice, int num_classes, void *classes); @@ -609,36 +606,36 @@ private: static void xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *event); #endif - xcb_connection_t *m_connection; - const xcb_setup_t *m_setup; - bool m_canGrabServer; - xcb_visualid_t m_defaultVisualId; + xcb_connection_t *m_connection = nullptr; + const xcb_setup_t *m_setup = nullptr; + const bool m_canGrabServer; + const xcb_visualid_t m_defaultVisualId; QList m_virtualDesktops; QList m_screens; - int m_primaryScreenNumber; + int m_primaryScreenNumber = 0; xcb_atom_t m_allAtoms[QXcbAtom::NAtoms]; - xcb_timestamp_t m_time; - xcb_timestamp_t m_netWmUserTime; + xcb_timestamp_t m_time = XCB_CURRENT_TIME; + xcb_timestamp_t m_netWmUserTime = XCB_CURRENT_TIME; QByteArray m_displayName; - QXcbKeyboard *m_keyboard; + QXcbKeyboard *m_keyboard = nullptr; #ifndef QT_NO_CLIPBOARD - QXcbClipboard *m_clipboard; + QXcbClipboard *m_clipboard = nullptr; #endif #ifndef QT_NO_DRAGANDDROP - QXcbDrag *m_drag; + QXcbDrag *m_drag = nullptr; #endif QScopedPointer m_wmSupport; - QXcbNativeInterface *m_nativeInterface; + QXcbNativeInterface *m_nativeInterface = nullptr; #if defined(XCB_USE_XLIB) - void *m_xlib_display; + void *m_xlib_display = nullptr; #endif - QXcbEventReader *m_reader; + QXcbEventReader *m_reader = nullptr; #if defined(XCB_USE_XINPUT2) QHash m_touchDevices; #ifdef XCB_USE_XINPUT22 @@ -671,29 +668,29 @@ private: QVector m_peekFuncs; - uint32_t xfixes_first_event; - uint32_t xrandr_first_event; - uint32_t xkb_first_event; + uint32_t xfixes_first_event = 0; + uint32_t xrandr_first_event = 0; + uint32_t xkb_first_event = 0; - bool has_xinerama_extension; - bool has_shape_extension; - bool has_randr_extension; + bool has_xinerama_extension = false; + bool has_shape_extension = false; + bool has_randr_extension = false; bool has_input_shape; - bool has_xkb; + bool has_xkb = false; - Qt::MouseButtons m_buttons; + Qt::MouseButtons m_buttons = 0; - QXcbWindow *m_focusWindow; - QXcbWindow *m_mouseGrabber; - QXcbWindow *m_mousePressWindow; + QXcbWindow *m_focusWindow = nullptr; + QXcbWindow *m_mouseGrabber = nullptr; + QXcbWindow *m_mousePressWindow = nullptr; - xcb_window_t m_clientLeader; + xcb_window_t m_clientLeader = 0; QByteArray m_startupId; - QXcbSystemTrayTracker *m_systemTrayTracker; - QXcbGlIntegration *m_glIntegration; - bool m_xiGrab; + QXcbSystemTrayTracker *m_systemTrayTracker = nullptr; + QXcbGlIntegration *m_glIntegration = nullptr; + bool m_xiGrab = false; - xcb_window_t m_qtSelectionOwner; + xcb_window_t m_qtSelectionOwner = 0; friend class QXcbEventReader; }; diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index d91cbfe82d..acdcc996b7 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -52,14 +52,8 @@ #include struct XInput2TouchDeviceData { - XInput2TouchDeviceData() - : xiDeviceInfo(0) - , qtTouchDevice(0) - , providesTouchOrientation(false) - { - } - XIDeviceInfo *xiDeviceInfo; - QTouchDevice *qtTouchDevice; + XIDeviceInfo *xiDeviceInfo = nullptr; + QTouchDevice *qtTouchDevice = nullptr; QHash touchPoints; QHash pointPressedPosition; // in screen coordinates where each point was pressed @@ -67,7 +61,7 @@ struct XInput2TouchDeviceData { QPointF firstPressedPosition; // in screen coordinates where the first point was pressed QPointF firstPressedNormalPosition; // device coordinates (0 to 1, 0 to 1) where the first point was pressed QSizeF size; // device size in mm - bool providesTouchOrientation; + bool providesTouchOrientation = false; }; void QXcbConnection::initializeXInput2() @@ -80,7 +74,7 @@ void QXcbConnection::initializeXInput2() Display *xDisplay = static_cast(m_xlib_display); if (XQueryExtension(xDisplay, "XInputExtension", &m_xiOpCode, &m_xiEventBase, &m_xiErrorBase)) { int xiMajor = 2; - m_xi2Minor = 2; // try 2.2 first, needed for TouchBegin/Update/End + // try 2.2 first, needed for TouchBegin/Update/End if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) { m_xi2Minor = 1; // for smooth scrolling 2.1 is enough if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) { diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index a5aff7f11f..2e29c208c7 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -1136,12 +1136,6 @@ int QXcbKeyboard::keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modi QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection) : QXcbObject(connection) - , m_autorepeat_code(0) - , xkb_context(0) - , xkb_keymap(0) - , xkb_state(0) - , latin_keymap(0) - , m_hasLatinLayout(false) { memset(&xkb_names, 0, sizeof(xkb_names)); #if QT_CONFIG(xkb) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h index dfd2926435..74f9da0353 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h @@ -106,14 +106,14 @@ protected: private: void updateXKBStateFromState(struct xkb_state *kb_state, quint16 state); - bool m_config; - xcb_keycode_t m_autorepeat_code; + bool m_config = false; + xcb_keycode_t m_autorepeat_code = 0; - struct xkb_context *xkb_context; - struct xkb_keymap *xkb_keymap; - struct xkb_state *xkb_state; + struct xkb_context *xkb_context = nullptr; + struct xkb_keymap *xkb_keymap = nullptr; + struct xkb_state *xkb_state = nullptr; struct xkb_rule_names xkb_names; - mutable struct xkb_keymap *latin_keymap; + mutable struct xkb_keymap *latin_keymap = nullptr; struct _mod_masks { uint alt; @@ -143,7 +143,7 @@ private: _mod_masks vmod_masks; int core_device_id; #endif - bool m_hasLatinLayout; + bool m_hasLatinLayout = false; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index b1575cbee4..725288633a 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -90,8 +90,7 @@ static int resourceType(const QByteArray &key) } QXcbNativeInterface::QXcbNativeInterface() : - m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t")), - m_sysTraySelectionAtom(XCB_ATOM_NONE) + m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t")) { } diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index a830829311..4186d77f4d 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -129,7 +129,7 @@ private: const QByteArray m_genericEventFilterType; - xcb_atom_t m_sysTraySelectionAtom; + xcb_atom_t m_sysTraySelectionAtom = XCB_ATOM_NONE; static QXcbScreen *qPlatformScreenForWindow(QWindow *window); diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index a9675935f4..736b4852d8 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -59,7 +59,6 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t : QXcbObject(connection) , m_screen(screen) , m_number(number) - , m_xSettings(Q_NULLPTR) { const QByteArray cmAtomName = "_NET_WM_CM_S" + QByteArray::number(m_number); m_net_wm_cm_atom = connection->internAtom(cmAtomName.constData()); @@ -175,20 +174,10 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe , m_virtualDesktop(virtualDesktop) , m_output(outputId) , m_crtc(output ? output->crtc : XCB_NONE) - , m_mode(XCB_NONE) - , m_primary(false) - , m_rotation(XCB_RANDR_ROTATION_ROTATE_0) , m_outputName(getOutputName(output)) , m_outputSizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize()) , m_virtualSize(virtualDesktop->size()) , m_virtualSizeMillimeters(virtualDesktop->physicalSize()) - , m_orientation(Qt::PrimaryOrientation) - , m_refreshRate(60) - , m_forcedDpi(-1) - , m_pixelDensity(1) - , m_hintStyle(QFontEngine::HintStyle(-1)) - , m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1)) - , m_antialiasingEnabled(-1) { if (connection->hasXRandr()) { xcb_randr_select_input(xcb_connection(), screen()->root, true); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 627397fcaf..4163be2969 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -95,12 +95,12 @@ private: QRect getWorkArea() const; xcb_screen_t *m_screen; - int m_number; + const int m_number; QList m_screens; - QXcbXSettings *m_xSettings; - xcb_atom_t m_net_wm_cm_atom; - bool m_compositingActive; + QXcbXSettings *m_xSettings = nullptr; + xcb_atom_t m_net_wm_cm_atom = 0; + bool m_compositingActive = false; QRect m_workArea; }; @@ -186,9 +186,9 @@ private: QXcbVirtualDesktop *m_virtualDesktop; xcb_randr_output_t m_output; xcb_randr_crtc_t m_crtc; - xcb_randr_mode_t m_mode; - bool m_primary; - uint8_t m_rotation; + xcb_randr_mode_t m_mode = XCB_NONE; + bool m_primary = false; + uint8_t m_rotation = XCB_RANDR_ROTATION_ROTATE_0; QString m_outputName; QSizeF m_outputSizeMillimeters; @@ -197,18 +197,18 @@ private: QRect m_availableGeometry; QSize m_virtualSize; QSizeF m_virtualSizeMillimeters; - Qt::ScreenOrientation m_orientation; + Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation; QString m_windowManagerName; - bool m_syncRequestSupported; + bool m_syncRequestSupported = false; QMap m_visuals; QMap m_visualDepths; QXcbCursor *m_cursor; - int m_refreshRate; - int m_forcedDpi; - int m_pixelDensity; - QFontEngine::HintStyle m_hintStyle; - QFontEngine::SubpixelAntialiasingType m_subpixelType; - int m_antialiasingEnabled; + int m_refreshRate = 60; + int m_forcedDpi = -1; + int m_pixelDensity = 1; + QFontEngine::HintStyle m_hintStyle = QFontEngine::HintStyle(-1); + QFontEngine::SubpixelAntialiasingType m_subpixelType = QFontEngine::SubpixelAntialiasingType(-1); + int m_antialiasingEnabled = -1; }; #ifndef QT_NO_DEBUG_STREAM diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp index 5522af86de..fb0a4a3939 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp @@ -80,7 +80,6 @@ QXcbSystemTrayTracker::QXcbSystemTrayTracker(QXcbConnection *connection, , m_selection(selection) , m_trayAtom(trayAtom) , m_connection(connection) - , m_trayWindow(0) { } diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h index a6131e6d0e..a95b9374e9 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h @@ -77,7 +77,7 @@ private: const xcb_atom_t m_selection; const xcb_atom_t m_trayAtom; QXcbConnection *m_connection; - xcb_window_t m_trayWindow; + xcb_window_t m_trayWindow = 0; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 2d52f5dd46..756806108e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -314,22 +314,6 @@ static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; QXcbWindow::QXcbWindow(QWindow *window) : QPlatformWindow(window) - , m_window(0) - , m_cmap(0) - , m_syncCounter(0) - , m_gravity(XCB_GRAVITY_STATIC) - , m_mapped(false) - , m_transparent(false) - , m_usingSyncProtocol(false) - , m_deferredActivation(false) - , m_embedded(false) - , m_alertState(false) - , m_netWmUserTimeWindow(XCB_NONE) - , m_dirtyFrameMargins(false) - , m_lastWindowStateEvent(-1) - , m_syncState(NoSyncNeeded) - , m_pendingSyncRequest(0) - , m_currentBitmapCursor(XCB_CURSOR_NONE) { setConnection(xcbScreen()->connection()); } diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 680629c040..b4d947e700 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -233,48 +233,48 @@ protected: void handleLeaveNotifyEvent(int root_x, int root_y, quint8 mode, quint8 detail, xcb_timestamp_t timestamp); - xcb_window_t m_window; - xcb_colormap_t m_cmap; + xcb_window_t m_window = 0; + xcb_colormap_t m_cmap = 0; - uint m_depth; - QImage::Format m_imageFormat; - bool m_imageRgbSwap; + uint m_depth = 0; + QImage::Format m_imageFormat = QImage::Format_ARGB32_Premultiplied; + bool m_imageRgbSwap = false; xcb_sync_int64_t m_syncValue; - xcb_sync_counter_t m_syncCounter; + xcb_sync_counter_t m_syncCounter = 0; - Qt::WindowState m_windowState; + Qt::WindowState m_windowState = Qt::WindowNoState; - xcb_gravity_t m_gravity; + xcb_gravity_t m_gravity = XCB_GRAVITY_STATIC; - bool m_mapped; - bool m_transparent; - bool m_usingSyncProtocol; - bool m_deferredActivation; - bool m_embedded; - bool m_alertState; - xcb_window_t m_netWmUserTimeWindow; + bool m_mapped = false; + bool m_transparent = false; + bool m_usingSyncProtocol = false; + bool m_deferredActivation = false; + bool m_embedded = false; + bool m_alertState = false; + xcb_window_t m_netWmUserTimeWindow = XCB_NONE; QSurfaceFormat m_format; - mutable bool m_dirtyFrameMargins; + mutable bool m_dirtyFrameMargins = false; mutable QMargins m_frameMargins; QRegion m_exposeRegion; QSize m_oldWindowSize; - xcb_visualid_t m_visualId; - int m_lastWindowStateEvent; + xcb_visualid_t m_visualId = 0; + int m_lastWindowStateEvent = -1; enum SyncState { NoSyncNeeded, SyncReceived, SyncAndConfigureReceived }; - SyncState m_syncState; + SyncState m_syncState = NoSyncNeeded; - QXcbSyncWindowRequest *m_pendingSyncRequest; - xcb_cursor_t m_currentBitmapCursor; + QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr; + xcb_cursor_t m_currentBitmapCursor = XCB_CURSOR_NONE; }; QT_END_NAMESPACE From ce3402b5efc929b99d6ecb27f47e671cdcfae393 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 19 Jan 2015 11:29:52 +0100 Subject: [PATCH 286/304] QSizePolicy: add some constexpr Also add a basic test for constexpr expressions involving QSizePolicy. GCC < 4.8.0 has problems with initializing variant members in constexpr ctors: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 Instead of revoking its Q_COMPILER_CONSTEXPR, which is a source-incompatible change, simply note the fact so we can selectively provide constexpr for QSizePolicy. Change-Id: Iba8e5a7cdf847d73e8e2b6bb6211fb3c9846aa0a Reviewed-by: Thiago Macieira --- doc/global/qt-cpp-defines.qdocconf | 1 + src/widgets/kernel/qsizepolicy.h | 38 ++++++++++++------- .../kernel/qsizepolicy/qsizepolicy.pro | 1 + .../kernel/qsizepolicy/tst_qsizepolicy.cpp | 14 +++++++ 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/doc/global/qt-cpp-defines.qdocconf b/doc/global/qt-cpp-defines.qdocconf index 8ac5b70bbb..fc3f78b925 100644 --- a/doc/global/qt-cpp-defines.qdocconf +++ b/doc/global/qt-cpp-defines.qdocconf @@ -171,6 +171,7 @@ Cpp.ignoretokens += \ QT_END_NAMESPACE \ QT_FASTCALL \ QT_MUTEX_LOCK_NOEXCEPT \ + QT_SIZEPOLICY_CONSTEXPR \ QT_WARNING_DISABLE_DEPRECATED \ QT_WARNING_PUSH \ QT_WARNING_POP \ diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 3934c0f1d0..a0098cfd74 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -45,6 +45,15 @@ QT_BEGIN_NAMESPACE +// gcc < 4.8.0 has problems with init'ing variant members in constexpr ctors +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 +#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || Q_CC_GNU >= 408 +# define QT_SIZEPOLICY_CONSTEXPR Q_DECL_CONSTEXPR +#endif + +#ifndef QT_SIZEPOLICY_CONSTEXPR +# define QT_SIZEPOLICY_CONSTEXPR +#endif class QVariant; class QSizePolicy; @@ -94,7 +103,7 @@ public: Q_DECLARE_FLAGS(ControlTypes, ControlType) Q_FLAG(ControlTypes) - QSizePolicy() : data(0) { } + QT_SIZEPOLICY_CONSTEXPR QSizePolicy() : data(0) { } QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) : data(0) { @@ -102,48 +111,47 @@ public: bits.verPolicy = vertical; setControlType(type); } - Policy horizontalPolicy() const { return static_cast(bits.horPolicy); } - Policy verticalPolicy() const { return static_cast(bits.verPolicy); } + QT_SIZEPOLICY_CONSTEXPR Policy horizontalPolicy() const { return static_cast(bits.horPolicy); } + QT_SIZEPOLICY_CONSTEXPR Policy verticalPolicy() const { return static_cast(bits.verPolicy); } ControlType controlType() const; void setHorizontalPolicy(Policy d) { bits.horPolicy = d; } void setVerticalPolicy(Policy d) { bits.verPolicy = d; } void setControlType(ControlType type); - Qt::Orientations expandingDirections() const { + QT_SIZEPOLICY_CONSTEXPR Qt::Orientations expandingDirections() const { return ( (verticalPolicy() & ExpandFlag) ? Qt::Vertical : Qt::Orientations() ) | ( (horizontalPolicy() & ExpandFlag) ? Qt::Horizontal : Qt::Orientations() ) ; } - void setHeightForWidth(bool b) { bits.hfw = b; } - bool hasHeightForWidth() const { return bits.hfw; } + void setHeightForWidth(bool b) { bits.hfw = b; } + QT_SIZEPOLICY_CONSTEXPR bool hasHeightForWidth() const { return bits.hfw; } void setWidthForHeight(bool b) { bits.wfh = b; } - bool hasWidthForHeight() const { return bits.wfh; } + QT_SIZEPOLICY_CONSTEXPR bool hasWidthForHeight() const { return bits.wfh; } - bool operator==(const QSizePolicy& s) const { return data == s.data; } - bool operator!=(const QSizePolicy& s) const { return data != s.data; } + QT_SIZEPOLICY_CONSTEXPR bool operator==(const QSizePolicy& s) const { return data == s.data; } + QT_SIZEPOLICY_CONSTEXPR bool operator!=(const QSizePolicy& s) const { return data != s.data; } friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) Q_DECL_NOTHROW { return qHash(key.data, seed); } operator QVariant() const; - int horizontalStretch() const { return static_cast(bits.horStretch); } - int verticalStretch() const { return static_cast(bits.verStretch); } + QT_SIZEPOLICY_CONSTEXPR int horizontalStretch() const { return static_cast(bits.horStretch); } + QT_SIZEPOLICY_CONSTEXPR int verticalStretch() const { return static_cast(bits.verStretch); } void setHorizontalStretch(int stretchFactor) { bits.horStretch = static_cast(qBound(0, stretchFactor, 255)); } void setVerticalStretch(int stretchFactor) { bits.verStretch = static_cast(qBound(0, stretchFactor, 255)); } - bool retainSizeWhenHidden() const { return bits.retainSizeWhenHidden; } + QT_SIZEPOLICY_CONSTEXPR bool retainSizeWhenHidden() const { return bits.retainSizeWhenHidden; } void setRetainSizeWhenHidden(bool retainSize) { bits.retainSizeWhenHidden = retainSize; } void transpose(); - private: #ifndef QT_NO_DATASTREAM friend Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &); friend Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); #endif - QSizePolicy(int i) : data(i) { } + QT_SIZEPOLICY_CONSTEXPR QSizePolicy(int i) : data(i) { } struct Bits { quint32 horStretch : 8; @@ -187,6 +195,8 @@ inline void QSizePolicy::transpose() { setVerticalStretch(hStretch); } +#undef QT_SIZEPOLICY_CONSTEXPR + QT_END_NAMESPACE #endif // QSIZEPOLICY_H diff --git a/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro b/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro index 84629c7c0a..d325bc4aeb 100644 --- a/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro +++ b/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro @@ -1,4 +1,5 @@ CONFIG += testcase +contains(QT_CONFIG, c++14): CONFIG += c++14 TARGET = tst_qsizepolicy QT += widgets widgets-private testlib diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp index cd5aa03689..15bd0a8c1c 100644 --- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp +++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp @@ -41,6 +41,7 @@ class tst_QSizePolicy : public QObject private Q_SLOTS: void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void qtest(); + void constExpr(); void defaultValues(); void getSetCheck_data() { data(); } void getSetCheck(); @@ -102,6 +103,19 @@ void tst_QSizePolicy::qtest() #undef CHECK2 } +void tst_QSizePolicy::constExpr() +{ +/* gcc < 4.8.0 has problems with init'ing variant members in constexpr ctors */ +/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 */ +#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || Q_CC_GNU >= 408 + // check that certain ctors are constexpr (compile-only): + { Q_CONSTEXPR QSizePolicy sp; Q_UNUSED(sp); } + { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(); Q_UNUSED(sp); } +#else + QSKIP("QSizePolicy cannot be constexpr with this version of the compiler."); +#endif +} + void tst_QSizePolicy::defaultValues() { { From 8b9b27bced5227fae0f44a92a24183f38c944c02 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 17 Dec 2014 16:19:27 +0100 Subject: [PATCH 287/304] QSizePolicy: add a transposed() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some situations, this allows for nicer code. It's also possible to make this constexpr in C++11, whereas the mutable transpose() would require C++14-style constexpr. The new function should also be faster, since it just swaps the member variables. Because of constexpr-function limitations, the way the return value is constructed needs to depend on the level of the compiler's C++11 support. This is not the only class that requires uniform init to provide a fully constexpr interface (QUuid and QBasicAtomic come to mind), so this should probably be generalized across Qt at some point. Added tests. [ChangeLog][QtWidgets][QSizePolicy] Added transposed() method. Change-Id: Ic1077a0d5a861e7c63bd1daeeb42b97c3a2f71ef Reviewed-by: Sérgio Martins --- src/widgets/kernel/qsizepolicy.cpp | 12 ++++++ src/widgets/kernel/qsizepolicy.h | 38 +++++++++++++++++++ .../kernel/qsizepolicy/tst_qsizepolicy.cpp | 22 +++++++++++ 3 files changed, 72 insertions(+) diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp index e902bb522c..34ad64217b 100644 --- a/src/widgets/kernel/qsizepolicy.cpp +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -395,6 +395,18 @@ void QSizePolicy::setControlType(ControlType type) \fn void QSizePolicy::transpose() Swaps the horizontal and vertical policies and stretches. + + \sa transposed() +*/ + +/*! + \fn QSizePolicy QSizePolicy::transposed() + \since 5.9 + + Returns a size policy object with the horizontal and vertical + policies and stretches swapped. + + \sa transpose() */ /*! diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index a0098cfd74..80bc8eacdb 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -49,11 +49,25 @@ QT_BEGIN_NAMESPACE // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 #if !defined(Q_CC_GNU) || defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || Q_CC_GNU >= 408 # define QT_SIZEPOLICY_CONSTEXPR Q_DECL_CONSTEXPR +# if defined(Q_COMPILER_UNIFORM_INIT) +# define QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT Q_DECL_CONSTEXPR +# if defined(Q_COMPILER_CONSTEXPR) +# define QT_SIZEPOLICY_RETURN_BITS(E1, E2, E3, E4, E5, E6, E7, E8) \ + return Bits{ E1, E2, E3, E4, E5, E6, E7, E8 } +# endif // constexpr && uniform-init +# endif // uniform-init #endif #ifndef QT_SIZEPOLICY_CONSTEXPR # define QT_SIZEPOLICY_CONSTEXPR #endif +#ifndef QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT +# define QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT +#endif +#ifndef QT_SIZEPOLICY_RETURN_BITS +# define QT_SIZEPOLICY_RETURN_BITS(E1, E2, E3, E4, E5, E6, E7, E8) \ + const Bits result = { E1, E2, E3, E4, E5, E6, E7, E8 }; return result +#endif class QVariant; class QSizePolicy; @@ -145,6 +159,13 @@ public: void setRetainSizeWhenHidden(bool retainSize) { bits.retainSizeWhenHidden = retainSize; } void transpose(); +#ifndef Q_QDOC + QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT +#endif + QSizePolicy transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { + return QSizePolicy(bits.transposed()); + } private: #ifndef QT_NO_DATASTREAM @@ -152,6 +173,8 @@ private: friend Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); #endif QT_SIZEPOLICY_CONSTEXPR QSizePolicy(int i) : data(i) { } + struct Bits; + QT_SIZEPOLICY_CONSTEXPR explicit QSizePolicy(Bits b) Q_DECL_NOTHROW : bits(b) { } struct Bits { quint32 horStretch : 8; @@ -162,6 +185,19 @@ private: quint32 hfw : 1; quint32 wfh : 1; quint32 retainSizeWhenHidden : 1; + + QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT + Bits transposed() const Q_DECL_NOTHROW + { + QT_SIZEPOLICY_RETURN_BITS(verStretch, // \ swap + horStretch, // / + verPolicy, // \ swap + horPolicy, // / + ctype, + hfw, // \ don't swap (historic behavior) + wfh, // / + retainSizeWhenHidden); + } }; union { Bits bits; @@ -196,6 +232,8 @@ inline void QSizePolicy::transpose() { } #undef QT_SIZEPOLICY_CONSTEXPR +#undef QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT +#undef QT_SIZEPOLICY_RETURN_BITS QT_END_NAMESPACE diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp index 15bd0a8c1c..98b765a6c6 100644 --- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp +++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp @@ -45,6 +45,8 @@ private Q_SLOTS: void defaultValues(); void getSetCheck_data() { data(); } void getSetCheck(); + void transposed_data() { data(); } + void transposed(); void dataStream(); void horizontalStretch(); void verticalStretch(); @@ -161,6 +163,26 @@ void tst_QSizePolicy::getSetCheck() QCOMPARE(sp.expandingDirections(), ed); } +void tst_QSizePolicy::transposed() +{ + FETCH_TEST_DATA; + + const QSizePolicy tr = sp.transposed(); + + QCOMPARE(tr.horizontalPolicy(), vp); // swapped + QCOMPARE(tr.verticalPolicy(), hp); // swapped + QCOMPARE(tr.horizontalStretch(), vst); // swapped + QCOMPARE(tr.verticalStretch(), hst); // swapped + QCOMPARE(tr.controlType(), ct); // not swapped + QCOMPARE(tr.hasHeightForWidth(), hfw); // not swapped (historic behavior) + QCOMPARE(tr.hasWidthForHeight(), wfh); // not swapped (historic behavior) + QCOMPARE(tr.expandingDirections(), ed); // swapped + + // destructive test - keep last: + sp.transpose(); + QCOMPARE(sp, tr); +} + static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy vp, int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh, Qt::Orientations orients) From 5ad191850becd7dc1d61d0975f141a5db64e6373 Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Wed, 14 Dec 2016 06:37:39 +0100 Subject: [PATCH 288/304] Modes API for QPlatformScreen Add an API for modes (that is screen size and refresh rate). This will allow platform plugins to list modes available for a screen. [ChangeLog][QtGui][QPA] Add an API for modes. Change-Id: I91851c51cc60a1544465dfa3b4d96cc667237a0a Reviewed-by: Laszlo Agocs --- src/gui/kernel/qplatformscreen.cpp | 49 ++++++++++++++++++++++++++++++ src/gui/kernel/qplatformscreen.h | 10 ++++++ 2 files changed, 59 insertions(+) diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index bbe984bebe..e22037c1e9 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -533,4 +533,53 @@ void QPlatformScreen::setPowerState(PowerState state) Q_UNUSED(state); } +/*! + Reimplement this function in subclass to return the list + of modes for this screen. + + The default implementation returns a list with + only one mode from the current screen size and refresh rate. + + \sa QPlatformScreen::geometry + \sa QPlatformScreen::refreshRate + + \since 5.9 +*/ +QVector QPlatformScreen::modes() const +{ + QVector list; + list.append({geometry().size(), refreshRate()}); + return list; +} + +/*! + Reimplement this function in subclass to return the + index of the current mode from the modes list. + + The default implementation returns 0. + + \sa QPlatformScreen::modes + + \since 5.9 +*/ +int QPlatformScreen::currentMode() const +{ + return 0; +} + +/*! + Reimplement this function in subclass to return the preferred + mode index from the modes list. + + The default implementation returns 0. + + \sa QPlatformScreen::modes + + \since 5.9 +*/ +int QPlatformScreen::preferredMode() const +{ + return 0; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index aa32917b6c..97fe3fed03 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -95,6 +95,11 @@ public: PowerStateOff }; + struct Mode { + QSize size; + qreal refreshRate; + }; + QPlatformScreen(); virtual ~QPlatformScreen(); @@ -139,6 +144,11 @@ public: virtual PowerState powerState() const; virtual void setPowerState(PowerState state); + virtual QVector modes() const; + + virtual int currentMode() const; + virtual int preferredMode() const; + static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b); static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target); static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect); From 84fa396d84103770a345a06f7cf151ae17c00b67 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 30 Jan 2017 10:24:41 +0100 Subject: [PATCH 289/304] SecureTransport - remove (now) redundant standalone function It was first introduced when we had to work-around old macOS SDK (<= 10.7) with missing API; so we split the original code into two functions, one for iOS (any supported version) and macOS > 10.7, another function (with all ifdefs needed and old, deprecated API usage) for macOS <= 10.7. Now that support for those versions was dropped and the second function gone, having the remaining code in some external function looks illogical. It can be moved into the member-function back. Change-Id: Ib6355f225b5df3d92a70bd7679545cc89c450228 Reviewed-by: Jake Petroules --- src/network/ssl/qsslsocket_mac.cpp | 176 ++++++++++++++--------------- 1 file changed, 82 insertions(+), 94 deletions(-) diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 0548aa3909..752640bd46 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -82,98 +82,6 @@ static void qt_releaseSecureTransportContext(SSLContextRef context) CFRelease(context); } -static bool qt_setSessionProtocol(SSLContextRef context, const QSslConfigurationPrivate &configuration, - QTcpSocket *plainSocket) -{ - Q_ASSERT(context); - -#ifndef QSSLSOCKET_DEBUG - Q_UNUSED(plainSocket) -#endif - - OSStatus err = noErr; - - if (configuration.protocol == QSsl::SslV3) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : SSLv3"; - #endif - err = SSLSetProtocolVersionMin(context, kSSLProtocol3); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kSSLProtocol3); - } else if (configuration.protocol == QSsl::TlsV1_0) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.0"; - #endif - err = SSLSetProtocolVersionMin(context, kTLSProtocol1); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol1); - } else if (configuration.protocol == QSsl::TlsV1_1) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.1"; - #endif - err = SSLSetProtocolVersionMin(context, kTLSProtocol11); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol11); - } else if (configuration.protocol == QSsl::TlsV1_2) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.2"; - #endif - err = SSLSetProtocolVersionMin(context, kTLSProtocol12); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol12); - } else if (configuration.protocol == QSsl::AnyProtocol) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : any"; - #endif - // kSSLProtocol3, since kSSLProtocol2 is disabled: - err = SSLSetProtocolVersionMin(context, kSSLProtocol3); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol12); - } else if (configuration.protocol == QSsl::TlsV1SslV3) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : SSLv3 - TLSv1.2"; - #endif - err = SSLSetProtocolVersionMin(context, kSSLProtocol3); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol12); - } else if (configuration.protocol == QSsl::SecureProtocols) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2"; - #endif - err = SSLSetProtocolVersionMin(context, kTLSProtocol1); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol12); - } else if (configuration.protocol == QSsl::TlsV1_0OrLater) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2"; - #endif - err = SSLSetProtocolVersionMin(context, kTLSProtocol1); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol12); - } else if (configuration.protocol == QSsl::TlsV1_1OrLater) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.1 - TLSv1.2"; - #endif - err = SSLSetProtocolVersionMin(context, kTLSProtocol11); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol12); - } else if (configuration.protocol == QSsl::TlsV1_2OrLater) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.2"; - #endif - err = SSLSetProtocolVersionMin(context, kTLSProtocol12); - if (err == noErr) - err = SSLSetProtocolVersionMax(context, kTLSProtocol12); - } else { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "no protocol version found in the configuration"; - #endif - return false; - } - - return err == noErr; -} - QSecureTransportContext::QSecureTransportContext(SSLContextRef c) : context(c) { @@ -956,7 +864,7 @@ bool QSslSocketBackendPrivate::setSessionProtocol() { Q_ASSERT_X(context, Q_FUNC_INFO, "invalid SSL context (null)"); - // QSsl::SslV2 == kSSLProtocol2 is disabled in secure transport and + // QSsl::SslV2 == kSSLProtocol2 is disabled in Secure Transport and // always fails with errSSLIllegalParam: // if (version < MINIMUM_STREAM_VERSION || version > MAXIMUM_STREAM_VERSION) // return errSSLIllegalParam; @@ -966,7 +874,87 @@ bool QSslSocketBackendPrivate::setSessionProtocol() return false; } - return qt_setSessionProtocol(context, configuration, plainSocket); + OSStatus err = noErr; + + if (configuration.protocol == QSsl::SslV3) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : SSLv3"; + #endif + err = SSLSetProtocolVersionMin(context, kSSLProtocol3); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kSSLProtocol3); + } else if (configuration.protocol == QSsl::TlsV1_0) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.0"; + #endif + err = SSLSetProtocolVersionMin(context, kTLSProtocol1); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol1); + } else if (configuration.protocol == QSsl::TlsV1_1) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.1"; + #endif + err = SSLSetProtocolVersionMin(context, kTLSProtocol11); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol11); + } else if (configuration.protocol == QSsl::TlsV1_2) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.2"; + #endif + err = SSLSetProtocolVersionMin(context, kTLSProtocol12); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol12); + } else if (configuration.protocol == QSsl::AnyProtocol) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : any"; + #endif + // kSSLProtocol3, since kSSLProtocol2 is disabled: + err = SSLSetProtocolVersionMin(context, kSSLProtocol3); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol12); + } else if (configuration.protocol == QSsl::TlsV1SslV3) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : SSLv3 - TLSv1.2"; + #endif + err = SSLSetProtocolVersionMin(context, kSSLProtocol3); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol12); + } else if (configuration.protocol == QSsl::SecureProtocols) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2"; + #endif + err = SSLSetProtocolVersionMin(context, kTLSProtocol1); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol12); + } else if (configuration.protocol == QSsl::TlsV1_0OrLater) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2"; + #endif + err = SSLSetProtocolVersionMin(context, kTLSProtocol1); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol12); + } else if (configuration.protocol == QSsl::TlsV1_1OrLater) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.1 - TLSv1.2"; + #endif + err = SSLSetProtocolVersionMin(context, kTLSProtocol11); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol12); + } else if (configuration.protocol == QSsl::TlsV1_2OrLater) { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.2"; + #endif + err = SSLSetProtocolVersionMin(context, kTLSProtocol12); + if (err == noErr) + err = SSLSetProtocolVersionMax(context, kTLSProtocol12); + } else { + #ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "no protocol version found in the configuration"; + #endif + return false; + } + + return err == noErr; } bool QSslSocketBackendPrivate::canIgnoreTrustVerificationFailure() const From ad4f7b59ead6c4eb17e787bce25a7211b866063f Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 30 Jan 2017 04:02:10 -0800 Subject: [PATCH 290/304] Fix iOS build This fixes a regression introduced in the merge 318b5856. Due to the removal of actual simulator_and_device in 5.8 (397f345a6), conditions using it have become meaningless. Task-number: QTBUG-58440 Change-Id: I9f874f9f85efa590c40602dbcd07793ff17d35f5 Reviewed-by: Oswald Buddenhagen Reviewed-by: Liang Qi --- mkspecs/features/mac/default_post.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 623a348684..1df6c4f8b2 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -88,7 +88,7 @@ macx-xcode { tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET - # If we're doing a simulator_and_device build, device and simulator + # If we're doing a simulator and device build, device and simulator # architectures use different paths and flags for the sysroot and # deployment target switch, so we must multiplex them across multiple # architectures using -Xarch. Otherwise we fall back to the simple path. @@ -96,7 +96,7 @@ macx-xcode { # and makes it easier for people to override EXPORT_VALID_ARCHS to limit # individual rules to a different set of architecture(s) from the overall # build (such as machtest in QtCore). - simulator_and_device { + simulator:device { QMAKE_XARCH_CFLAGS = QMAKE_XARCH_LFLAGS = QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS From 85468f7bccb276c2be5801481a6ce10f07581cdb Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 20 Dec 2016 16:17:58 +0100 Subject: [PATCH 291/304] Manually vectorize ARGB32toARGB32PM for SSE4.1 and NEON Manually vectorizing is significantly faster because we can optimize for common cases like long stretches of opaque or transparent pixels. This is both smaller and faster than the auto-vectorized version, it is also much faster than the autovectorized version for AVX2 which then can be removed. Change-Id: I0fa80ce273a8387cc6cd084879822ad9bade385c Reviewed-by: Thiago Macieira --- src/gui/painting/qdrawhelper.cpp | 23 +++++----- src/gui/painting/qdrawhelper_avx2.cpp | 13 ------ src/gui/painting/qdrawhelper_neon.cpp | 61 +++++++++++++++++++++++++++ src/gui/painting/qdrawhelper_sse4.cpp | 55 +++++++++++++++++++++++- 4 files changed, 125 insertions(+), 27 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 9b5f15470e..4ea3b37d5f 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6196,20 +6196,18 @@ static void qInitDrawhelperFunctions() #if defined(QT_COMPILER_SUPPORTS_SSE4_1) if (qCpuHasFeature(SSE4_1)) { -#if !defined(__SSE4_1__) extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector *, QDitherInfo *); extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector *, QDitherInfo *); - qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_sse4; - qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_sse4; -#endif extern const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector *, QDitherInfo *); extern const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector *, QDitherInfo *); extern const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector *, QDitherInfo *); + qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_sse4; + qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_sse4; qPixelLayouts[QImage::Format_ARGB32].convertFromARGB32PM = convertARGB32FromARGB32PM_sse4; qPixelLayouts[QImage::Format_RGBA8888].convertFromARGB32PM = convertRGBA8888FromARGB32PM_sse4; qPixelLayouts[QImage::Format_RGBX8888].convertFromARGB32PM = convertRGBXFromARGB32PM_sse4; @@ -6220,14 +6218,6 @@ static void qInitDrawhelperFunctions() #if defined(QT_COMPILER_SUPPORTS_AVX2) if (qCpuHasFeature(AVX2)) { -#if !defined(__AVX2__) - extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count, - const QVector *, QDitherInfo *); - extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count, - const QVector *, QDitherInfo *); - qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_avx2; - qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_avx2; -#endif extern void qt_blend_rgb32_on_rgb32_avx2(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha); @@ -6277,6 +6267,15 @@ static void qInitDrawhelperFunctions() sourceFetchUntransformed[QImage::Format_RGB888] = qt_fetchUntransformed_888_neon; +#if defined(Q_PROCESSOR_ARM_64) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN + extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_neon(uint *buffer, const uint *src, int count, + const QVector *, QDitherInfo *); + extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_neon(uint *buffer, const uint *src, int count, + const QVector *, QDitherInfo *); + qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_neon; + qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_neon; +#endif + #if defined(ENABLE_PIXMAN_DRAWHELPERS) // The RGB16 helpers are using Arm32 assemblythat has not been ported to AArch64 qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16_neon; diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp index 9c1335298e..5e17e8abec 100644 --- a/src/gui/painting/qdrawhelper_avx2.cpp +++ b/src/gui/painting/qdrawhelper_avx2.cpp @@ -44,19 +44,6 @@ QT_BEGIN_NAMESPACE -// Autovectorized premultiply functions: -const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count, - const QVector *, QDitherInfo *) -{ - return qt_convertARGB32ToARGB32PM(buffer, src, count); -} - -const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count, - const QVector *, QDitherInfo *) -{ - return qt_convertRGBA8888ToARGB32PM(buffer, src, count); -} - // Vectorized blend functions: // See BYTE_MUL_SSE2 for details. diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp index cdb374f823..643c570f65 100644 --- a/src/gui/painting/qdrawhelper_neon.cpp +++ b/src/gui/painting/qdrawhelper_neon.cpp @@ -1069,6 +1069,67 @@ const uint * QT_FASTCALL qt_fetchUntransformed_888_neon(uint *buffer, const Oper return buffer; } +#if defined(Q_PROCESSOR_ARM_64) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN +template +static inline void convertARGBToARGB32PM_neon(uint *buffer, const uint *src, int count) +{ + int i = 0; + const uint8x16_t rgbaMask = { 2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15}; + const uint8x8_t shuffleMask = { 3, 3, 3, 3, 7, 7, 7, 7}; + const uint32x4_t blendMask = vdupq_n_u32(0xff000000); + + for (; i < count - 3; i += 4) { + uint32x4_t srcVector = vld1q_u32(src + i); + uint32x4_t alphaVector = vshrq_n_u32(srcVector, 24); + uint32_t alphaSum = vaddvq_u32(alphaVector); + if (alphaSum) { + if (alphaSum != 255 * 4) { + if (RGBA) + srcVector = vreinterpretq_u32_u8(vqtbl1q_u8(vreinterpretq_u8_u32(srcVector), rgbaMask)); + const uint8x8_t s1 = vreinterpret_u8_u32(vget_low_u32(srcVector)); + const uint8x8_t s2 = vreinterpret_u8_u32(vget_high_u32(srcVector)); + const uint8x8_t alpha1 = vtbl1_u8(s1, shuffleMask); + const uint8x8_t alpha2 = vtbl1_u8(s2, shuffleMask); + uint16x8_t src1 = vmull_u8(s1, alpha1); + uint16x8_t src2 = vmull_u8(s2, alpha2); + src1 = vsraq_n_u16(src1, src1, 8); + src2 = vsraq_n_u16(src2, src2, 8); + const uint8x8_t d1 = vrshrn_n_u16(src1, 8); + const uint8x8_t d2 = vrshrn_n_u16(src2, 8); + const uint32x4_t d = vbslq_u32(blendMask, srcVector, vreinterpretq_u32_u8(vcombine_u8(d1, d2))); + vst1q_u32(buffer + i, d); + } else { + if (RGBA) + vst1q_u32(buffer + i, vreinterpretq_u32_u8(vqtbl1q_u8(vreinterpretq_u8_u32(srcVector), rgbaMask))); + else if (buffer != src) + vst1q_u32(buffer + i, srcVector); + } + } else { + vst1q_u32(buffer + i, vdupq_n_u32(0)); + } + } + + SIMD_EPILOGUE(i, count, 3) { + uint v = qPremultiply(src[i]); + buffer[i] = RGBA ? RGBA2ARGB(v) : v; + } +} + +const uint *QT_FASTCALL convertARGB32ToARGB32PM_neon(uint *buffer, const uint *src, int count, + const QVector *, QDitherInfo *) +{ + convertARGBToARGB32PM_neon(buffer, src, count); + return buffer; +} + +const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_neon(uint *buffer, const uint *src, int count, + const QVector *, QDitherInfo *) +{ + convertARGBToARGB32PM_neon(buffer, src, count); + return buffer; +} +#endif + QT_END_NAMESPACE #endif // __ARM_NEON__ diff --git a/src/gui/painting/qdrawhelper_sse4.cpp b/src/gui/painting/qdrawhelper_sse4.cpp index 257bad9eca..14bfaabf09 100644 --- a/src/gui/painting/qdrawhelper_sse4.cpp +++ b/src/gui/painting/qdrawhelper_sse4.cpp @@ -44,16 +44,67 @@ QT_BEGIN_NAMESPACE +template +static inline void convertARGBToARGB32PM_sse4(uint *buffer, const uint *src, int count) +{ + int i = 0; + const __m128i alphaMask = _mm_set1_epi32(0xff000000); + const __m128i rgbaMask = _mm_setr_epi8(2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15); + const __m128i shuffleMask = _mm_setr_epi8(6, 7, 6, 7, 6, 7, 6, 7, 14, 15, 14, 15, 14, 15, 14, 15); + const __m128i half = _mm_set1_epi16(0x0080); + const __m128i zero = _mm_setzero_si128(); + + for (; i < count - 3; i += 4) { + __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[i]); + if (!_mm_testz_si128(srcVector, alphaMask)) { + if (!_mm_testc_si128(srcVector, alphaMask)) { + if (RGBA) + srcVector = _mm_shuffle_epi8(srcVector, rgbaMask); + __m128i src1 = _mm_unpacklo_epi8(srcVector, zero); + __m128i src2 = _mm_unpackhi_epi8(srcVector, zero); + __m128i alpha1 = _mm_shuffle_epi8(src1, shuffleMask); + __m128i alpha2 = _mm_shuffle_epi8(src2, shuffleMask); + src1 = _mm_mullo_epi16(src1, alpha1); + src2 = _mm_mullo_epi16(src2, alpha2); + src1 = _mm_add_epi16(src1, _mm_srli_epi16(src1, 8)); + src2 = _mm_add_epi16(src2, _mm_srli_epi16(src2, 8)); + src1 = _mm_add_epi16(src1, half); + src2 = _mm_add_epi16(src2, half); + src1 = _mm_srli_epi16(src1, 8); + src2 = _mm_srli_epi16(src2, 8); + src1 = _mm_blend_epi16(src1, alpha1, 0x88); + src2 = _mm_blend_epi16(src2, alpha2, 0x88); + srcVector = _mm_packus_epi16(src1, src2); + _mm_storeu_si128((__m128i *)&buffer[i], srcVector); + } else { + if (RGBA) + _mm_storeu_si128((__m128i *)&buffer[i], _mm_shuffle_epi8(srcVector, rgbaMask)); + else if (buffer != src) + _mm_storeu_si128((__m128i *)&buffer[i], srcVector); + } + } else { + _mm_storeu_si128((__m128i *)&buffer[i], _mm_setzero_si128()); + } + } + + SIMD_EPILOGUE(i, count, 3) { + uint v = qPremultiply(src[i]); + buffer[i] = RGBA ? RGBA2ARGB(v) : v; + } +} + const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector *, QDitherInfo *) { - return qt_convertARGB32ToARGB32PM(buffer, src, count); + convertARGBToARGB32PM_sse4(buffer, src, count); + return buffer; } const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector *, QDitherInfo *) { - return qt_convertRGBA8888ToARGB32PM(buffer, src, count); + convertARGBToARGB32PM_sse4(buffer, src, count); + return buffer; } const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, From 6a9cd5604e9bfd3debc4cece4d7c260e2333cb55 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 30 Jan 2017 13:59:19 +0100 Subject: [PATCH 292/304] Don't narrow lengths in qHash() implementations The crc32() functions take a size_t length, but the hash() functions wrapping them took int lengths. That makes no sense and actively hurts adding hash functions for STL types or QStringView, so port the hash() interface to size_t. Change-Id: Id303d6df4b698560fce656cec8ed693b01daac1c Reviewed-by: Milian Wolff Reviewed-by: Thiago Macieira --- src/corelib/tools/qhash.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index abec9ebb79..9270539f4f 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -199,14 +199,14 @@ static uint crc32(...) } #endif -static inline uint hash(const uchar *p, int len, uint seed) Q_DECL_NOTHROW +static inline uint hash(const uchar *p, size_t len, uint seed) Q_DECL_NOTHROW { uint h = seed; if (hasFastCrc32()) - return crc32(p, size_t(len), h); + return crc32(p, len, h); - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) h = 31 * h + p[i]; return h; @@ -217,14 +217,14 @@ uint qHashBits(const void *p, size_t len, uint seed) Q_DECL_NOTHROW return hash(static_cast(p), int(len), seed); } -static inline uint hash(const QChar *p, int len, uint seed) Q_DECL_NOTHROW +static inline uint hash(const QChar *p, size_t len, uint seed) Q_DECL_NOTHROW { uint h = seed; if (hasFastCrc32()) - return crc32(p, size_t(len), h); + return crc32(p, len, h); - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) h = 31 * h + p[i].unicode(); return h; @@ -232,23 +232,24 @@ static inline uint hash(const QChar *p, int len, uint seed) Q_DECL_NOTHROW uint qHash(const QByteArray &key, uint seed) Q_DECL_NOTHROW { - return hash(reinterpret_cast(key.constData()), key.size(), seed); + return hash(reinterpret_cast(key.constData()), size_t(key.size()), seed); } uint qHash(const QString &key, uint seed) Q_DECL_NOTHROW { - return hash(key.unicode(), key.size(), seed); + return hash(key.unicode(), size_t(key.size()), seed); } uint qHash(const QStringRef &key, uint seed) Q_DECL_NOTHROW { - return hash(key.unicode(), key.size(), seed); + return hash(key.unicode(), size_t(key.size()), seed); } uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW { int m = bitArray.d.size() - 1; - uint result = hash(reinterpret_cast(bitArray.d.constData()), qMax(0, m), seed); + uint result = hash(reinterpret_cast(bitArray.d.constData()), + size_t(qMax(0, m)), seed); // deal with the last 0 to 7 bits manually, because we can't trust that // the padding is initialized to 0 in bitArray.d @@ -260,7 +261,7 @@ uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW uint qHash(QLatin1String key, uint seed) Q_DECL_NOTHROW { - return hash(reinterpret_cast(key.data()), key.size(), seed); + return hash(reinterpret_cast(key.data()), size_t(key.size()), seed); } /*! From f66319faa1a67101f9e864233f80837b6f5745d8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 17 Dec 2014 16:21:03 +0100 Subject: [PATCH 293/304] QtWidgets: convert some users of QSizePolicy::transpose() to transposed() Change-Id: I492c3825ac10145c6ca69029ad1bcda6efc971b7 Reviewed-by: Giuseppe D'Angelo --- src/widgets/widgets/qabstractslider.cpp | 4 +--- src/widgets/widgets/qprogressbar.cpp | 4 +--- src/widgets/widgets/qsplitter.cpp | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index cc6a407bf8..0ea9250695 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -303,9 +303,7 @@ void QAbstractSlider::setOrientation(Qt::Orientation orientation) d->orientation = orientation; if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) { - QSizePolicy sp = sizePolicy(); - sp.transpose(); - setSizePolicy(sp); + setSizePolicy(sizePolicy().transposed()); setAttribute(Qt::WA_WState_OwnSizePolicy, false); } update(); diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 64f19047b6..2b228cdb2c 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -508,9 +508,7 @@ void QProgressBar::setOrientation(Qt::Orientation orientation) return; d->orientation = orientation; if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) { - QSizePolicy sp = sizePolicy(); - sp.transpose(); - setSizePolicy(sp); + setSizePolicy(sizePolicy().transposed()); setAttribute(Qt::WA_WState_OwnSizePolicy, false); } d->resetLayoutItemMargins(); diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index e58fedba20..e6332293e4 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1008,9 +1008,7 @@ void QSplitter::setOrientation(Qt::Orientation orientation) return; if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) { - QSizePolicy sp = sizePolicy(); - sp.transpose(); - setSizePolicy(sp); + setSizePolicy(sizePolicy().transposed()); setAttribute(Qt::WA_WState_OwnSizePolicy, false); } From 714100f631458d3710bcb10c313406e30b25865f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 17 Dec 2014 16:20:27 +0100 Subject: [PATCH 294/304] QSizePolicy: implement transpose() via transposed() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having two implementations was nice for testing, but now remove one of them. Change-Id: I70dc7d16496427dd36ba2464c9f650ec865202b1 Reviewed-by: Sérgio Martins --- src/widgets/kernel/qsizepolicy.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 80bc8eacdb..3ab672a8e8 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -158,7 +158,7 @@ public: QT_SIZEPOLICY_CONSTEXPR bool retainSizeWhenHidden() const { return bits.retainSizeWhenHidden; } void setRetainSizeWhenHidden(bool retainSize) { bits.retainSizeWhenHidden = retainSize; } - void transpose(); + void transpose() { *this = transposed(); } #ifndef Q_QDOC QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT #endif @@ -220,16 +220,6 @@ Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); Q_WIDGETS_EXPORT QDebug operator<<(QDebug dbg, const QSizePolicy &); #endif -inline void QSizePolicy::transpose() { - Policy hData = horizontalPolicy(); - Policy vData = verticalPolicy(); - int hStretch = horizontalStretch(); - int vStretch = verticalStretch(); - setHorizontalPolicy(vData); - setVerticalPolicy(hData); - setHorizontalStretch(vStretch); - setVerticalStretch(hStretch); -} #undef QT_SIZEPOLICY_CONSTEXPR #undef QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT From d258d6962a5b575839e207d71df4863f8d5218f6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 31 Jan 2017 00:43:07 +0100 Subject: [PATCH 295/304] QLocale(Win): fix pessimizing use of QStringBuilder Instead of result += QString(string builder expression); forcing a QString creation incl. memory allocation, do result += string builder expression; using the overloaded QString += QStringBuilder operator. Change-Id: I23023c76620fa6bb7bf9f2786c22f6a2ec0d87c2 Reviewed-by: Friedemann Kleint --- src/corelib/tools/qlocale_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index b5f97b5fe8..d1abb8b565 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -691,7 +691,7 @@ QString QSystemLocalePrivate::winToQtFormat(const QString &sys_fmt) if (text == QLatin1String("'")) result += QLatin1String("''"); else - result += QString(QLatin1Char('\'') + text + QLatin1Char('\'')); + result += QLatin1Char('\'') + text + QLatin1Char('\''); continue; } From 1b488d8b49c55c6f91eb4217e39a7f94f3be4231 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 20 Jan 2017 14:48:42 +0000 Subject: [PATCH 296/304] Streamline #include It's included by qglobal.h, so we get it for free in other headers. Change-Id: I90072156e313271a5354a39cbf78a83a6885c431 Reviewed-by: Thiago Macieira --- src/corelib/global/qflags.h | 2 -- src/corelib/global/qglobal.h | 1 - src/corelib/kernel/qobjectdefs_impl.h | 2 -- src/testlib/qtestcase.h | 1 - 4 files changed, 6 deletions(-) diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 89a0ae9083..93dbedc930 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -46,8 +46,6 @@ #include #endif -#include - QT_BEGIN_NAMESPACE class QFlag diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e6d4848491..9ac29acd16 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -44,7 +44,6 @@ #ifdef __cplusplus # include # include -# include # include #endif diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 1768e8ccc6..bd08ca1763 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -50,8 +50,6 @@ #pragma qt_sync_stop_processing #endif -#include - QT_BEGIN_NAMESPACE diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 26d8ff2766..a7e825396a 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -51,7 +51,6 @@ #include -#include #ifndef QT_NO_EXCEPTIONS # include #endif // QT_NO_EXCEPTIONS From 8d9da54dd58da7a909bb5981db27bb4e8e57d21c Mon Sep 17 00:00:00 2001 From: Kimmo Ollila Date: Thu, 19 Jan 2017 11:51:50 +0200 Subject: [PATCH 297/304] Add a configure check for alloca() Alloca() is not supported on all platforms, like INTEGRITY on ARM, so adding a configure check for it. This can be used when building QtQml and 3rd party code, in particular PCRE2 and SQLite. Change-Id: I9785e16c21f67d1a68fef567e18c3356170f027e Reviewed-by: Lars Knoll --- config.tests/common/alloca/alloca.cpp | 46 +++++++++++++++++++++++++++ config.tests/common/alloca/alloca.pro | 1 + configure.json | 10 ++++++ 3 files changed, 57 insertions(+) create mode 100644 config.tests/common/alloca/alloca.cpp create mode 100644 config.tests/common/alloca/alloca.pro diff --git a/config.tests/common/alloca/alloca.cpp b/config.tests/common/alloca/alloca.cpp new file mode 100644 index 0000000000..566ee5651a --- /dev/null +++ b/config.tests/common/alloca/alloca.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the config.tests 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$ +** +****************************************************************************/ + +#include + +int main(int, char **) +{ + alloca(1); + return 0; +} diff --git a/config.tests/common/alloca/alloca.pro b/config.tests/common/alloca/alloca.pro new file mode 100644 index 0000000000..a2d7d45da2 --- /dev/null +++ b/config.tests/common/alloca/alloca.pro @@ -0,0 +1 @@ +SOURCES = alloca.cpp diff --git a/configure.json b/configure.json index 21ec84818d..cb64e6313a 100644 --- a/configure.json +++ b/configure.json @@ -409,6 +409,11 @@ "type": "compile", "test": "unix/posix_fallocate" }, + "alloca": { + "label": "alloca()", + "type": "compile", + "test": "common/alloca" + }, "stack_protector": { "label": "stack protection", "type": "compilerSupportsFlag", @@ -889,6 +894,11 @@ "condition": "tests.posix_fallocate", "output": [ "privateFeature" ] }, + "alloca": { + "label": "alloca()", + "condition": "tests.alloca", + "output": [ "privateFeature" ] + }, "stack-protector-strong": { "label": "stack protection", "condition": "config.qnx && tests.stack_protector", From 60f48dd09aad4266fa4aaaa7b6228b9a8394cc73 Mon Sep 17 00:00:00 2001 From: Kimmo Ollila Date: Thu, 26 Jan 2017 18:38:13 +0200 Subject: [PATCH 298/304] Remove -uvfd flag on INTEGRITY The uvfd flag is implicitly defined when -Olink is used. This causes the compiler to generate a warning for every file being compiled in release mode. Change-Id: I75759151864da7cf2f6d9c812e466a52c1208444 Reviewed-by: Nikola Velinov Reviewed-by: Lars Knoll --- mkspecs/common/ghs-base.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/common/ghs-base.conf b/mkspecs/common/ghs-base.conf index b6c9654725..bd1f3eb5ab 100644 --- a/mkspecs/common/ghs-base.conf +++ b/mkspecs/common/ghs-base.conf @@ -8,7 +8,7 @@ QMAKE_COMPILER = ghs QMAKE_CFLAGS += --signed_fields --no_commons --diag_suppress=1,82,228,236,381,611,961,997,1795,1974 QMAKE_CFLAGS_DEPS += -MD -QMAKE_CFLAGS_RELEASE += -Ospeed -Olink -Omax -uvfd +QMAKE_CFLAGS_RELEASE += -Ospeed -Olink -Omax QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE -g QMAKE_CFLAGS_DEBUG += -g -Omaxdebug QMAKE_CFLAGS_SHLIB += @@ -34,7 +34,7 @@ QMAKE_CXXFLAGS_EXCEPTIONS_ON += --exceptions QMAKE_LFLAGS += --signed_fields --no_commons --no_implicit_include --link_once_templates -non_shared --new_outside_of_constructor QMAKE_LFLAGS_DEBUG += -g -Omaxdebug -QMAKE_LFLAGS_RELEASE += -Ospeed -Olink -Omax -uvfd +QMAKE_LFLAGS_RELEASE += -Ospeed -Olink -Omax QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_LFLAGS_RELEASE -g QMAKE_LFLAGS_CXX11 += --c++11 --thread_local_storage QMAKE_LFLAGS_EXCEPTIONS_ON += --exceptions From 36f8816555da28b01d38032b4d298300681c61a5 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 27 Jan 2017 15:21:57 +0100 Subject: [PATCH 299/304] Fix 2 clang warnings The first one was already suppressed for GCC, so also do that for clang: /Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:1076:16: warning: format string is not a string literal (potentially insecure) [-Wformat-security] a.sprintf( zero ); ^~~~ /Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:1076:16: note: treat the string as an argument to avoid this a.sprintf( zero ); ^ "%s", The second one could also occur with other compilers, so fix it in a generic way. /Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:6382:5: warning: ignoring return value of function declared with warn_unused_result attribute [-Wunused-result] string.repeated(3); ^~~~~~~~~~~~~~~ ~ 2 warnings generated. Change-Id: Id999179e795580a37b5be673ee54d6fa1a006dd7 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 6ed7b74277..727eda7456 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -1066,6 +1066,7 @@ void tst_QString::acc_01() QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wformat-security") +QT_WARNING_DISABLE_CLANG("-Wformat-security") void tst_QString::isNull() { @@ -6345,7 +6346,7 @@ void tst_QString::repeatedSignature() const { /* repated() should be a const member. */ const QString string; - string.repeated(3); + (void) string.repeated(3); } void tst_QString::repeated() const From e5d303cb9fb3ade3fae6d3f14a5f4fe139af63c9 Mon Sep 17 00:00:00 2001 From: Glen Mabey Date: Tue, 31 Jan 2017 04:42:13 +0000 Subject: [PATCH 300/304] tst_qvariant: fix comparison ambiguity for QMetaEnum value Under certain circumstances, VS2015 reported ambiguous options in using the operator>(Enum,int) operator. This change adds a static_cast to remove any ambiguity. In the process of testing this change, a gap in the existing logic was identified: the handling (just in the test code) of large negative enum values. Consequently, and additional test case was added, and additional if-conditions were added to account for that case. Change-Id: Ife2c471ba4caa4b9a0107722042114e58145c4d0 Reviewed-by: Thiago Macieira --- tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 3a51e67768..2a9b9c0a7f 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -80,7 +80,7 @@ public: enum MetaEnumTest_Enum1 { MetaEnumTest_Enum1_value = 42, MetaEnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 }; Q_ENUM(MetaEnumTest_Enum1) - enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5 }; + enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 }; Q_ENUM(MetaEnumTest_Enum3) enum MetaEnumTest_Enum4 ENUM_SIZE(quint64) { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 }; Q_ENUM(MetaEnumTest_Enum4) @@ -4671,7 +4671,7 @@ template void testVariant(Enum value, bool *ok) QVERIFY(var2.convert(QMetaType::Int)); QCOMPARE(var2.value(), static_cast(value)); - if (static_cast(value) <= INT_MAX) { + if ((static_cast(value) <= INT_MAX) && (static_cast(value) >= INT_MIN)) { int intValue = static_cast(value); QVariant intVar = intValue; QVERIFY(intVar.canConvert()); @@ -4732,7 +4732,7 @@ template void testVariantMeta(Enum value, bool *ok, const char *s QVariant strVar = QString::fromLatin1(string); QVERIFY(strVar.canConvert()); - if (value > INT_MAX) { + if ((static_cast(value) > INT_MAX) || (static_cast(value) < INT_MIN)) { QEXPECT_FAIL("", "QMetaEnum api uses 'int' as return type QTBUG-27451", Abort); *ok = true; } @@ -4754,6 +4754,7 @@ void tst_QVariant::metaEnums() METAENUMS_TEST(MetaEnumTest_Enum1_bigValue); METAENUMS_TEST(MetaEnumTest_Enum3_value); METAENUMS_TEST(MetaEnumTest_Enum3_bigValue); + METAENUMS_TEST(MetaEnumTest_Enum3_bigNegValue); METAENUMS_TEST(MetaEnumTest_Enum4_value); METAENUMS_TEST(MetaEnumTest_Enum4_bigValue); METAENUMS_TEST(MetaEnumTest_Enum5_value); From 3ab7016632c825949f32b72d06ac324b6672b9f6 Mon Sep 17 00:00:00 2001 From: Glen Mabey Date: Sat, 22 Jun 2013 19:43:46 -0500 Subject: [PATCH 301/304] New qfloat16 class This constitutes a fairly complete submission of an entirely new floating point type which conforms to IEEE 754 as a 16-bit storage class. Conversion between qfloat16 and float is currently performed through a sequence of lookup tables. Global-level functions qRound(), qRound64(), qFuzzyCompare(), qFuzzyIsNull(), and qIsNull() each with a qfloat16 parameter have been included for completeness. [ChangeLog][QtCore] Added new qfloat16 class. Change-Id: Ia52eb27846965c14f8140c00faf5ba33c9443976 Reviewed-by: Thiago Macieira --- .gitignore | 2 + src/corelib/global/global.pri | 14 + src/corelib/global/qfloat16.cpp | 117 ++++++++ src/corelib/global/qfloat16.h | 225 +++++++++++++++ src/corelib/global/qfloat16_p.h | 95 +++++++ src/corelib/io/qdatastream.cpp | 23 +- src/corelib/io/qdatastream.h | 9 + src/src.pro | 10 +- .../qfloat16-tables/gen_qfloat16_tables.cpp | 161 +++++++++++ src/tools/qfloat16-tables/qfloat16-tables.pro | 9 + tests/auto/corelib/global/global.pro | 1 + .../auto/corelib/global/qfloat16/qfloat16.pro | 4 + .../corelib/global/qfloat16/tst_qfloat16.cpp | 266 ++++++++++++++++++ 13 files changed, 932 insertions(+), 4 deletions(-) create mode 100644 src/corelib/global/qfloat16.cpp create mode 100644 src/corelib/global/qfloat16.h create mode 100644 src/corelib/global/qfloat16_p.h create mode 100644 src/tools/qfloat16-tables/gen_qfloat16_tables.cpp create mode 100644 src/tools/qfloat16-tables/qfloat16-tables.pro create mode 100644 tests/auto/corelib/global/qfloat16/qfloat16.pro create mode 100644 tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp diff --git a/.gitignore b/.gitignore index e0677a3a68..45412cd791 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,7 @@ bin/makeqpf* bin/pixeltool* bin/qmake* bin/qdoc* +bin/qfloat16-tables* bin/qt3to4* bin/qttracereplay* bin/rcc* @@ -137,6 +138,7 @@ src/corelib/global/qconfig.h src/corelib/global/qconfig.h.qmake src/corelib/global/qconfig_p.h src/corelib/global/qfeatures.h +src/corelib/global/qfloat16tables.cpp src/platformsupport/*_interface.* src/platformsupport/*_adaptor.* ui_*.h diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index d23706e631..9ae1e3a4ae 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -11,6 +11,8 @@ HEADERS += \ global/qendian.h \ global/qnumeric_p.h \ global/qnumeric.h \ + global/qfloat16_p.h \ + global/qfloat16.h \ global/qglobalstatic.h \ global/qlibraryinfo.h \ global/qlogging.h \ @@ -29,6 +31,7 @@ SOURCES += \ global/qlibraryinfo.cpp \ global/qmalloc.cpp \ global/qnumeric.cpp \ + global/qfloat16.cpp \ global/qoperatingsystemversion.cpp \ global/qlogging.cpp \ global/qhooks.cpp @@ -76,3 +79,14 @@ gcc:ltcg { } else { SOURCES += $$VERSIONTAGGING_SOURCES } + +QMAKE_QFLOAT16_TABLES_GENERATE = global/qfloat16.h + +qtPrepareTool(QMAKE_QFLOAT16_TABLES, qfloat16-tables) + +qfloat16_tables.commands = $$QMAKE_QFLOAT16_TABLES ${QMAKE_FILE_OUT} +qfloat16_tables.output = global/qfloat16tables.cpp +qfloat16_tables.depends = $$QMAKE_QFLOAT16_TABLES +qfloat16_tables.input = QMAKE_QFLOAT16_TABLES_GENERATE +qfloat16_tables.variable_out = SOURCES +QMAKE_EXTRA_COMPILERS += qfloat16_tables diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp new file mode 100644 index 0000000000..5264b56104 --- /dev/null +++ b/src/corelib/global/qfloat16.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2016 by Southwest Research Institute (R) +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore 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$ +** +****************************************************************************/ + +#include "qfloat16_p.h" + +QT_BEGIN_NAMESPACE + +/*! \headerfile + + This header file provides support for half-precision (16-bit) floating + point data with the class \c qfloat16. It is fully compliant with IEEE + 754 as a storage type. This implies that any arithmetic operation on a + \c qfloat16 instance results in the value first being converted to a + \c float. This conversion to and from \c float is performed by hardware + when possible, but on processors that do not natively support half-precision, + the conversion is performed through a sequence of lookup table operations. + + \c qfloat16 should be treated as if it were a POD (plain old data) type. + Consequently, none of the supported operations need any elaboration beyond + stating that it supports all arithmetic operators incident to floating point + types. + + \since 5.9 +*/ + +Q_STATIC_ASSERT_X(sizeof(float) == sizeof(quint32), + "qfloat16 assumes that floats are 32 bits wide"); +Q_STATIC_ASSERT_X(std::numeric_limits::is_iec559, + "Only works with IEEE 754 floating point"); + +/*! + Returns true if the \c qfloat16 \a {f} is equivalent to infinity. + \relates + + \sa qIsInf +*/ +Q_REQUIRED_RESULT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW { return qt_is_inf(f); } + +/*! + Returns true if the \c qfloat16 \a {f} is not a number (NaN). + \relates + + \sa qIsNaN +*/ +Q_REQUIRED_RESULT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW { return qt_is_nan(f); } + +/*! + Returns true if the \c qfloat16 \a {f} is a finite number. + \relates + + \sa qIsFinite +*/ +Q_REQUIRED_RESULT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW { return qt_is_finite(f); } + +/*! \fn int qRound(qfloat16 value) + \relates + + Rounds \a value to the nearest integer. + + \sa qRound +*/ + +/*! \fn qint64 qRound64(qfloat16 value) + \relates + + Rounds \a value to the nearest 64-bit integer. + + \sa qRound64 +*/ + +/*! \fn bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) + \relates + + Compares the floating point value \a p1 and \a p2 and + returns \c true if they are considered equal, otherwise \c false. + + The two numbers are compared in a relative way, where the + exactness is stronger the smaller the numbers are. + */ + +QT_END_NAMESPACE diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h new file mode 100644 index 0000000000..5059108fb8 --- /dev/null +++ b/src/corelib/global/qfloat16.h @@ -0,0 +1,225 @@ +/**************************************************************************** +** +** Copyright (C) 2016 by Southwest Research Institute (R) +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore 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 QFLOAT16_H +#define QFLOAT16_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +#if 0 +#pragma qt_class(QFloat16) +#endif + +class qfloat16 +{ +public: +#ifndef Q_QDOC + Q_DECL_CONSTEXPR inline qfloat16() Q_DECL_NOTHROW : b16(0) { } + inline qfloat16(float f) Q_DECL_NOTHROW; + inline operator float() const Q_DECL_NOTHROW; + inline operator double() const Q_DECL_NOTHROW; + inline operator long double() const Q_DECL_NOTHROW; +#endif + +private: + quint16 b16; + + Q_CORE_EXPORT static const quint32 mantissatable[]; + Q_CORE_EXPORT static const quint32 exponenttable[]; + Q_CORE_EXPORT static const quint32 offsettable[]; + Q_CORE_EXPORT static const quint32 basetable[]; + Q_CORE_EXPORT static const quint32 shifttable[]; + + friend bool qIsNull(qfloat16 f) Q_DECL_NOTHROW; + friend qfloat16 operator-(qfloat16 a) Q_DECL_NOTHROW; +}; + +Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE); + +Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h +Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h +Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h + +// The remainder of these utility functions complement qglobal.h +inline Q_REQUIRED_RESULT int qRound(qfloat16 d) Q_DECL_NOTHROW +{ return qRound(static_cast(d)); } + +inline Q_REQUIRED_RESULT qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW +{ return qRound64(static_cast(d)); } + +inline Q_REQUIRED_RESULT bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW +{ + float f1 = static_cast(p1); + float f2 = static_cast(p2); + // The significand precision for IEEE754 half precision is + // 11 bits (10 explicitly stored), or approximately 3 decimal + // digits. In selecting the fuzzy comparison factor of 102.5f + // (that is, (2^10+1)/10) below, we effectively select a + // window of about 1 (least significant) decimal digit about + // which the two operands can vary and still return true. + return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2))); +} + +inline Q_REQUIRED_RESULT bool qIsNull(qfloat16 f) Q_DECL_NOTHROW +{ + return (f.b16 & static_cast(0x7fff)) == 0; +} + +inline int qIntCast(qfloat16 f) Q_DECL_NOTHROW +{ return int(static_cast(f)); } + +inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW +{ + quint32 u; + memcpy(&u, &f, sizeof(quint32)); + b16 = basetable[(u >> 23) & 0x1ff] + + ((u & 0x007fffff) >> shifttable[(u >> 23) & 0x1ff]); +} + +inline qfloat16::operator float() const Q_DECL_NOTHROW +{ + quint32 u = mantissatable[offsettable[b16 >> 10] + (b16 & 0x3ff)] + + exponenttable[b16 >> 10]; + float f; + memcpy(&f, &u, sizeof(quint32)); + return f; +} + +inline qfloat16::operator double() const Q_DECL_NOTHROW +{ + return static_cast(float(*this)); +} + +inline qfloat16::operator long double() const Q_DECL_NOTHROW +{ + return static_cast(float(*this)); +} + +inline qfloat16 operator-(qfloat16 a) Q_DECL_NOTHROW +{ + qfloat16 f; + f.b16 = a.b16 ^ quint16(0x8000); + return f; +} + +inline qfloat16 operator+(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) + static_cast(b)); } +inline qfloat16 operator-(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) - static_cast(b)); } +inline qfloat16 operator*(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) * static_cast(b)); } +inline qfloat16 operator/(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) / static_cast(b)); } + +#define QF16_MAKE_ARITH_OP_FP(FP, OP) \ + inline FP operator OP(qfloat16 lhs, FP rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ + inline FP operator OP(FP lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } +#define QF16_MAKE_ARITH_OP_EQ_FP(FP, OP_EQ, OP) \ + inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) Q_DECL_NOTHROW { lhs = qfloat16(static_cast(lhs) OP rhs); return lhs; } +#define QF16_MAKE_ARITH_OP(FP) \ + QF16_MAKE_ARITH_OP_FP(FP, +) \ + QF16_MAKE_ARITH_OP_FP(FP, -) \ + QF16_MAKE_ARITH_OP_FP(FP, *) \ + QF16_MAKE_ARITH_OP_FP(FP, /) \ + QF16_MAKE_ARITH_OP_EQ_FP(FP, +=, +) \ + QF16_MAKE_ARITH_OP_EQ_FP(FP, -=, -) \ + QF16_MAKE_ARITH_OP_EQ_FP(FP, *=, *) \ + QF16_MAKE_ARITH_OP_EQ_FP(FP, /=, /) +QF16_MAKE_ARITH_OP(long double) +QF16_MAKE_ARITH_OP(double) +QF16_MAKE_ARITH_OP(float) +#undef QF16_MAKE_ARITH_OP +#undef QF16_MAKE_ARITH_OP_FP + +#define QF16_MAKE_ARITH_OP_INT(OP) \ + inline double operator OP(qfloat16 lhs, int rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ + inline double operator OP(int lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } +QF16_MAKE_ARITH_OP_INT(+) +QF16_MAKE_ARITH_OP_INT(-) +QF16_MAKE_ARITH_OP_INT(*) +QF16_MAKE_ARITH_OP_INT(/) +#undef QF16_MAKE_ARITH_OP_INT + +inline bool operator>(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) > static_cast(b); } +inline bool operator<(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) < static_cast(b); } +inline bool operator>=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) >= static_cast(b); } +inline bool operator<=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) <= static_cast(b); } +inline bool operator==(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) == static_cast(b); } +inline bool operator!=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) != static_cast(b); } + +#define QF16_MAKE_BOOL_OP_FP(FP, OP) \ + inline bool operator OP(qfloat16 lhs, FP rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ + inline bool operator OP(FP lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } +#define QF16_MAKE_BOOL_OP(FP) \ + QF16_MAKE_BOOL_OP_FP(FP, <) \ + QF16_MAKE_BOOL_OP_FP(FP, >) \ + QF16_MAKE_BOOL_OP_FP(FP, >=) \ + QF16_MAKE_BOOL_OP_FP(FP, <=) \ + QF16_MAKE_BOOL_OP_FP(FP, ==) \ + QF16_MAKE_BOOL_OP_FP(FP, !=) +QF16_MAKE_BOOL_OP(long double) +QF16_MAKE_BOOL_OP(double) +QF16_MAKE_BOOL_OP(float) +#undef QF16_MAKE_BOOL_OP +#undef QF16_MAKE_BOOL_OP_FP + +#define QF16_MAKE_BOOL_OP_INT(OP) \ + inline bool operator OP(qfloat16 a, int b) Q_DECL_NOTHROW { return static_cast(a) OP b; } \ + inline bool operator OP(int a, qfloat16 b) Q_DECL_NOTHROW { return a OP static_cast(b); } +QF16_MAKE_BOOL_OP_INT(>) +QF16_MAKE_BOOL_OP_INT(<) +QF16_MAKE_BOOL_OP_INT(>=) +QF16_MAKE_BOOL_OP_INT(<=) +QF16_MAKE_BOOL_OP_INT(==) +QF16_MAKE_BOOL_OP_INT(!=) +#undef QF16_MAKE_BOOL_OP_INT + +/*! + \internal +*/ +inline Q_REQUIRED_RESULT bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW +{ + return qAbs(static_cast(f)) <= 0.001f; +} + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(qfloat16) + +#endif // QFLOAT16_H diff --git a/src/corelib/global/qfloat16_p.h b/src/corelib/global/qfloat16_p.h new file mode 100644 index 0000000000..ae52e64435 --- /dev/null +++ b/src/corelib/global/qfloat16_p.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2016 by Southwest Research Institute (R) +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore 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 QFLOAT16_P_H +#define QFLOAT16_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 +#include + +QT_BEGIN_NAMESPACE + +static inline bool qt_is_inf(qfloat16 d) Q_DECL_NOTHROW +{ + bool is_inf; + uchar *ch = (uchar *)&d; + if (QSysInfo::ByteOrder == QSysInfo::BigEndian) + is_inf = (ch[0] & 0x7c) == 0x7c; + else + is_inf = (ch[1] & 0x7c) == 0x7c; + return is_inf; +} + +static inline bool qt_is_nan(qfloat16 d) Q_DECL_NOTHROW +{ + bool is_nan; + uchar *ch = (uchar *)&d; + if (QSysInfo::ByteOrder == QSysInfo::BigEndian) + is_nan = (ch[0] & 0x7c) == 0x7c && (ch[0] & 0x02) != 0; + else + is_nan = (ch[1] & 0x7c) == 0x7c && (ch[1] & 0x02) != 0; + return is_nan; +} + +static inline bool qt_is_finite(qfloat16 d) Q_DECL_NOTHROW +{ + bool is_finite; + uchar *ch = (uchar *)&d; + if (QSysInfo::ByteOrder == QSysInfo::BigEndian) + is_finite = (ch[0] & 0x7c) != 0x7c; + else + is_finite = (ch[1] & 0x7c) != 0x7c; + return is_finite; +} + + +QT_END_NAMESPACE + +#endif // QFLOAT16_P_H diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 2730fd7f11..cac5152e87 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -448,6 +448,9 @@ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const The default is DoublePrecision. + Note that this property does not affect the serialization or deserialization of \c qfloat16 + instances. + \warning This property must be set to the same value on the object that writes and the object that reads the data stream. @@ -971,6 +974,16 @@ QDataStream &QDataStream::operator>>(double &f) } +/*! + \fn QDataStream &QDataStream::operator>>(qfloat16 &f) + \overload + \since 5.9 + + Reads a floating point number from the stream into \a f, + using the standard IEEE 754 format. Returns a reference to the + stream. +*/ + /*! \overload @@ -1259,6 +1272,15 @@ QDataStream &QDataStream::operator<<(double f) } +/*! + \fn QDataStream &QDataStream::operator<<(qfloat16 f) + \overload + \since 5.9 + + Writes a floating point number, \a f, to the stream using + the standard IEEE 754 format. Returns a reference to the stream. +*/ + /*! \overload @@ -1282,7 +1304,6 @@ QDataStream &QDataStream::operator<<(const char *s) return *this; } - /*! Writes the length specifier \a len and the buffer \a s to the stream and returns a reference to the stream. diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index 994ed88791..9a7d7e275d 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -43,6 +43,7 @@ #include #include #include +#include #ifdef Status #error qdatastream.h must be included before any header file that defines Status @@ -154,6 +155,7 @@ public: QDataStream &operator>>(quint64 &i); QDataStream &operator>>(bool &i); + QDataStream &operator>>(qfloat16 &f); QDataStream &operator>>(float &f); QDataStream &operator>>(double &f); QDataStream &operator>>(char *&str); @@ -167,6 +169,7 @@ public: QDataStream &operator<<(qint64 i); QDataStream &operator<<(quint64 i); QDataStream &operator<<(bool i); + QDataStream &operator<<(qfloat16 f); QDataStream &operator<<(float f); QDataStream &operator<<(double f); QDataStream &operator<<(const char *str); @@ -345,6 +348,9 @@ inline QDataStream &QDataStream::operator>>(quint32 &i) inline QDataStream &QDataStream::operator>>(quint64 &i) { return *this >> reinterpret_cast(i); } +inline QDataStream &QDataStream::operator>>(qfloat16 &f) +{ return *this >> reinterpret_cast(f); } + inline QDataStream &QDataStream::operator<<(quint8 i) { return *this << qint8(i); } @@ -357,6 +363,9 @@ inline QDataStream &QDataStream::operator<<(quint32 i) inline QDataStream &QDataStream::operator<<(quint64 i) { return *this << qint64(i); } +inline QDataStream &QDataStream::operator<<(qfloat16 f) +{ return *this << reinterpret_cast(f); } + template inline QDataStream &operator>>(QDataStream &s, QList &l) { diff --git a/src/src.pro b/src/src.pro index f57b57b6ee..403bf58a0a 100644 --- a/src/src.pro +++ b/src/src.pro @@ -21,6 +21,10 @@ src_tools_rcc.subdir = tools/rcc src_tools_rcc.target = sub-rcc src_tools_rcc.depends = src_tools_bootstrap +src_tools_qfloat16_tables.subdir = tools/qfloat16-tables +src_tools_qfloat16_tables.target = sub-qfloat16-tables +src_tools_qfloat16_tables.depends = src_tools_bootstrap + src_tools_qlalr.subdir = tools/qlalr src_tools_qlalr.target = sub-qlalr force_bootstrap: src_tools_qlalr.depends = src_tools_bootstrap @@ -51,7 +55,7 @@ src_winmain.depends = sub-corelib # just for the module .pri file src_corelib.subdir = $$PWD/corelib src_corelib.target = sub-corelib -src_corelib.depends = src_tools_moc src_tools_rcc +src_corelib.depends = src_tools_moc src_tools_rcc src_tools_qfloat16_tables src_xml.subdir = $$PWD/xml src_xml.target = sub-xml @@ -135,13 +139,13 @@ src_android.subdir = $$PWD/android src_3rdparty_freetype.depends += src_corelib } } -SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc +SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_qfloat16_tables qtConfig(regularexpression):pcre2 { SUBDIRS += src_3rdparty_pcre2 src_corelib.depends += src_3rdparty_pcre2 } SUBDIRS += src_corelib src_tools_qlalr -TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr +TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr src_tools_qfloat16_tables win32:SUBDIRS += src_winmain qtConfig(network) { SUBDIRS += src_network diff --git a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp new file mode 100644 index 0000000000..f5051e25fc --- /dev/null +++ b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2016 by Southwest Research Institute (R) +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore 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$ +** +****************************************************************************/ + +#include +#include + +quint32 convertmantissa(qint32 i) +{ + quint32 m = i << 13; // Zero pad mantissa bits + quint32 e = 0; // Zero exponent + + while (!(m & 0x00800000)) { // While not normalized + e -= 0x00800000; // Decrement exponent (1<<23) + m <<= 1; // Shift mantissa + } + m &= ~0x00800000; // Clear leading 1 bit + e += 0x38800000; // Adjust bias ((127-14)<<23) + return m | e; // Return combined number +} + +// we first build these tables up and then print them out as a separate step in order +// to more closely map the implementation given in the paper. +quint32 basetable[512]; +quint32 shifttable[512]; + +#define PRINTHEX(a) "0x" + QByteArray::number(a,16).toUpper() + "U,\n" + +qint32 main(qint32 argc, char **argv) +{ + if (argc < 2) { + qWarning() << "Must provide output filename as argument."; + return -1; + } + + QFile fid(argv[1]); + if (!fid.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning() << "Abort: Failed to open/create file" << fid.fileName(); + return -1; + } + quint32 i; + + fid.write("/* This file was generated by gen_qfloat16_tables.cpp */\n\n"); + fid.write("#include \n\n"); + + fid.write("QT_BEGIN_NAMESPACE\n\n"); + + fid.write("const quint32 qfloat16::mantissatable[2048] = {\n"); + fid.write("0,\n"); + for (i = 1; i < 1024; i++) + fid.write(PRINTHEX(convertmantissa(i))); + for (i = 1024; i < 2048; i++) + fid.write(PRINTHEX(0x38000000U + ((i - 1024) << 13))); + fid.write("};\n\n"); + + fid.write("const quint32 qfloat16::exponenttable[64] = {\n"); + fid.write("0,\n"); + for (i = 1; i < 31; i++) + fid.write(PRINTHEX(i << 23)); + fid.write("0x47800000U,\n"); // 31 + fid.write("0x80000000U,\n"); // 32 + for (i = 33; i < 63; i++) + fid.write(PRINTHEX(0x80000000U + ((i - 32) << 23))); + fid.write("0xC7800000U,\n"); // 63 + fid.write("};\n\n"); + + fid.write("const quint32 qfloat16::offsettable[64] = {\n"); + fid.write("0,\n"); + for (i = 1; i < 32; i++) + fid.write("1024U,\n"); + fid.write("0,\n"); + for (i = 33; i < 64; i++) + fid.write("1024U,\n"); + fid.write("};\n\n"); + + qint32 e; + for (i = 0; i < 256; ++i) { + e = i - 127; + if (e < -24) { // Very small numbers map to zero + basetable[i | 0x000] = 0x0000; + basetable[i | 0x100] = 0x8000; + shifttable[i | 0x000] = 24; + shifttable[i | 0x100] = 24; + + } else if (e < -14) { // Small numbers map to denorms + basetable[i | 0x000] = (0x0400 >> (-e - 14)); + basetable[i | 0x100] = (0x0400 >> (-e - 14)) | 0x8000; + shifttable[i | 0x000] = -e - 1; + shifttable[i | 0x100] = -e - 1; + + } else if (e <= 15) { // Normal numbers just lose precision + basetable[i | 0x000] = ((e + 15) << 10); + basetable[i | 0x100] = ((e + 15) << 10) | 0x8000; + shifttable[i | 0x000] = 13; + shifttable[i | 0x100] = 13; + + } else if (e < 128) { // Large numbers map to Infinity + basetable[i | 0x000] = 0x7C00; + basetable[i | 0x100] = 0xFC00; + shifttable[i | 0x000] = 24; + shifttable[i | 0x100] = 24; + + } else { // Infinity and NaN's stay Infinity and NaN's + basetable[i | 0x000] = 0x7C00; + basetable[i | 0x100] = 0xFC00; + shifttable[i | 0x000] = 13; + shifttable[i | 0x100] = 13; + } + } + + fid.write("const quint32 qfloat16::basetable[512] = {\n"); + for (i = 0; i < 512; i++) + fid.write(PRINTHEX(basetable[i])); + + fid.write("};\n\n"); + + fid.write("const quint32 qfloat16::shifttable[512] = {\n"); + for (i = 0; i < 512; i++) + fid.write(PRINTHEX(shifttable[i])); + + fid.write("};\n\n"); + + fid.write("QT_END_NAMESPACE\n"); + fid.close(); + return 0; +} diff --git a/src/tools/qfloat16-tables/qfloat16-tables.pro b/src/tools/qfloat16-tables/qfloat16-tables.pro new file mode 100644 index 0000000000..a7d10ac197 --- /dev/null +++ b/src/tools/qfloat16-tables/qfloat16-tables.pro @@ -0,0 +1,9 @@ +option(host_build) + +CONFIG += force_bootstrap +SOURCES += gen_qfloat16_tables.cpp + +load(qt_tool) + +lib.CONFIG = dummy_install +INSTALLS = lib diff --git a/tests/auto/corelib/global/global.pro b/tests/auto/corelib/global/global.pro index 219e9de818..b4cc8035e6 100644 --- a/tests/auto/corelib/global/global.pro +++ b/tests/auto/corelib/global/global.pro @@ -5,6 +5,7 @@ SUBDIRS=\ qgetputenv \ qglobal \ qnumeric \ + qfloat16 \ qrand \ qlogging \ qtendian \ diff --git a/tests/auto/corelib/global/qfloat16/qfloat16.pro b/tests/auto/corelib/global/qfloat16/qfloat16.pro new file mode 100644 index 0000000000..42081181b4 --- /dev/null +++ b/tests/auto/corelib/global/qfloat16/qfloat16.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qfloat16 +QT = core testlib +SOURCES = tst_qfloat16.cpp diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp new file mode 100644 index 0000000000..c894a9c897 --- /dev/null +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** Copyright (C) 2016 by Southwest Research Institute (R) +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore 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$ +** +****************************************************************************/ + + +#include +#include + +#include + +class tst_qfloat16: public QObject +{ + Q_OBJECT + +private slots: + void fuzzyCompare_data(); + void fuzzyCompare(); + void ltgt_data(); + void ltgt(); + void qNan(); + void float_cast(); + void float_cast_data(); + void promotionTests(); +}; + +void tst_qfloat16::fuzzyCompare_data() +{ + QTest::addColumn("val1"); + QTest::addColumn("val2"); + QTest::addColumn("fuzEqual"); + QTest::addColumn("isEqual"); + + QTest::newRow("zero") << qfloat16(0.0f) << qfloat16(0.0f) << true << true; + QTest::newRow("ten") << qfloat16(1e1f) << qfloat16(1e1f) << true << true; + QTest::newRow("large") << qfloat16(1e4f) << qfloat16(1e4f) << true << true; + QTest::newRow("small") << qfloat16(1e-5f) << qfloat16(1e-5f) << true << true; + QTest::newRow("eps") << qfloat16(10.01f) << qfloat16(10.02f) << true << false; + QTest::newRow("eps2") << qfloat16(1024.f) << qfloat16(1033.f) << true << false; + + QTest::newRow("mis1") << qfloat16(0.0f) << qfloat16(1.0f) << false << false; + QTest::newRow("mis2") << qfloat16(0.0f) << qfloat16(1e7f) << false << false; + QTest::newRow("mis3") << qfloat16(0.0f) << qfloat16(1e-4f) << false << false; + QTest::newRow("mis4") << qfloat16(1e8f) << qfloat16(1e-8f) << false << false; + QTest::newRow("mis5") << qfloat16(1e-4f) << qfloat16(1e-5) << false << false; + QTest::newRow("mis6") << qfloat16(1024.f) << qfloat16(1034.f) << false << false; +} + +void tst_qfloat16::fuzzyCompare() +{ + QFETCH(qfloat16, val1); + QFETCH(qfloat16, val2); + QFETCH(bool, fuzEqual); + QFETCH(bool, isEqual); + + if (!isEqual && (val1==val2)) + qWarning() << "Identical arguments provided unintentionally!"; + + if (fuzEqual) { + QVERIFY(::qFuzzyCompare(val1, val2)); + QVERIFY(::qFuzzyCompare(val2, val1)); + QVERIFY(::qFuzzyCompare(-val1, -val2)); + QVERIFY(::qFuzzyCompare(-val2, -val1)); + } else { + QVERIFY(!::qFuzzyCompare(val1, val2)); + QVERIFY(!::qFuzzyCompare(val2, val1)); + QVERIFY(!::qFuzzyCompare(-val1, -val2)); + QVERIFY(!::qFuzzyCompare(-val2, -val1)); + } +} + +void tst_qfloat16::ltgt_data() +{ + QTest::addColumn("val1"); + QTest::addColumn("val2"); + + QTest::newRow("zero") << 0.0f << 0.0f; + QTest::newRow("ten") << 10.0f << 10.0f; + QTest::newRow("large") << 100000.0f << 100000.0f; + QTest::newRow("small") << 0.0000001f << 0.0000001f; + QTest::newRow("eps") << 10.000000000000001f << 10.00000000000002f; + QTest::newRow("eps2") << 10.000000000000001f << 10.000000000000009f; + + QTest::newRow("mis1") << 0.0f << 1.0f; + QTest::newRow("mis2") << 0.0f << 10000000.0f; + QTest::newRow("mis3") << 0.0f << 0.0001f; + QTest::newRow("mis4") << 100000000.0f << 0.000000001f; + QTest::newRow("mis5") << 0.0001f << 0.00001f; + + QTest::newRow("45,23") << 45.f << 23.f; + QTest::newRow("1000,76") << 1000.f << 76.f; +} + +void tst_qfloat16::ltgt() +{ + QFETCH(float, val1); + QFETCH(float, val2); + + QCOMPARE(qfloat16(val1) == qfloat16(val2), val1 == val2); + QCOMPARE(qfloat16(val1) < qfloat16(val2), val1 < val2); + QCOMPARE(qfloat16(val1) <= qfloat16(val2), val1 <= val2); + QCOMPARE(qfloat16(val1) > qfloat16(val2), val1 > val2); + QCOMPARE(qfloat16(val1) >= qfloat16(val2), val1 >= val2); + + QCOMPARE(qfloat16(val1) == qfloat16(-val2), val1 == -val2); + QCOMPARE(qfloat16(val1) < qfloat16(-val2), val1 < -val2); + QCOMPARE(qfloat16(val1) <= qfloat16(-val2), val1 <= -val2); + QCOMPARE(qfloat16(val1) > qfloat16(-val2), val1 > -val2); + QCOMPARE(qfloat16(val1) >= qfloat16(-val2), val1 >= -val2); + + QCOMPARE(qfloat16(-val1) == qfloat16(val2), -val1 == val2); + QCOMPARE(qfloat16(-val1) < qfloat16(val2), -val1 < val2); + QCOMPARE(qfloat16(-val1) <= qfloat16(val2), -val1 <= val2); + QCOMPARE(qfloat16(-val1) > qfloat16(val2), -val1 > val2); + QCOMPARE(qfloat16(-val1) >= qfloat16(val2), -val1 >= val2); + + QCOMPARE(qfloat16(-val1) == qfloat16(-val2), -val1 == -val2); + QCOMPARE(qfloat16(-val1) < qfloat16(-val2), -val1 < -val2); + QCOMPARE(qfloat16(-val1) <= qfloat16(-val2), -val1 <= -val2); + QCOMPARE(qfloat16(-val1) > qfloat16(-val2), -val1 > -val2); + QCOMPARE(qfloat16(-val1) >= qfloat16(-val2), -val1 >= -val2); +} + +#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404) + // turn -ffast-math off +# pragma GCC optimize "no-fast-math" +#endif + +void tst_qfloat16::qNan() +{ +#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ < 404) + QSKIP("Non-conformant fast math mode is enabled, cannot run test"); +#endif + qfloat16 nan = qQNaN(); + QVERIFY(!(0. > nan)); + QVERIFY(!(0. < nan)); + QVERIFY(qIsNaN(nan)); + QVERIFY(qIsNaN(nan + 1.f)); + QVERIFY(qIsNaN(-nan)); + qfloat16 inf = qInf(); + QVERIFY(inf > qfloat16(0)); + QVERIFY(-inf < qfloat16(0)); + QVERIFY(qIsInf(inf)); + QVERIFY(qIsInf(-inf)); + QVERIFY(qIsInf(2.f*inf)); + QVERIFY(qIsInf(inf*2.f)); + QCOMPARE(qfloat16(1.f/inf), qfloat16(0.f)); +#ifdef Q_CC_INTEL + QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); +#endif + QVERIFY(qIsNaN(nan*0.f)); +#ifdef Q_CC_INTEL + QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); +#endif + QVERIFY(qIsNaN(inf*0.f)); + QVERIFY(qFuzzyCompare(qfloat16(1.f/inf), qfloat16(0.0))); +} + +void tst_qfloat16::float_cast_data() +{ + QTest::addColumn("val"); + + QTest::newRow("zero") << 0.f; + QTest::newRow("one") << 1e0f; + QTest::newRow("ten") << 1e1f; + QTest::newRow("hund") << 1e2f; + QTest::newRow("thou") << 1e3f; + QTest::newRow("tthou") << 1e4f; + //QTest::newRow("hthou") << 1e5f; + //QTest::newRow("mil") << 1e6f; + //QTest::newRow("tmil") << 1e7f; + //QTest::newRow("hmil") << 1e8f; +} + +void tst_qfloat16::float_cast() +{ + QFETCH(float, val); + + QVERIFY(qFuzzyCompare(float(qfloat16(val)),val)); + QVERIFY(qFuzzyCompare(float(qfloat16(-val)),-val)); +} + +void tst_qfloat16::promotionTests() +{ + QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)+qfloat16(1.f))); + QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)-qfloat16(1.f))); + QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)*qfloat16(1.f))); + QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)/qfloat16(1.f))); + + QCOMPARE(sizeof(float),sizeof(1.f+qfloat16(1.f))); + QCOMPARE(sizeof(float),sizeof(1.f-qfloat16(1.f))); + QCOMPARE(sizeof(float),sizeof(1.f*qfloat16(1.f))); + QCOMPARE(sizeof(float),sizeof(1.f/qfloat16(1.f))); + + QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)+1.f)); + QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)-1.f)); + QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)*1.f)); + QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)/1.f)); + + QCOMPARE(sizeof(double),sizeof(1.+qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1.-qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1.*qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1./qfloat16(1.f))); + + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)+1.)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)-1.)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)*1.)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)/1.)); + + QCOMPARE(sizeof(long double),sizeof((long double)(1.)+qfloat16(1.f))); + QCOMPARE(sizeof(long double),sizeof((long double)(1.)-qfloat16(1.f))); + QCOMPARE(sizeof(long double),sizeof((long double)(1.)*qfloat16(1.f))); + QCOMPARE(sizeof(long double),sizeof((long double)(1.)/qfloat16(1.f))); + + QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)+(long double)(1.))); + QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)-(long double)(1.))); + QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)*(long double)(1.))); + QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)/(long double)(1.))); + + QCOMPARE(sizeof(double),sizeof(1+qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1-qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1*qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1/qfloat16(1.f))); + + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)+1)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)-1)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)*1)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)/1)); +} + +QTEST_APPLESS_MAIN(tst_qfloat16) +#include "tst_qfloat16.moc" From bc232b2befd6add9b275f868302b0f4b005a22a4 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 31 Jan 2017 13:21:26 -0800 Subject: [PATCH 302/304] QCommonStyle: fix a few typos and formatting issues Change-Id: I7855795bf010865d5c2b8dd51538c446cdff1974 Reviewed-by: Jake Petroules --- src/widgets/styles/qcommonstyle.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index c174a7af26..18a0c4fb64 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1099,7 +1099,7 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w || opt->shape == QTabBar::TriangularEast || opt->shape == QTabBar::TriangularWest; if (verticalTabs) - tr.setRect(0, 0, tr.height(), tr.width()); //0, 0 as we will have a translate transform + tr.setRect(0, 0, tr.height(), tr.width()); // 0, 0 as we will have a translate transform int verticalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftVertical, opt, widget); int horizontalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, opt, widget); @@ -1122,7 +1122,7 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w // right widget if (!opt->rightButtonSize.isEmpty()) { tr.setRight(tr.right() - 4 - - (verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width())); + (verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width())); } // icon @@ -1134,12 +1134,12 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w } QSize tabIconSize = opt->icon.actualSize(iconSize, (opt->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled, - (opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off ); - // High-dpi icons do not need adjustmet; make sure tabIconSize is not larger than iconSize + (opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off); + // High-dpi icons do not need adjustment; make sure tabIconSize is not larger than iconSize tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.height())); *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2, - tabIconSize.width(), tabIconSize .height()); + tabIconSize.width(), tabIconSize.height()); if (!verticalTabs) *iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect); tr.setLeft(tr.left() + tabIconSize.width() + 4); From 3ac806b76da4f841bc168201eb314e00d4a85df1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 31 Jan 2017 13:16:06 -0800 Subject: [PATCH 303/304] De-inline qfloat16 streaming operators in QDataStream Which allows us to remove the #include. The qfloat16 operator overloads in the global namespace are giving some trouble on some compilers, for reasons unknown (could be compiler bug, could be real). So don't #include the header anywhere else: let the user choose it. Task-number: QTBUG-58555 Change-Id: I4c9f691516694b90b08ffffd149ef7dff27d0f6a Reviewed-by: Jani Heikkinen --- src/corelib/io/qdatastream.cpp | 11 ++++++++++- src/corelib/io/qdatastream.h | 9 +-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index cac5152e87..2369fe4726 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -42,6 +42,7 @@ #if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED) #include "qbuffer.h" +#include "qfloat16.h" #include "qstring.h" #include #include @@ -975,7 +976,6 @@ QDataStream &QDataStream::operator>>(double &f) /*! - \fn QDataStream &QDataStream::operator>>(qfloat16 &f) \overload \since 5.9 @@ -983,6 +983,11 @@ QDataStream &QDataStream::operator>>(double &f) using the standard IEEE 754 format. Returns a reference to the stream. */ +QDataStream &QDataStream::operator>>(qfloat16 &f) +{ + return *this >> reinterpret_cast(f); +} + /*! \overload @@ -1280,6 +1285,10 @@ QDataStream &QDataStream::operator<<(double f) Writes a floating point number, \a f, to the stream using the standard IEEE 754 format. Returns a reference to the stream. */ +QDataStream &QDataStream::operator<<(qfloat16 f) +{ + return *this << reinterpret_cast(f); +} /*! \overload diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index 9a7d7e275d..ecd55f71ae 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -43,7 +43,6 @@ #include #include #include -#include #ifdef Status #error qdatastream.h must be included before any header file that defines Status @@ -51,7 +50,7 @@ QT_BEGIN_NAMESPACE - +class qfloat16; class QByteArray; class QIODevice; @@ -348,9 +347,6 @@ inline QDataStream &QDataStream::operator>>(quint32 &i) inline QDataStream &QDataStream::operator>>(quint64 &i) { return *this >> reinterpret_cast(i); } -inline QDataStream &QDataStream::operator>>(qfloat16 &f) -{ return *this >> reinterpret_cast(f); } - inline QDataStream &QDataStream::operator<<(quint8 i) { return *this << qint8(i); } @@ -363,9 +359,6 @@ inline QDataStream &QDataStream::operator<<(quint32 i) inline QDataStream &QDataStream::operator<<(quint64 i) { return *this << qint64(i); } -inline QDataStream &QDataStream::operator<<(qfloat16 f) -{ return *this << reinterpret_cast(f); } - template inline QDataStream &operator>>(QDataStream &s, QList &l) { From ff68e5d667cc62141f177d01f747a62c95f08d3e Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 13 Dec 2016 12:27:55 +0100 Subject: [PATCH 304/304] Document new PCRE2 library [ChangeLog][Third-Party Code] The PCRE sources that are bundled with Qt got updated to version 10.22. Change-Id: Ib334fb4e9766035fd120ef4ab3a249322adba8eb Reviewed-by: Giuseppe D'Angelo --- src/3rdparty/pcre2/qt_attribution.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/3rdparty/pcre2/qt_attribution.json diff --git a/src/3rdparty/pcre2/qt_attribution.json b/src/3rdparty/pcre2/qt_attribution.json new file mode 100644 index 0000000000..2e80d51298 --- /dev/null +++ b/src/3rdparty/pcre2/qt_attribution.json @@ -0,0 +1,17 @@ +{ + "Id": "pcre2", + "Name": "PCRE2", + "QDocModule": "qtcore", + "QtUsage": "Optionally used in Qt Core (QRegularExpression). Configure with -system-pcre2 or -no-pcre2 to avoid.", + + "Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.", + "Homepage": "http://www.pcre.org/", + "Version": "10.22", + "License": "BSD 3-clause \"New\" or \"Revised\" License", + "LicenseId": "BSD-3-Clause", + "LicenseFile": "LICENCE", + "Copyright": "Copyright (c) 1997-2016 University of Cambridge +Copyright (c) 2009-2016 Zoltan Herczeg +Copyright (c) 2007-2012 Google Inc. +Copyright (c) 2013-2013 Tilera Corporation (jiwang@tilera.com)" +}