From 07fffa60103fed42efed86f928fcec30f9d98815 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Feb 2017 11:01:46 -0800 Subject: QDateTime: Fix clearing the ShortData flag in setMSecsSinceEpoch Unlike setTimeSpec, this forgot to clear the bit when detaching. So it's possible that some further use of the flags could incorrectly conclude that the data was short and then proceed to corrupt the pointer. The example from QTBUG-59061 caused this because toUTC() -> toTimeSpec() calls setMSecsSinceEpoch which left the bit set; then addDays() calls setDateTime(), which calls checkValidDateTime() and that corrupted the pointer. This problem was more visible on 32-bit systems because no QDateTime was short (except for default constructed ones), but it can happen on 64-bit with sufficiently large dates. Task-number: QTBUG-59061 Change-Id: Ibc5c715fda334a75bd2efffd14a562a375a4e69b Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetime.cpp | 5 ++++- .../auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 23 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index a642358770..bf92be2dd4 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2842,6 +2842,9 @@ inline bool QDateTime::Data::isShort() const { bool b = quintptr(d) & QDateTimePrivate::ShortData; + // sanity check: + Q_ASSERT(b || (d->m_status & QDateTimePrivate::ShortData) == 0); + // even if CanBeSmall = false, we have short data for a default-constructed // QDateTime object. But it's unlikely. if (CanBeSmall) @@ -3658,7 +3661,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs) d.data.status = status; } else { d.detach(); - d->m_status = status; + d->m_status = status & ~QDateTimePrivate::ShortData; d->m_msecs = msecs; } diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index e54edb490c..33844feafe 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -667,6 +667,29 @@ void tst_QDateTime::setMSecsSinceEpoch() QCOMPARE(dt.time(), utc.time()); QCOMPARE(dt.timeSpec(), Qt::UTC); + { + QDateTime dt1 = QDateTime::fromMSecsSinceEpoch(msecs, Qt::UTC); + QCOMPARE(dt1, utc); + QCOMPARE(dt1.date(), utc.date()); + QCOMPARE(dt1.time(), utc.time()); + QCOMPARE(dt1.timeSpec(), Qt::UTC); + } + { + QDateTime dt1(utc.date(), utc.time(), Qt::UTC); + QCOMPARE(dt1, utc); + QCOMPARE(dt1.date(), utc.date()); + QCOMPARE(dt1.time(), utc.time()); + QCOMPARE(dt1.timeSpec(), Qt::UTC); + } + { + // used to fail to clear the ShortData bit, causing corruption + QDateTime dt1 = dt.addDays(0); + QCOMPARE(dt1, utc); + QCOMPARE(dt1.date(), utc.date()); + QCOMPARE(dt1.time(), utc.time()); + QCOMPARE(dt1.timeSpec(), Qt::UTC); + } + if (zoneIsCET) { QCOMPARE(dt.toLocalTime(), cet); -- cgit v1.2.3 From 611b7c9ce77f1b02fc389583c24fbe7d49cce8a8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Feb 2017 13:01:08 +0100 Subject: de-duplicate and simplify condition checking in qtConfProcessOneOutput() amends 90eee08b3. Change-Id: If1fa2b14d758cc252d9a2ec3f9deedd1dd200c5e Reviewed-by: Lars Knoll --- mkspecs/features/qt_configure.prf | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 6d78dc9484..aeaf666a5c 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -1739,10 +1739,6 @@ defineTest(qtConfProcessOneOutput) { fpfx = $${currentConfig}.features.$${feature} opfx = $${fpfx}.output.$${2} - condition = $$eval($${opfx}.condition) - !isEmpty(condition):!$$qtConfEvaluate($$condition): \ - return() - call = $$eval($${opfx}.type) isEmpty(call) { # output is just a string, not an object @@ -1751,11 +1747,8 @@ defineTest(qtConfProcessOneOutput) { !defined("qtConfOutput_$$call", test): \ error("Undefined type '$$call' in output '$$2' of feature '$$feature'.") - condition = $$eval($${opfx}.condition) - !isEmpty(condition) { - !$$qtConfEvaluate($$condition): \ - return(false) - } + !$$qtConfEvaluate($$eval($${opfx}.condition)): \ + return() $${opfx}.feature = $$feature qtConfOutput_$${call}($$opfx, $$eval($${fpfx}.available)) -- cgit v1.2.3 From 76d667eff56afa8d3dbd61515b38762038fcb1ba Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 17 Feb 2017 09:45:05 +0100 Subject: make an effort to keep /src properties constant writing $$PWD (via $$QT_SOURCE_TREE) into the new bin/qt.conf would potentially change the path compared to the value originally written by the configure script, as $$PWD is canonicalized. this in turn would break the magic for delaying the loading of toolchain.prf. so instead just write out the perfectly fine current value of $$[QT_INSTALL_PREFIX/src]. amends 169a40d51, thereby fixing 6834d0eec on windows. Task-number: QTBUG-58816 Change-Id: Ibbd44df8f3c825a97d9f4acb869e44c93acb835b Reviewed-by: Joerg Bornemann Reviewed-by: Jake Petroules --- configure.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.pri b/configure.pri index a5e77411ee..30e31ddbcd 100644 --- a/configure.pri +++ b/configure.pri @@ -805,7 +805,7 @@ defineTest(qtConfOutput_preparePaths) { !equals(QT_SOURCE_TREE, $$QT_BUILD_TREE): \ cont += \ "[EffectiveSourcePaths]" \ - "Prefix=$$QT_SOURCE_TREE" + "Prefix=$$[QT_INSTALL_PREFIX/src]" write_file($$QT_BUILD_TREE/bin/qt.conf, cont)|error() reload_properties() -- cgit v1.2.3 From 0af9999c8bde58802131e6c7d95f6752090638a7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 17 Feb 2017 10:17:10 +0100 Subject: fix generation of QSql header the classname definition must name the new real header, not the generated deprecated one. amends 7331d22c6. Task-number: QTBUG-58844 Change-Id: I2721d1f682a4ca0f986184fe7c8321976a540b4c Reviewed-by: Joerg Bornemann --- sync.profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sync.profile b/sync.profile index ef2779ae48..ce9c828871 100644 --- a/sync.profile +++ b/sync.profile @@ -52,7 +52,7 @@ "qnumeric.h" => "QtNumeric", "qvariant.h" => "QVariantHash,QVariantList,QVariantMap", "qgl.h" => "QGL", - "qsql.h" => "QSql", + "qtsqlglobal.h" => "QSql", "qssl.h" => "QSsl", "qtest.h" => "QTest", "qtconcurrentmap.h" => "QtConcurrentMap", -- cgit v1.2.3 From b9c5c7139ea1054f69a1c43ca2cd7212206a41e5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Feb 2017 17:39:43 +0100 Subject: don't assume that configure --foo options' value is 'yes' otherwise, the invalid "--qpa xcb" would complain about "xcb" being unknown, rather than "--qpa" missing an argument. actual booleans are handled by the type-specific callback, just like -foo would be. Task-number: QTBUG-59062 Change-Id: I96632dacfb721cfcbf223b76f6c5c38c810e8d0e Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_configure.prf | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index aeaf666a5c..656a885795 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -125,7 +125,8 @@ defineTest(qtConfValidateValue) { defineTest(qtConfCommandline_string) { opt = $${1} val = $${2} - isEmpty(val): val = $$qtConfGetNextCommandlineArg() + nextok = $${3} + isEmpty(val):$$nextok: val = $$qtConfGetNextCommandlineArg() # Note: Arguments which are variable assignments are legit here. contains(val, "^-.*")|isEmpty(val) { @@ -142,9 +143,10 @@ defineTest(qtConfCommandline_string) { defineTest(qtConfCommandline_optionalString) { opt = $${1} val = $${2} + nextok = $${3} isEmpty(val) { - v = $$qtConfPeekNextCommandlineArg() - contains(v, "^-.*|[A-Z_]+=.*")|isEmpty(v): \ + $$nextok: val = $$qtConfPeekNextCommandlineArg() + contains(val, "^-.*|[A-Z_]+=.*")|isEmpty(val): \ val = "yes" else: \ val = $$qtConfGetNextCommandlineArg() @@ -160,7 +162,8 @@ defineTest(qtConfCommandline_optionalString) { defineTest(qtConfCommandline_addString) { opt = $${1} val = $${2} - isEmpty(val): val = $$qtConfGetNextCommandlineArg() + nextok = $${3} + isEmpty(val):$$nextok: val = $$qtConfGetNextCommandlineArg() # Note: Arguments which are variable assignments are legit here. contains(val, "^-.*")|isEmpty(val) { @@ -236,6 +239,7 @@ defineTest(qtConfParseCommandLine) { } # parse out opt and val + nextok = false contains(c, "^--?enable-(.*)") { opt = $$replace(c, "^--?enable-(.*)", "\\1") val = yes @@ -247,10 +251,11 @@ defineTest(qtConfParseCommandLine) { val = $$replace(c, "^--([^=]+)=(.*)", "\\2") } else: contains(c, "^--(.*)") { opt = $$replace(c, "^--(.*)", "\\1") - val = yes + val = } else: contains(c, "^-(.*)") { opt = $$replace(c, "^-(.*)", "\\1") val = + nextok = true for (cc, allConfigs) { type = $$eval($${cc}.commandline.options.$${opt}) !isEmpty(type): break() @@ -277,6 +282,7 @@ defineTest(qtConfParseCommandLine) { contains(c, $$e) { opt = $$eval($${cc}.commandline.prefix.$${p}) val = $$replace(c, $$e, "\\1") + nextok = true type = "addString" break() } @@ -315,7 +321,7 @@ defineTest(qtConfParseCommandLine) { error("Command line option '$$c' has unknown type '$$type'.") # now that we have opt and value, process it - $${call}($$opt, $$val) + $${call}($$opt, $$val, $$nextok) } } -- cgit v1.2.3 From d37c353dc0f2ae5bb803fe9e5752eff846246439 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 23 Feb 2017 14:33:57 +0100 Subject: remove unused Xlib's XRender dependency We do use xcb-xrender, and it has its own detection logic in configure.json. Change-Id: I20bbc1ddf5dd0c32e93ef2c12c7b0eda3f96f4f4 Reviewed-by: Alexander Volkov Reviewed-by: Oswald Buddenhagen --- config.tests/x11/xrender/xrender.cpp | 52 ---------------------- config.tests/x11/xrender/xrender.pro | 3 -- src/gui/configure.json | 17 +------ .../glxconvenience/glxconvenience.pro | 1 - .../glxconvenience/qglxconvenience.cpp | 4 -- 5 files changed, 2 insertions(+), 75 deletions(-) delete mode 100644 config.tests/x11/xrender/xrender.cpp delete mode 100644 config.tests/x11/xrender/xrender.pro diff --git a/config.tests/x11/xrender/xrender.cpp b/config.tests/x11/xrender/xrender.cpp deleted file mode 100644 index 223328a3df..0000000000 --- a/config.tests/x11/xrender/xrender.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -#if RENDER_MAJOR == 0 && RENDER_MINOR < 5 -# error "Required Xrender version 0.6 not found." -#else -int main(int, char **) -{ - XRenderPictFormat *format; - format = 0; - return 0; -} -#endif diff --git a/config.tests/x11/xrender/xrender.pro b/config.tests/x11/xrender/xrender.pro deleted file mode 100644 index ab5c5efa77..0000000000 --- a/config.tests/x11/xrender/xrender.pro +++ /dev/null @@ -1,3 +0,0 @@ -SOURCES = xrender.cpp -CONFIG += x11 -CONFIG -= qt diff --git a/src/gui/configure.json b/src/gui/configure.json index 68bc43b5ca..81fa0db76f 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -43,8 +43,7 @@ "xkb-config-root": "string", "xkbcommon": { "type": "enum", "values": [ "no", "qt", "system" ] }, "xkbcommon-evdev": "boolean", - "xkbcommon-x11": { "type": "enum", "name": "xkbcommon", "values": [ "no", "qt", "system" ] }, - "xrender": "boolean" + "xkbcommon-x11": { "type": "enum", "name": "xkbcommon", "values": [ "no", "qt", "system" ] } } }, @@ -285,13 +284,6 @@ "sources": [ { "type": "pkgConfig", "args": "xkbcommon xkbcommon-x11 >= 0.4.1" } ] - }, - "xrender": { - "label": "XRender", - "test": "x11/xrender", - "sources": [ - "-lXrender" - ] } }, @@ -776,11 +768,6 @@ "condition": "tests.xlib", "output": [ "privateFeature" ] }, - "xrender": { - "label": "Xrender", - "condition": "libs.xrender", - "output": [ "privateFeature", "feature" ] - }, "texthtmlparser": { "label": "HtmlParser", "purpose": "Provides a parser for HTML.", @@ -1108,7 +1095,7 @@ QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your pla "section": "X11", "condition": "features.xcb", "entries": [ - "system-xcb", "egl_x11", "xinput2", "xkb", "xlib", "xrender", "xcb-render", "xcb-glx", "xcb-xlib", "xkbcommon-system" + "system-xcb", "egl_x11", "xinput2", "xkb", "xlib", "xcb-render", "xcb-glx", "xcb-xlib", "xkbcommon-system" ] }, { diff --git a/src/platformsupport/glxconvenience/glxconvenience.pro b/src/platformsupport/glxconvenience/glxconvenience.pro index 185d6b0364..41c96d8f0d 100644 --- a/src/platformsupport/glxconvenience/glxconvenience.pro +++ b/src/platformsupport/glxconvenience/glxconvenience.pro @@ -7,7 +7,6 @@ CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h -qtConfig(xrender): QMAKE_USE_PRIVATE += xrender LIBS_PRIVATE += $$QMAKE_LIBS_X11 HEADERS += qglxconvenience_p.h diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index 4225bebf37..8c26550c1e 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -47,10 +47,6 @@ #include #include -#ifndef QT_NO_XRENDER -#include -#endif - #include enum { -- cgit v1.2.3 From e3bcab935c9fe37b344394c3ee8afd6773a8cd7e Mon Sep 17 00:00:00 2001 From: Christian Gagneraud Date: Wed, 22 Feb 2017 12:15:41 +1300 Subject: Fix documentation typos This patch fixes 2 simple typos in QGraphicsItem and QPainter documentation and a copy/paste error between QAbstractItemModel's beginRemoveColumns and beginRemoveRows documentation. Change-Id: I32bdc4dc69154a40fe30a5b8c08d0c3a001853f8 Reviewed-by: Harri Porten Reviewed-by: Marc Mutz --- src/corelib/itemmodels/qabstractitemmodel.cpp | 2 +- src/gui/painting/qpainter.cpp | 2 +- src/widgets/graphicsview/qgraphicsitem.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 7fdf107383..6848a408f6 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3071,7 +3071,7 @@ void QAbstractItemModel::endRemoveColumns() When reimplementing a subclass, this method simplifies moving entities in your model. This method is responsible for moving persistent indexes in the model, which you would otherwise be - required to do yourself. Using beginMoveRows and endMoveRows + required to do yourself. Using beginMoveColumns and endMoveColumns is an alternative to emitting layoutAboutToBeChanged and layoutChanged directly along with changePersistentIndex. diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 083e68fcdb..b186182c34 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5968,7 +5968,7 @@ void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br \snippet code/src_gui_painting_qpainter.cpp 17 \endtable - The \a boundingRect (if not null) is set to the what the bounding rectangle + The \a boundingRect (if not null) is set to what the bounding rectangle should be in order to enclose the whole text. For example, in the following image, the dotted line represents \a boundingRect as calculated by the function, and the dashed line represents \a rectangle: diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index c9eea6928a..4fc52e6ad4 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -4516,7 +4516,7 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) otherwise, \a matrix \e replaces the current matrix. \a combine is false by default. - To simplify interation with items using a transformed view, QGraphicsItem + To simplify interaction with items using a transformed view, QGraphicsItem provides mapTo... and mapFrom... functions that can translate between items' and the scene's coordinates. For example, you can call mapToScene() to map an item coordiate to a scene coordinate, or mapFromScene() to map -- cgit v1.2.3 From 1b81f931839229fbc2e1769d2d3ea62a108727c4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 17 Feb 2017 10:10:39 -0800 Subject: forkfd: use SA_SIGINFO to pass extra information to chained handlers This existed in QProcess before forkfd, but was lost in the port to it (commit 1814142b7a11befab315bf3f9d91c4ffbf56ef3e). The original QProcess fix was done in 97279d05822a70da1fb3dab083d823a5f5a008fe. Task-number: QTBUG-57584 Change-Id: Ibc5c715fda334a75bd2efffd14a425871f3162b5 Reviewed-by: Edward Welbourne --- src/3rdparty/forkfd/forkfd.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index e57d9aa1e0..309458a3a7 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -281,7 +281,7 @@ static void notifyAndFreeInfo(Header *header, ProcessInfo *entry, freeInfo(header, entry); } -static void sigchld_handler(int signum) +static void sigchld_handler(int signum, siginfo_t *handler_info, void *handler_context) { /* * This is a signal handler, so we need to be careful about which functions @@ -289,7 +289,18 @@ static void sigchld_handler(int signum) * specification at: * http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03 * + * The handler_info and handler_context parameters may not be valid, if + * we're a chained handler from another handler that did not use + * SA_SIGINFO. Therefore, we must obtain the siginfo ourselves directly by + * calling waitid. + * + * But we pass them anyway. Let's call the chained handler first, while + * those two arguments have a chance of being correct. */ + if (old_sigaction.sa_flags & SA_SIGINFO) + old_sigaction.sa_sigaction(signum, handler_info, handler_context); + else if (old_sigaction.sa_handler != SIG_IGN && old_sigaction.sa_handler != SIG_DFL) + old_sigaction.sa_handler(signum); if (ffd_atomic_load(&forkfd_status, FFD_ATOMIC_RELAXED) == 1) { /* is this one of our children? */ @@ -317,9 +328,8 @@ search_next_child: waitid(P_ALL, 0, &info, WNOHANG | WNOWAIT | WEXITED); if (info.si_pid == 0) { /* there are no further un-waited-for children, so we can just exit. - * But before, transfer control to the chained SIGCHLD handler. */ - goto chain_handler; + return; } for (i = 0; i < (int)sizeofarray(children.entries); ++i) { @@ -407,12 +417,6 @@ search_arrays: array = ffd_atomic_load(&array->header.nextArray, FFD_ATOMIC_ACQUIRE); } } - -#ifdef HAVE_WAITID -chain_handler: -#endif - if (old_sigaction.sa_handler != SIG_IGN && old_sigaction.sa_handler != SIG_DFL) - old_sigaction.sa_handler(signum); } static void ignore_sigpipe() @@ -457,8 +461,8 @@ static void forkfd_initialize() struct sigaction action; memset(&action, 0, sizeof action); sigemptyset(&action.sa_mask); - action.sa_flags = SA_NOCLDSTOP; - action.sa_handler = sigchld_handler; + action.sa_flags = SA_NOCLDSTOP | SA_SIGINFO; + action.sa_sigaction = sigchld_handler; /* ### RACE CONDITION * The sigaction function does a memcpy from an internal buffer -- cgit v1.2.3 From 0d7ed8f5f3b8a308c495c71c7427b41157d769b1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Feb 2017 17:39:47 +0100 Subject: streamline libdl detection and linking instead of having a library and a test, use a library with two sources, the first being empty (i.e., just libc). this allows us doing away with the "libdl" feature, and using just the "dlopen" one. subsequently, replace all LIBS+=$$QMAKE_LIBS_DYNLOAD with QMAKE_USE+=libdl. the definitions of QMAKE_LIBS_DYNLOAD remain in the qmakespecs for backwards compat only. n.b.: the only specs where it is not empty or "-ldl" (i.e., what we support now) are the hpux ones, where the library is called 'dld'. technically, the "library" feature should depend on '!unix || dlopen', but that's for a later patch. Change-Id: Ib8546affc4b7bc757f1a76729573ddd00e152176 Reviewed-by: Lars Knoll Reviewed-by: Ulf Hermann --- src/corelib/configure.json | 17 ++++------------- src/corelib/plugin/plugin.pri | 2 +- src/platformsupport/eglconvenience/eglconvenience.pro | 2 +- src/plugins/platforms/eglfs/eglfsdeviceintegration.pro | 2 -- .../xcb/gl_integrations/xcb_glx/qglxintegration.cpp | 4 ++-- .../platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro | 2 +- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 76dfed3128..c13ad25c15 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -74,10 +74,10 @@ ] }, "libdl": { - "label": "dlopen() in libdl", - "export": "", + "label": "dlopen()", "test": "unix/dlopen", "sources": [ + "", "-ldl" ] }, @@ -131,11 +131,6 @@ "type": "compile", "test": "unix/cloexec" }, - "dlopen": { - "label": "dlopen() in libc", - "type": "compile", - "test": "unix/dlopen" - }, "eventfd": { "label": "eventfd", "type": "compile", @@ -211,12 +206,8 @@ }, "dlopen": { "label": "dlopen()", - "condition": "tests.dlopen || libs.libdl" - }, - "libdl": { - "label": "dlopen() in libdl", - "condition": "!tests.dlopen && libs.libdl", - "output": [ { "type": "privateConfig", "negative": true } ] + "condition": "config.unix && libs.libdl", + "output": [ "privateFeature" ] }, "doubleconversion": { "label": "DoubleConversion", diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri index 473480eb55..bb3843cc36 100644 --- a/src/corelib/plugin/plugin.pri +++ b/src/corelib/plugin/plugin.pri @@ -35,4 +35,4 @@ integrity { SOURCES += plugin/qlibrary_unix.cpp } -!no-libdl: LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD +qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl diff --git a/src/platformsupport/eglconvenience/eglconvenience.pro b/src/platformsupport/eglconvenience/eglconvenience.pro index d364a42b3b..4301d63574 100644 --- a/src/platformsupport/eglconvenience/eglconvenience.pro +++ b/src/platformsupport/eglconvenience/eglconvenience.pro @@ -38,6 +38,6 @@ qtConfig(xlib) { } CONFIG += egl -LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD +qtConfig(dlopen): QMAKE_USE += libdl load(qt_module) diff --git a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro index 35af3615bd..2593df937b 100644 --- a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro +++ b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro @@ -17,8 +17,6 @@ QT += \ qtHaveModule(input_support-private): \ QT += input_support-private -LIBS += $$QMAKE_LIBS_DYNLOAD - # Avoid X11 header collision, use generic EGL native types DEFINES += QT_EGL_NO_X11 diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 1f36a1ad2a..56b2b1fd23 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -54,7 +54,7 @@ #include #include -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) +#if !defined(QT_STATIC) && QT_CONFIG(dlopen) #include #endif @@ -564,7 +564,7 @@ QFunctionPointer QGLXContext::getProcAddress(const char *procName) if (!glXGetProcAddressARB) { QList glxExt = QByteArray(glXGetClientString(m_display, GLX_EXTENSIONS)).split(' '); if (glxExt.contains("GLX_ARB_get_proc_address")) { -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) +#if QT_CONFIG(dlopen) void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB"); diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro index 8aa6e1febd..215f5a3fe1 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro @@ -12,7 +12,7 @@ qtConfig(xcb-glx) { QMAKE_USE += xcb_glx } -LIBS += $$QMAKE_LIBS_DYNLOAD +!static:qtConfig(dlopen): QMAKE_USE += libdl HEADERS += \ qxcbglxintegration.h \ -- cgit v1.2.3 From 85b30fda7ceccecfd3938703979b3431bdedc9a2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Feb 2017 18:37:05 +0100 Subject: fix detection of static icu under unix the library has a dependency on libdl. Task-number: QTBUG-58301 Change-Id: I36567ded32980b241ff2f01cfdec044510405a75 Reviewed-by: Thiago Macieira Reviewed-by: Joerg Bornemann --- src/corelib/configure.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/configure.json b/src/corelib/configure.json index c13ad25c15..6da3b61a2d 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -56,6 +56,9 @@ }, { "libs": "-licuin -licuuc -licudt", "condition": "config.win32 && features.shared" }, { "libs": "-licui18n -licuuc -licudata", "condition": "!config.win32" } + ], + "use": [ + { "lib": "libdl", "condition": "features.dlopen" } ] }, "journald": { -- cgit v1.2.3 From 44af54419eaceb27bb729717d6363917fd6bb819 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 12:25:17 +0100 Subject: Properly use the "process" feature Replace all QT_NO_PROCESS with QT_CONFIG(process), define it in qconfig-bootstrapped.h, add QT_REQUIRE_CONFIG(process) to the qprocess headers, exclude the sources from compilation when switched off, guard header inclusions in places where compilation without QProcess seems supported, drop some unused includes, and fix some tests that were apparently designed to work with QT_NO_PROCESS but failed to. Change-Id: Ieceea2504dea6fdf43b81c7c6b65c547b01b9714 Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qconfig-bootstrapped.h | 1 + src/corelib/io/forkfd_qt.cpp | 1 - src/corelib/io/io.pri | 18 ++++++--- src/corelib/io/qprocess.cpp | 5 --- src/corelib/io/qprocess.h | 7 +--- src/corelib/io/qprocess_p.h | 7 ++-- src/corelib/io/qprocess_unix.cpp | 4 -- src/corelib/io/qprocess_win.cpp | 4 -- src/corelib/io/qwindowspipewriter_p.h | 2 +- src/corelib/kernel/qcore_unix_p.h | 4 +- .../services/genericunix/qgenericunixservices.cpp | 6 ++- src/testlib/qbenchmark.cpp | 1 - src/testlib/qbenchmark_p.h | 2 +- src/testlib/qtestcase.cpp | 1 - src/widgets/styles/qfusionstyle.cpp | 1 - .../corelib/codecs/qtextcodec/tst_qtextcodec.cpp | 6 ++- .../auto/corelib/global/qlogging/tst_qlogging.cpp | 14 ++++--- tests/auto/corelib/io/io.pro | 8 ++-- tests/auto/corelib/io/qdir/tst_qdir.cpp | 4 +- tests/auto/corelib/io/qfile/tst_qfile.cpp | 14 ++++--- tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp | 28 +++++++------- .../corelib/io/qprocess/testForwarding/main.cpp | 2 - tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 13 ------- .../corelib/io/qtextstream/tst_qtextstream.cpp | 11 +++--- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 9 +++-- .../qsharedmemory/test/tst_qsharedmemory.cpp | 12 +++--- .../qsystemsemaphore/test/tst_qsystemsemaphore.cpp | 8 ++-- .../tst_qmimedatabase-cache.cpp | 2 +- .../mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 12 +++--- tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 4 +- .../thread/qthreadstorage/tst_qthreadstorage.cpp | 6 +-- .../qcommandlineparser/tst_qcommandlineparser.cpp | 12 +++--- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 12 +++--- .../corelib/tools/qsharedpointer/externaltests.cpp | 18 +++++---- .../dbus/qdbusconnection/tst_qdbusconnection.cpp | 2 +- tests/auto/gui/image/qicon/tst_qicon.cpp | 4 +- .../auto/gui/kernel/qclipboard/tst_qclipboard.cpp | 16 ++++---- tests/auto/gui/text/qfont/tst_qfont.cpp | 2 +- .../access/qnetworkreply/tst_qnetworkreply.cpp | 6 +-- .../qnetworksession/test/tst_qnetworksession.cpp | 2 +- .../socket/qlocalsocket/tst_qlocalsocket.cpp | 4 +- .../network/socket/qtcpserver/tst_qtcpserver.cpp | 6 ++- .../network/socket/qtcpsocket/tst_qtcpsocket.cpp | 8 ++-- .../network/socket/qudpsocket/tst_qudpsocket.cpp | 4 +- .../other/networkselftest/tst_networkselftest.cpp | 6 +-- tests/auto/other/other.pro | 5 +-- .../tst_qprocess_and_guieventloop.cpp | 4 +- tests/auto/testlib/selftests/tst_selftests.cpp | 8 ++-- tests/auto/tools/moc/tst_moc.cpp | 44 ++++++++++++---------- .../kernel/qapplication/tst_qapplication.cpp | 12 +++--- .../widgets/util/qundogroup/tst_qundogroup.cpp | 2 +- .../widgets/util/qundostack/tst_qundostack.cpp | 2 +- tests/baselineserver/shared/baselineprotocol.cpp | 10 +++-- tests/baselineserver/shared/qbaselinetest.cpp | 8 ++-- tests/benchmarks/corelib/io/io.pro | 2 +- .../corelib/io/qprocess/tst_bench_qprocess.cpp | 6 --- 56 files changed, 209 insertions(+), 213 deletions(-) diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 1c806e0774..a2c0b011e7 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -74,6 +74,7 @@ #define QT_NO_LIBRARY #define QT_FEATURE_library -1 #define QT_NO_QOBJECT +#define QT_FEATURE_process -1 #define QT_NO_SYSTEMLOCALE #define QT_FEATURE_slog2 -1 #define QT_FEATURE_syslog -1 diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp index 141efeb08c..dce0ebb4da 100644 --- a/src/corelib/io/forkfd_qt.cpp +++ b/src/corelib/io/forkfd_qt.cpp @@ -39,7 +39,6 @@ // these might be defined via precompiled headers #include -#include "qprocess_p.h" #define FORKFD_NO_SPAWNFD diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 0414ae966a..b5bfec8857 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -22,8 +22,6 @@ HEADERS += \ io/qlockfile.h \ io/qlockfile_p.h \ io/qnoncontiguousbytedevice_p.h \ - io/qprocess.h \ - io/qprocess_p.h \ io/qtextstream.h \ io/qtextstream_p.h \ io/qtemporarydir.h \ @@ -72,7 +70,6 @@ SOURCES += \ io/qiodevice.cpp \ io/qlockfile.cpp \ io/qnoncontiguousbytedevice.cpp \ - io/qprocess.cpp \ io/qstorageinfo.cpp \ io/qtextstream.cpp \ io/qtemporarydir.cpp \ @@ -96,6 +93,19 @@ SOURCES += \ io/qloggingcategory.cpp \ io/qloggingregistry.cpp +qtConfig(process) { + SOURCES += \ + io/qprocess.cpp + HEADERS += \ + io/qprocess.h \ + io/qprocess_p.h + + win32:!winrt: \ + SOURCES += io/qprocess_win.cpp + else: unix: \ + SOURCES += io/qprocess_unix.cpp +} + win32 { SOURCES += io/qfsfileengine_win.cpp SOURCES += io/qlockfile_win.cpp @@ -112,7 +122,6 @@ win32 { io/qwinoverlappedionotifier_p.h SOURCES += \ - io/qprocess_win.cpp \ io/qsettings_win.cpp \ io/qstandardpaths_win.cpp \ io/qstorageinfo_win.cpp \ @@ -132,7 +141,6 @@ win32 { io/qfsfileengine_unix.cpp \ io/qfilesystemengine_unix.cpp \ io/qlockfile_unix.cpp \ - io/qprocess_unix.cpp \ io/qfilesystemiterator_unix.cpp !integrity:!uikit { diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index c7d6cb426d..fd340ca607 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -99,8 +99,6 @@ QT_END_NAMESPACE #include #endif -#ifndef QT_NO_PROCESS - QT_BEGIN_NAMESPACE /*! @@ -2604,6 +2602,3 @@ QString QProcess::nullDevice() QT_END_NAMESPACE #include "moc_qprocess.cpp" - -#endif // QT_NO_PROCESS - diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 4ce0503761..67c163c012 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -46,10 +46,9 @@ #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(process); -#ifndef QT_NO_PROCESS +QT_BEGIN_NAMESPACE #if !defined(Q_OS_WIN) || defined(Q_QDOC) typedef qint64 Q_PID; @@ -298,8 +297,6 @@ private: friend class QProcessManager; }; -#endif // QT_NO_PROCESS - QT_END_NAMESPACE #endif // QPROCESS_H diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index ae236c8c60..250eeb5de6 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -57,6 +57,9 @@ #include "QtCore/qhash.h" #include "QtCore/qshareddata.h" #include "private/qiodevice_p.h" + +QT_REQUIRE_CONFIG(process); + #ifdef Q_OS_UNIX #include #endif @@ -70,8 +73,6 @@ typedef int Q_PIPE; #define INVALID_Q_PIPE -1 #endif -#ifndef QT_NO_PROCESS - QT_BEGIN_NAMESPACE class QSocketNotifier; @@ -388,6 +389,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_PROCESS - #endif // QPROCESS_P_H diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index b39816dd7d..03e2c0c4ce 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -41,8 +41,6 @@ //#define QPROCESS_DEBUG #include "qdebug.h" -#ifndef QT_NO_PROCESS - #if defined QPROCESS_DEBUG #include "private/qtools_p.h" #include @@ -1045,5 +1043,3 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a } QT_END_NAMESPACE - -#endif // QT_NO_PROCESS diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index d0e922bf2b..6dd431eb47 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -59,8 +59,6 @@ #define PIPE_REJECT_REMOTE_CLIENTS 0x08 #endif -#ifndef QT_NO_PROCESS - QT_BEGIN_NAMESPACE //#define QPROCESS_DEBUG @@ -893,5 +891,3 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a } QT_END_NAMESPACE - -#endif // QT_NO_PROCESS diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index 5a0d04855f..c43e986f34 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -156,4 +156,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_PROCESS +#endif // QWINDOWSPIPEWRITER_P_H diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 80058d9115..8f37aec6e2 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -300,7 +300,7 @@ static inline int qt_safe_close(int fd) #define QT_CLOSE qt_safe_close // - VxWorks & iOS/tvOS/watchOS don't have processes -#if !defined(Q_OS_VXWORKS) && !defined(QT_NO_PROCESS) +#if QT_CONFIG(process) static inline int qt_safe_execve(const char *filename, char *const argv[], char *const envp[]) { @@ -329,7 +329,7 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options) EINTR_LOOP(ret, ::waitpid(pid, status, options)); return ret; } -#endif // Q_OS_VXWORKS +#endif // QT_CONFIG(process) #if !defined(_POSIX_MONOTONIC_CLOCK) # define _POSIX_MONOTONIC_CLOCK -1 diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index a24ab82057..01d988fdbe 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -41,7 +41,9 @@ #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include #include @@ -121,7 +123,7 @@ static inline bool launch(const QString &launcher, const QUrl &url) const QString command = launcher + QLatin1Char(' ') + QLatin1String(url.toEncoded()); if (debug) qDebug("Launching %s", qPrintable(command)); -#if defined(QT_NO_PROCESS) +#if !QT_CONFIG(process) const bool ok = ::system(qPrintable(command + QLatin1String(" &"))); #else const bool ok = QProcess::startDetached(command); diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index c933a16c35..d49d07bb70 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -42,7 +42,6 @@ #include #include -#include #include #include #include diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h index 0b16f624df..69b33d2d58 100644 --- a/src/testlib/qbenchmark_p.h +++ b/src/testlib/qbenchmark_p.h @@ -55,7 +55,7 @@ #include -#if (defined(Q_OS_LINUX) || defined Q_OS_MAC) && !defined(QT_NO_PROCESS) +#if (defined(Q_OS_LINUX) || defined Q_OS_MACOS) && QT_CONFIG(process) #define QTESTLIB_USE_VALGRIND #else #undef QTESTLIB_USE_VALGRIND diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 31ffb36690..d0f4f76fe5 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index e08cd3ac70..7cfb51743d 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index bdd862e316..0f2e9b5d68 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -33,7 +33,9 @@ #include #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include class tst_QTextCodec : public QObject @@ -2085,7 +2087,7 @@ void tst_QTextCodec::codecForUtfText() #if defined(Q_OS_UNIX) void tst_QTextCodec::toLocal8Bit() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess process; diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index c2d7338042..bb8bb6cc21 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -29,7 +29,9 @@ #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include class tst_qmessagehandler : public QObject @@ -102,7 +104,7 @@ void tst_qmessagehandler::initTestCase() QVERIFY2(!m_appDir.isEmpty(), qPrintable( QString::fromLatin1("Couldn't find helper app dir starting from %1.").arg(QDir::currentPath()))); -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) m_baseEnvironment = QProcess::systemEnvironment(); for (int i = 0; i < m_baseEnvironment.count(); ++i) { if (m_baseEnvironment.at(i).startsWith("QT_MESSAGE_PATTERN=")) { @@ -110,7 +112,7 @@ void tst_qmessagehandler::initTestCase() break; } } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_qmessagehandler::cleanup() @@ -813,7 +815,7 @@ void tst_qmessagehandler::qMessagePattern_data() void tst_qmessagehandler::qMessagePattern() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QFETCH(QString, pattern); @@ -855,7 +857,7 @@ void tst_qmessagehandler::qMessagePattern() void tst_qmessagehandler::setMessagePattern() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else @@ -892,7 +894,7 @@ void tst_qmessagehandler::setMessagePattern() output.replace("\r\n", "\n"); #endif QCOMPARE(QString::fromLatin1(output), QString::fromLatin1(expected)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } Q_DECLARE_METATYPE(QtMsgType) diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index 0542833456..5e20f5de5c 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -56,12 +56,14 @@ SUBDIRS=\ qurlinternal \ qloggingregistry +!qtConfig(process): SUBDIRS -= \ + qprocess \ + qprocess-noapplication \ + qprocessenvironment + win32:!qtConfig(private_tests): SUBDIRS -= \ qfilesystementry winrt: SUBDIRS -= \ - qprocess \ - qprocess-noapplication \ - qprocessenvironment \ qstorageinfo \ qwinoverlappedionotifier diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index c3774997e9..6232ce4c66 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -852,7 +852,7 @@ void tst_QDir::entryList() void tst_QDir::entryListTimedSort() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString touchBinary = "/bin/touch"; if (!QFile::exists(touchBinary)) QSKIP("/bin/touch not found"); @@ -886,7 +886,7 @@ void tst_QDir::entryListTimedSort() QCOMPARE(actual.last(), aFileInfo.fileName()); #else QSKIP("This test requires QProcess support."); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QDir::entryListSimple_data() diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 34ad2813b0..8595c048b2 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -50,7 +50,9 @@ QT_END_NAMESPACE #if !defined(QT_NO_NETWORK) #include #endif -#include +#if QT_CONFIG(process) +# include +#endif #ifdef Q_OS_WIN # include #else @@ -884,7 +886,7 @@ void tst_QFile::readAllBuffer() QFile::remove(fileName); } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) class StdinReaderProcessGuard { // Ensure the stdin reader process is stopped on destruction. Q_DISABLE_COPY(StdinReaderProcessGuard) @@ -908,11 +910,11 @@ public: private: QProcess *m_process; }; -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) void tst_QFile::readAllStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QByteArray lotsOfData(1024, '@'); // 10 megs @@ -935,7 +937,7 @@ void tst_QFile::readAllStdin() void tst_QFile::readLineStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QByteArray lotsOfData(1024, '@'); // 10 megs @@ -976,7 +978,7 @@ void tst_QFile::readLineStdin() void tst_QFile::readLineStdin_lineByLine() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else for (int i = 0; i < 2; ++i) { diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index b21701f341..a13ff0358a 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -72,7 +72,7 @@ void tst_QLockFile::initTestCase() { #if defined(Q_OS_ANDROID) QSKIP("This test requires deploying and running external console applications"); -#elif defined(QT_NO_PROCESS) +#elif !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QVERIFY2(dir.isValid(), qPrintable(dir.errorString())); @@ -80,7 +80,7 @@ void tst_QLockFile::initTestCase() QString testdata_dir = QFileInfo(QFINDTESTDATA("qlockfiletesthelper")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); m_helperApp = "qlockfiletesthelper/qlockfile_test_helper"; -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::lockUnlock() @@ -114,7 +114,7 @@ void tst_QLockFile::lockUnlock() void tst_QLockFile::lockOutOtherProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else // Lock @@ -138,7 +138,7 @@ void tst_QLockFile::lockOutOtherProcess() QCOMPARE(ret, int(QLockFile::NoError)); // Lock doesn't survive process though (on clean exit) QVERIFY(!QFile::exists(fileName)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } static QLockFile::LockError tryLockFromThread(const QString &fileName) @@ -254,7 +254,7 @@ void tst_QLockFile::staleLockFromCrashedProcess_data() void tst_QLockFile::staleLockFromCrashedProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QFETCH(int, staleLockTime); @@ -274,12 +274,12 @@ void tst_QLockFile::staleLockFromCrashedProcess() QVERIFY(secondLock.tryLock()); #endif QCOMPARE(int(secondLock.error()), int(QLockFile::NoError)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::staleLockFromCrashedProcessReusedPid() { -#if defined(QT_NO_PROCESS) +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #elif defined(Q_OS_WINRT) || defined(QT_PLATFORM_UIKIT) QSKIP("We cannot retrieve information about other processes on this platform."); @@ -298,12 +298,12 @@ void tst_QLockFile::staleLockFromCrashedProcessReusedPid() secondLock.setStaleLockTime(0); QVERIFY(secondLock.tryLock()); QCOMPARE(int(secondLock.error()), int(QLockFile::NoError)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::staleShortLockFromBusyProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else const QString fileName = dir.path() + "/staleLockFromBusyProcess"; @@ -331,12 +331,12 @@ void tst_QLockFile::staleShortLockFromBusyProcess() proc.waitForFinished(); QVERIFY(secondLock.tryLock()); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::staleLongLockFromBusyProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else const QString fileName = dir.path() + "/staleLockFromBusyProcess"; @@ -358,7 +358,7 @@ void tst_QLockFile::staleLongLockFromBusyProcess() QVERIFY(!secondLock.removeStaleLockFile()); proc.waitForFinished(); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } static QString tryStaleLockFromThread(const QString &fileName) @@ -388,7 +388,7 @@ static QString tryStaleLockFromThread(const QString &fileName) void tst_QLockFile::staleLockRace() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else // Multiple threads notice a stale lock at the same time @@ -406,7 +406,7 @@ void tst_QLockFile::staleLockRace() synchronizer.waitForFinished(); foreach (const QFuture &future, synchronizer.futures()) QVERIFY2(future.result().isEmpty(), qPrintable(future.result())); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLockFile::noPermissions() diff --git a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp index d76156219e..b7367ff8c6 100644 --- a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp +++ b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp @@ -38,7 +38,6 @@ int main(int argc, char **argv) if (argc < 3) return 13; -#ifndef QT_NO_PROCESS QProcess process; QProcess::ProcessChannelMode mode = (QProcess::ProcessChannelMode)atoi(argv[1]); @@ -69,6 +68,5 @@ int main(int argc, char **argv) if ((mode == QProcess::ForwardedErrorChannel || mode == QProcess::ForwardedChannels) && !process.readAllStandardError().isEmpty()) return 6; -#endif return 0; } diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 3f3533c9a1..82efbdcb2c 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -53,7 +53,6 @@ public slots: void cleanupTestCase(); void init(); -#ifndef QT_NO_PROCESS private slots: void getSetCheck(); void constructing(); @@ -159,26 +158,18 @@ protected slots: private: qint64 bytesAvailable; QTemporaryDir m_temporaryDir; -#endif //QT_NO_PROCESS }; void tst_QProcess::initTestCase() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#else QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString())); // chdir to our testdata path and execute helper apps relative to that. QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessNormal")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); -#endif } void tst_QProcess::cleanupTestCase() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#endif } void tst_QProcess::init() @@ -186,8 +177,6 @@ void tst_QProcess::init() bytesAvailable = 0; } -#ifndef QT_NO_PROCESS - // Testing get/set functions void tst_QProcess::getSetCheck() { @@ -2406,7 +2395,5 @@ void tst_QProcess::processEventsInAReadyReadSlot() QVERIFY(process.waitForFinished()); } -#endif //QT_NO_PROCESS - QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 7f29e2a7d7..0e423a56ca 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -40,8 +40,9 @@ #include #include #include -#include - +#if QT_CONFIG(process) +# include +#endif #include "../../../network-settings.h" @@ -1493,7 +1494,7 @@ void tst_QTextStream::pos3LargeFile() // ------------------------------------------------------------------------------ void tst_QTextStream::readStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess stdinProcess; @@ -1520,7 +1521,7 @@ void tst_QTextStream::readStdin() // ------------------------------------------------------------------------------ void tst_QTextStream::readAllFromStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess stdinProcess; @@ -1541,7 +1542,7 @@ void tst_QTextStream::readAllFromStdin() // ------------------------------------------------------------------------------ void tst_QTextStream::readLineFromStdin() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess stdinProcess; diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 7b75438b19..50f0061905 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -41,8 +41,9 @@ #include #include #include -#include - +#if QT_CONFIG(process) +# include +#endif #include "qobject.h" #ifdef QT_BUILD_INTERNAL #include @@ -281,7 +282,7 @@ static void playWithObjects() void tst_QObject::initTestCase() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString testDataDir = QFileInfo(QFINDTESTDATA("signalbug")).absolutePath(); QVERIFY2(QDir::setCurrent(testDataDir), qPrintable("Could not chdir to " + testDataDir)); #endif @@ -3006,7 +3007,7 @@ void tst_QObject::dynamicProperties() void tst_QObject::recursiveSignalEmission() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess proc; diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp index 26caff4301..8833321b4f 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp @@ -28,7 +28,9 @@ #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include #include #include @@ -133,7 +135,7 @@ tst_QSharedMemory::~tst_QSharedMemory() void tst_QSharedMemory::initTestCase() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QVERIFY2(!m_helperBinary.isEmpty(), "Could not find helper binary"); #endif } @@ -455,7 +457,7 @@ void tst_QSharedMemory::emptyMemory() #if !defined(Q_OS_WIN) void tst_QSharedMemory::readOnly() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else rememberKey("readonly_segfault"); @@ -736,7 +738,7 @@ void tst_QSharedMemory::simpleThreadedProducerConsumer() void tst_QSharedMemory::simpleProcessProducerConsumer_data() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QTest::addColumn("processes"); int tries = 5; for (int i = 0; i < tries; ++i) { @@ -751,7 +753,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer_data() */ void tst_QSharedMemory::simpleProcessProducerConsumer() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QFETCH(int, processes); diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp index 641ea5fc9d..6ff1e14976 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp +++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp @@ -172,7 +172,7 @@ void tst_QSystemSemaphore::release() void tst_QSystemSemaphore::basicProcesses() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QSystemSemaphore sem("store", 0, QSystemSemaphore::Create); @@ -208,7 +208,7 @@ void tst_QSystemSemaphore::processes_data() void tst_QSystemSemaphore::processes() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); @@ -237,7 +237,7 @@ void tst_QSystemSemaphore::processes() #if !defined(Q_OS_WIN) && !defined(QT_POSIX_IPC) void tst_QSystemSemaphore::undo() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); @@ -262,7 +262,7 @@ void tst_QSystemSemaphore::undo() void tst_QSystemSemaphore::initialValue() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp index 1ca730d0c7..529c8942b3 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp @@ -36,7 +36,7 @@ void tst_QMimeDatabase::initTestCaseInternal() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else const QString mimeDirName = m_globalXdgDir + QStringLiteral("/mime"); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 2edb94d542..02ba987ccd 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -858,7 +858,7 @@ void tst_QMimeDatabase::fromThreads() QVERIFY(tp.waitForDone(60000)); } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) enum { UpdateMimeDatabaseTimeout = 120 * 1000 // 2min @@ -901,7 +901,7 @@ static bool waitAndRunUpdateMimeDatabase(const QString &path) } return runUpdateMimeDatabase(path); } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) static void checkHasMimeType(const QString &mimeType) { @@ -936,7 +936,7 @@ void tst_QMimeDatabase::installNewGlobalMimeType() QSKIP("This test requires XDG_DATA_DIRS"); #endif -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else qmime_secondsBetweenChecks = 0; @@ -989,12 +989,12 @@ void tst_QMimeDatabase::installNewGlobalMimeType() QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("application/octet-stream")); QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QMimeDatabase::installNewLocalMimeType() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else qmime_secondsBetweenChecks = 0; @@ -1057,7 +1057,7 @@ void tst_QMimeDatabase::installNewLocalMimeType() QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("application/octet-stream")); QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); -#endif +#endif // QT_CONFIG(process) } QTEST_GUILESS_MAIN(tst_QMimeDatabase) diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index e2c137e25f..cb45336d4c 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -91,7 +91,7 @@ void tst_QUuid::initTestCase() //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; uuidB = QUuid(0x1ab6e93a, 0xb1cb, 0x4a87, 0xba, 0x47, 0xec, 0x7e, 0x99, 0x03, 0x9a, 0x7b); -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) // chdir to the directory containing our testdata, then refer to it with relative paths QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessUniqueness")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); @@ -338,7 +338,7 @@ void tst_QUuid::threadUniqueness() void tst_QUuid::processUniqueness() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess process; diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index 49a3b3e4db..403e28b07b 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -76,7 +76,7 @@ int Pointer::count = 0; void tst_QThreadStorage::initTestCase() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString crashOnExitDir = QFINDTESTDATA("crashonexit"); QVERIFY2(!crashOnExitDir.isEmpty(), qPrintable(QString::fromLatin1("Could not find 'crashonexit' starting from '%1'") @@ -300,7 +300,7 @@ void tst_QThreadStorage::ensureCleanupOrder() QVERIFY(First::order < Second::order); } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) static inline bool runCrashOnExit(const QString &binary, QString *errorMessage) { const int timeout = 60000; @@ -325,7 +325,7 @@ static inline bool runCrashOnExit(const QString &binary, QString *errorMessage) void tst_QThreadStorage::crashOnExit() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QString errorMessage; diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index a54ad3d9c9..10398f1a99 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -509,7 +509,7 @@ void tst_QCommandLineParser::testCpp11StyleInitialization() void tst_QCommandLineParser::testVersionOption() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else #if defined(Q_OS_ANDROID) @@ -526,7 +526,7 @@ void tst_QCommandLineParser::testVersionOption() output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif QCOMPARE(output, QString("qcommandlineparser_test_helper 1.0\n")); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } static const char expectedOptionsHelp[] = @@ -575,7 +575,7 @@ void tst_QCommandLineParser::testHelpOption_data() void tst_QCommandLineParser::testHelpOption() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else #if defined(Q_OS_ANDROID) @@ -618,12 +618,12 @@ void tst_QCommandLineParser::testHelpOption() expectedResizeHelp.replace("testhelper/", "testhelper\\"); #endif QCOMPARE(output, QString(expectedResizeHelp)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QCommandLineParser::testQuoteEscaping() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #elif defined(Q_OS_ANDROID) QSKIP("Deploying executable applications to file system on Android not supported."); @@ -644,7 +644,7 @@ void tst_QCommandLineParser::testQuoteEscaping() QVERIFY2(output.contains("KEY1=\"VALUE1\""), qPrintable(output)); QVERIFY2(output.contains("QTBUG-15379=C:\\path\\'file.ext"), qPrintable(output)); QVERIFY2(output.contains("QTBUG-30628=C:\\temp\\'file'.ext"), qPrintable(output)); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } QTEST_APPLESS_MAIN(tst_QCommandLineParser) diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 42bfb3603d..06b0fe8d51 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -35,7 +35,9 @@ #include #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include #include @@ -152,7 +154,7 @@ tst_QLocale::tst_QLocale() void tst_QLocale::initTestCase() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString syslocaleapp_dir = QFINDTESTDATA("syslocaleapp"); QVERIFY2(!syslocaleapp_dir.isEmpty(), qPrintable(QStringLiteral("Cannot find 'syslocaleapp' starting from ") @@ -165,7 +167,7 @@ void tst_QLocale::initTestCase() QVERIFY2(fi.exists() && fi.isExecutable(), qPrintable(QDir::toNativeSeparators(m_sysapp) + QStringLiteral(" does not exist or is not executable."))); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QLocale::cleanupTestCase() @@ -420,7 +422,7 @@ void tst_QLocale::ctor() #undef TEST_CTOR } -#if !defined(QT_NO_PROCESS) +#if QT_CONFIG(process) static inline bool runSysApp(const QString &binary, const QStringList &env, QString *output, @@ -472,7 +474,7 @@ static inline bool runSysAppTest(const QString &binary, void tst_QLocale::emptyCtor() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else #define TEST_CTOR(req_lc, exp_str) \ diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp index 7bebe5e9e0..e8f56fc1d3 100644 --- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp @@ -31,7 +31,9 @@ #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include #include #include @@ -66,7 +68,7 @@ static QString makespec() QT_BEGIN_NAMESPACE namespace QTest { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) class QExternalProcess: public QProcess { protected: @@ -87,7 +89,7 @@ namespace QTest { } #endif }; -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) class QExternalTestPrivate { @@ -554,7 +556,7 @@ namespace QTest { bool QExternalTestPrivate::runQmake() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) if (temporaryDirPath.isEmpty()) qWarning() << "Temporary directory is expected to be non-empty"; @@ -597,14 +599,14 @@ namespace QTest { } return ok && exitCode == 0; -#else // QT_NO_PROCESS +#else // QT_CONFIG(process) return false; -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } bool QExternalTestPrivate::runMake(Target target) { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) return false; #else if (temporaryDirPath.isEmpty()) @@ -663,7 +665,7 @@ namespace QTest { std_err += make.readAllStandardError(); return ok; -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } bool QExternalTestPrivate::commonSetup(const QByteArray &body) diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index 95daa256b5..d521c18cef 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1410,7 +1410,7 @@ void tst_QDBusConnection::callVirtualObjectLocal() void tst_QDBusConnection::pendingCallWhenDisconnected() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("Test requires QProcess"); #else if (!QCoreApplication::instance()) diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index 4218d0751f..d628fad705 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -709,7 +709,7 @@ void tst_QIcon::fromThemeCache() QIcon::setThemeSearchPaths(QStringList()); QSKIP("gtk-update-icon-cache not run (binary not found)"); } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QProcess process; process.start(gtkUpdateIconCache, QStringList() << QStringLiteral("-f") << QStringLiteral("-t") << (dir.path() + QLatin1String("/testcache"))); @@ -719,7 +719,7 @@ void tst_QIcon::fromThemeCache() QVERIFY(process.waitForFinished()); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) QVERIFY(QFileInfo(cacheName).lastModified() >= QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified()); QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes QVERIFY(!QIcon::fromTheme("button-open").isNull()); diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index b1ec94403a..87fd5c0dc6 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -73,7 +73,7 @@ void tst_QClipboard::cleanupTestCase() void tst_QClipboard::init() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QString testdataDir = QFileInfo(QFINDTESTDATA("copier")).absolutePath(); QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir)); #endif @@ -218,7 +218,7 @@ void tst_QClipboard::testSignals() #if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX) static bool runHelper(const QString &program, const QStringList &arguments, QByteArray *errorMessage) { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QProcess process; process.setReadChannelMode(QProcess::ForwardedChannels); process.start(program, arguments); @@ -254,19 +254,19 @@ static bool runHelper(const QString &program, const QStringList &arguments, QByt return false; } return true; -#else // QT_NO_PROCESS +#else // QT_CONFIG(process) Q_UNUSED(program) Q_UNUSED(arguments) Q_UNUSED(errorMessage) return false; -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } // Test that pasted text remains on the clipboard after a Qt application exits. // This test does not make sense on X11 and embedded, copied data disappears from the clipboard when the application exits void tst_QClipboard::copy_exit_paste() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) // ### It's still possible to test copy/paste - just keep the apps running if (!PlatformClipboard::isAvailable()) QSKIP("Native clipboard not working in this setup"); @@ -282,12 +282,12 @@ void tst_QClipboard::copy_exit_paste() QStringList() << QStringLiteral("--text") << stringArgument, &errorMessage), errorMessage.constData()); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QClipboard::copyImage() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) if (!PlatformClipboard::isAvailable()) QSKIP("Native clipboard not working in this setup"); QImage image(100, 100, QImage::Format_ARGB32); @@ -303,7 +303,7 @@ void tst_QClipboard::copyImage() QVERIFY2(runHelper(QStringLiteral("paster/paster"), QStringList(QStringLiteral("--image")), &errorMessage), errorMessage.constData()); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } #endif // Q_OS_WIN || Q_OS_MAC || Q_OS_QNX diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 2603206ab0..1f826c01cf 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -486,7 +486,7 @@ void tst_QFont::styleName() QString getPlatformGenericFont(const char* genericName) { -#if defined(Q_OS_UNIX) && !defined(QT_NO_FONTCONFIG) +#if defined(Q_OS_UNIX) && !defined(QT_NO_FONTCONFIG) && QT_CONFIG(process) QProcess p; p.start(QLatin1String("fc-match"), (QStringList() << "-f%{family}" << genericName)); if (!p.waitForStarted()) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 649278d48b..a7f6a9058a 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -4285,14 +4285,14 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket() // Currently no stdin/out supported for Windows CE. void tst_QNetworkReply::ioPutToFileFromProcess_data() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) putToFile_data(); #endif } void tst_QNetworkReply::ioPutToFileFromProcess() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else @@ -4330,7 +4330,7 @@ void tst_QNetworkReply::ioPutToFileFromProcess() QByteArray contents = file.readAll(); QCOMPARE(contents, data); -#endif // QT_NO_PROCESS +#endif // QT_CONFIG(process) } void tst_QNetworkReply::ioPutToFtpFromFile_data() diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp index 138a0859cd..8d32ddf37c 100644 --- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp @@ -897,7 +897,7 @@ QDebug operator<<(QDebug debug, const QList &list) // at Discovered -state. void tst_QNetworkSession::outOfProcessSession() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else updateConfigurations(); diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 74bffef4f4..a74a056d91 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -904,7 +904,7 @@ void tst_QLocalSocket::processConnection_data() QTest::newRow("30 clients") << 30; } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) class ProcessOutputDumper { public: @@ -933,7 +933,7 @@ private: */ void tst_QLocalSocket::processConnection() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else #ifdef Q_OS_MAC diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 4bbd0662e4..3b9ef577bd 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -49,7 +49,9 @@ #include #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include #include #include @@ -544,7 +546,7 @@ protected: void tst_QTcpServer::addressReusable() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else #ifdef Q_OS_LINUX diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 9fd5620cec..7340817ade 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -54,7 +54,9 @@ #include #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include #include #include @@ -2403,7 +2405,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect_data() void tst_QTcpSocket::suddenRemoteDisconnect() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QFETCH(QString, client); @@ -2459,7 +2461,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect() #endif QCOMPARE(clientProcess.readAll().constData(), "SUCCESS\n"); QCOMPARE(serverProcess.readAll().constData(), "SUCCESS\n"); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } //---------------------------------------------------------------------------------- diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index aa01384350..1133a80820 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -956,7 +956,7 @@ void tst_QUdpSocket::writeToNonExistingPeer() void tst_QUdpSocket::outOfProcessConnectedClientServerTest() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess serverProcess; @@ -1017,7 +1017,7 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else QProcess serverProcess; diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 68473906b0..3b696604b5 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -961,7 +961,7 @@ void tst_NetworkSelfTest::supportsSsl() #endif } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) static const QByteArray msgProcessError(const QProcess &process, const char *what) { QString result; @@ -978,7 +978,7 @@ static void ensureTermination(QProcess &process) process.kill(); } } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) void tst_NetworkSelfTest::smbServer() { @@ -996,7 +996,7 @@ void tst_NetworkSelfTest::smbServer() QCOMPARE(ret, strlen(contents)); QVERIFY(memcmp(buf, contents, strlen(contents)) == 0); #else -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) enum { sambaTimeOutSecs = 5 }; // try to use Samba const QString progname = "smbclient"; diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 0babac4b6f..ab42a814eb 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -57,6 +57,8 @@ cross_compile: SUBDIRS -= \ !qtConfig(accessibility-atspi-bridge): SUBDIRS -= qaccessibilitylinux +!qtConfig(process): SUBDIRS -= qprocess_and_guieventloop + !mac: SUBDIRS -= \ macgui \ macnativeevents \ @@ -66,8 +68,5 @@ cross_compile: SUBDIRS -= \ !embedded: SUBDIRS -= \ qdirectpainter -winrt: SUBDIRS -= \ - qprocess_and_guieventloop - android: SUBDIRS += \ android diff --git a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp index 1fcb77c51b..5842d58fab 100644 --- a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp +++ b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp @@ -40,9 +40,7 @@ private slots: void tst_QProcess_and_GuiEventLoop::waitForAndEventLoop() { -#if defined(QT_NO_PROCESS) - QSKIP("QProcess not supported"); -#elif defined(Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) QSKIP("Not supported on Android"); #else diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 35b759bcc2..0c078127b4 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -536,7 +536,7 @@ void tst_Selftests::runSubTest_data() } } -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) static QProcessEnvironment processEnvironment() { @@ -820,11 +820,11 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge } } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) void tst_Selftests::runSubTest() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QFETCH(QString, subdir); @@ -833,7 +833,7 @@ void tst_Selftests::runSubTest() QFETCH(bool, crashes); doRunSubTest(subdir, loggers, arguments, crashes); -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } // attribute must contain =" diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index ecf6c7e992..e746800c9f 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -743,7 +743,7 @@ void tst_Moc::initTestCase() const QString testHeader = QFINDTESTDATA("backslash-newlines.h"); QVERIFY(!testHeader.isEmpty()); m_sourceDirectory = QFileInfo(testHeader).absolutePath(); -#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_UNIX) && QT_CONFIG(process) QProcess proc; proc.start(qmake, QStringList() << "-query" << "QT_INSTALL_HEADERS"); QVERIFY(proc.waitForFinished()); @@ -787,7 +787,7 @@ void tst_Moc::oldStyleCasts() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.start(m_moc, QStringList(m_sourceDirectory + QStringLiteral("/oldstyle-casts.h"))); QVERIFY(proc.waitForFinished()); @@ -817,7 +817,7 @@ void tst_Moc::warnOnExtraSignalSlotQualifiaction() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; const QString header = m_sourceDirectory + QStringLiteral("/extraqualification.h"); proc.start(m_moc, QStringList(header)); @@ -856,7 +856,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.setWorkingDirectory(m_sourceDirectory + QStringLiteral("/task71021")); proc.start(m_moc, QStringList("../Header")); @@ -1102,7 +1102,7 @@ void tst_Moc::warnOnMultipleInheritance() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; const QString header = m_sourceDirectory + QStringLiteral("/warn-on-multiple-qobject-subclasses.h"); @@ -1125,7 +1125,7 @@ void tst_Moc::ignoreOptionClashes() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; const QString header = m_sourceDirectory + QStringLiteral("/interface-from-include.h"); @@ -1166,7 +1166,7 @@ void tst_Moc::forgottenQInterface() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; const QString header = m_sourceDirectory + QStringLiteral("/forgotten-qinterface.h"); @@ -1248,7 +1248,7 @@ void tst_Moc::frameworkSearchPath() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_UNIX) && QT_CONFIG(process) QStringList args; args << "-F" << m_sourceDirectory + QStringLiteral("/.") << m_sourceDirectory + QStringLiteral("/interface-from-framework.h") @@ -1292,7 +1292,7 @@ void tst_Moc::templateGtGt() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.start(m_moc, QStringList(m_sourceDirectory + QStringLiteral("/template-gtgt.h"))); QVERIFY(proc.waitForFinished()); @@ -1308,7 +1308,7 @@ void tst_Moc::templateGtGt() void tst_Moc::defineMacroViaCmdline() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; @@ -1328,7 +1328,7 @@ void tst_Moc::defineMacroViaCmdline() void tst_Moc::defineMacroViaForcedInclude() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; @@ -1348,7 +1348,7 @@ void tst_Moc::defineMacroViaForcedInclude() void tst_Moc::defineMacroViaForcedIncludeRelative() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; QStringList args; @@ -1369,7 +1369,7 @@ void tst_Moc::defineMacroViaForcedIncludeRelative() void tst_Moc::environmentIncludePaths_data() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QTest::addColumn("cmdline"); QTest::addColumn("varname"); @@ -1383,7 +1383,7 @@ void tst_Moc::environmentIncludePaths_data() void tst_Moc::environmentIncludePaths() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QFETCH(QString, cmdline); QFETCH(QString, varname); @@ -1576,7 +1576,7 @@ void tst_Moc::warnOnPropertyWithoutREAD() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; const QString header = m_sourceDirectory + QStringLiteral("/warn-on-property-without-read.h"); proc.start(m_moc, QStringList(header)); @@ -1687,7 +1687,7 @@ void tst_Moc::warnOnVirtualSignal() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; const QString header = m_sourceDirectory + QStringLiteral("/pure-virtual-signals.h"); proc.start(m_moc, QStringList(header)); @@ -1819,7 +1819,7 @@ void tst_Moc::notifyError() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; const QString header = m_sourceDirectory + QStringLiteral("/error-on-wrong-notify.h"); proc.start(m_moc, QStringList(header)); @@ -2165,6 +2165,7 @@ void tst_Moc::warnings() expectedStdErr.replace(lineNumberRe, "(\\1):"); #endif +#if QT_CONFIG(process) QProcess proc; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); @@ -2187,6 +2188,9 @@ void tst_Moc::warnings() if (expectedStdOut != "IGNORE_ALL_STDOUT") QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardOutput()).trimmed(), expectedStdOut); QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()).trimmed().remove('\r'), expectedStdErr); +#else + QSKIP("Only tested if QProcess is available"); +#endif } class tst_Moc::PrivateClass : public QObject { @@ -3407,7 +3411,7 @@ void tst_Moc::preprocessorOnly() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.start(m_moc, QStringList() << "-E" << m_sourceDirectory + QStringLiteral("/pp-dollar-signs.h")); QVERIFY(proc.waitForFinished()); @@ -3428,7 +3432,7 @@ void tst_Moc::unterminatedFunctionMacro() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && QT_CONFIG(process) QProcess proc; proc.start(m_moc, QStringList() << "-E" << m_sourceDirectory + QStringLiteral("/unterminated-function-macro.h")); QVERIFY(proc.waitForFinished()); @@ -3731,7 +3735,7 @@ void tst_Moc::optionsFileError() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled"); #endif -#if !defined(QT_NO_PROCESS) +#if QT_CONFIG(process) QFETCH(QString, optionsArgument); QProcess p; p.start(m_moc, QStringList(optionsArgument)); diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index d6f3728663..13994e3b02 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -35,7 +35,9 @@ #include #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include #include @@ -1432,7 +1434,7 @@ void tst_QApplication::testDeleteLaterProcessEvents() */ void tst_QApplication::desktopSettingsAware() { -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QString path; { // We need an application object for QFINDTESTDATA to work @@ -2121,7 +2123,7 @@ void tst_QApplication::qtbug_12673() QVERIFY2(!path.isEmpty(), "Cannot locate modal helper application"); path += "modal"; -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QProcess testProcess; QStringList arguments; testProcess.start(path, arguments); @@ -2254,7 +2256,7 @@ void tst_QApplication::settableStyleHints() executed *after* the destruction of QApplication. */ Q_GLOBAL_STATIC(QLocale, tst_qapp_locale); -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) Q_GLOBAL_STATIC(QProcess, tst_qapp_process); #endif #ifndef QT_NO_FILESYSTEMWATCHER @@ -2279,7 +2281,7 @@ void tst_QApplication::globalStaticObjectDestruction() int argc = 1; QApplication app(argc, &argv0); QVERIFY(tst_qapp_locale()); -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QVERIFY(tst_qapp_process()); #endif #ifndef QT_NO_FILESYSTEMWATCHER diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp index f5cf9d7750..2c3eb66384 100644 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp @@ -606,7 +606,7 @@ void tst_QUndoGroup::addStackAndDie() void tst_QUndoGroup::commandTextFormat() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No QProcess available"); #else QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp index a3e7219892..ba3d80bbe4 100644 --- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp +++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp @@ -3088,7 +3088,7 @@ void tst_QUndoStack::undoLimit() void tst_QUndoStack::commandTextFormat() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("No QProcess available"); #else QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp index 3335ff8ffc..35ef255255 100644 --- a/tests/baselineserver/shared/baselineprotocol.cpp +++ b/tests/baselineserver/shared/baselineprotocol.cpp @@ -31,7 +31,9 @@ #include #include #include -#include +#if QT_CONFIG(process) +# include +#endif #include #include #include @@ -88,7 +90,7 @@ PlatformInfo PlatformInfo::localHostInfo() #if QT_VERSION >= 0x050000 pi.insert(PI_QtBuildMode, QLibraryInfo::isDebugBuild() ? QLS("QtDebug") : QLS("QtRelease")); #endif -#if defined(Q_OS_LINUX) +#if defined(Q_OS_LINUX) && QT_CONFIG(process) pi.insert(PI_OSName, QLS("Linux")); QProcess uname; uname.start(QLS("uname"), QStringList() << QLS("-r")); @@ -104,7 +106,7 @@ PlatformInfo PlatformInfo::localHostInfo() pi.insert(PI_OSName, QLS("Other")); #endif -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QProcess git; QString cmd; QStringList args; @@ -140,7 +142,7 @@ PlatformInfo PlatformInfo::localHostInfo() pi.insert(PI_PulseGitBranch, QString::fromLatin1(gb)); } } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) return pi; } diff --git a/tests/baselineserver/shared/qbaselinetest.cpp b/tests/baselineserver/shared/qbaselinetest.cpp index 7e913c1233..ef38e21edb 100644 --- a/tests/baselineserver/shared/qbaselinetest.cpp +++ b/tests/baselineserver/shared/qbaselinetest.cpp @@ -28,7 +28,9 @@ #include "qbaselinetest.h" #include "baselineprotocol.h" -#include +#if QT_CONFIG(process) +# include +#endif #include #define MAXCMDLINEARGS 128 @@ -126,7 +128,7 @@ void addClientProperty(const QString& key, const QString& value) */ void fetchCustomClientProperties() { -#ifdef QT_NO_PROCESS +#if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else QString script = "hostinfo.sh"; //### TBD: Windows implementation (hostinfo.bat) @@ -151,7 +153,7 @@ void fetchCustomClientProperties() else qDebug() << "Unparseable script output ignored:" << line; } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) } diff --git a/tests/benchmarks/corelib/io/io.pro b/tests/benchmarks/corelib/io/io.pro index 38a1f6b15b..23f9c190aa 100644 --- a/tests/benchmarks/corelib/io/io.pro +++ b/tests/benchmarks/corelib/io/io.pro @@ -5,7 +5,7 @@ SUBDIRS = \ qfile \ qfileinfo \ qiodevice \ - qprocess \ qtemporaryfile \ qtextstream +qtConfig(process): SUBDIRS += qprocess diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp index 782cad94a1..5bd4bc5520 100644 --- a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp +++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp @@ -33,15 +33,11 @@ class tst_QProcess : public QObject { Q_OBJECT -#if !defined(QT_NO_PROCESS) private slots: void echoTest_performance(); - -#endif // QT_NO_PROCESS }; -#if !defined(QT_NO_PROCESS) void tst_QProcess::echoTest_performance() { QProcess process; @@ -87,7 +83,5 @@ void tst_QProcess::echoTest_performance() QVERIFY(process.waitForFinished()); } -#endif // QT_NO_PROCESS - QTEST_MAIN(tst_QProcess) #include "tst_bench_qprocess.moc" -- cgit v1.2.3 From 740b5c1fea56d1ec7b227b25e58a64355a8963f9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 24 Feb 2017 11:27:21 +0100 Subject: Fix UB in QWidgetResizeHandler::eventFilter Unconditional cast to a QMouseEvent while the event might also be a QKeyEvent. Change-Id: If5eb6fbad6e4440c167ff95298f51efde1834217 Reviewed-by: Marc Mutz --- src/widgets/widgets/qwidgetresizehandler.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index 016598849b..dc7353a6ca 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -112,9 +112,9 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) return false; } - QMouseEvent *e = (QMouseEvent*)ee; - switch (e->type()) { + switch (ee->type()) { case QEvent::MouseButtonPress: { + QMouseEvent *e = static_cast(ee); if (w->isMaximized()) break; if (!widget->rect().contains(widget->mapFromGlobal(e->globalPos()))) @@ -155,7 +155,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) case QEvent::MouseButtonRelease: if (w->isMaximized()) break; - if (e->button() == Qt::LeftButton) { + if (static_cast(ee)->button() == Qt::LeftButton) { moveResizeMode = false; buttonDown = false; widget->releaseMouse(); @@ -171,6 +171,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) case QEvent::MouseMove: { if (w->isMaximized()) break; + QMouseEvent *e = static_cast(ee); buttonDown = buttonDown && (e->buttons() & Qt::LeftButton); // safety, state machine broken! bool me = movingEnabled; movingEnabled = (me && o == widget && (buttonDown || moveResizeMode)); @@ -184,11 +185,11 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) } } break; case QEvent::KeyPress: - keyPressEvent((QKeyEvent*)e); + keyPressEvent(static_cast(ee)); break; case QEvent::ShortcutOverride: if (buttonDown) { - ((QKeyEvent*)ee)->accept(); + ee->accept(); return true; } break; -- cgit v1.2.3 From e7f019011ace53d83d439c7c596fb063e02f5d79 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Mon, 27 Feb 2017 12:59:27 +0200 Subject: Fix wrong codec with MySQL plugin in newer versions Since MySQL now properly supports UTF-8 through utf8mb4 option, it caused regression on systems which did not use UTF-8 encoding by default which caused queries to fail as they were converted into system codec. To fix this, simply use UTF-8 encoding for queries when MySQL supports it. Task-number: QTBUG-59176 Change-Id: I21cc9102b15df15a31bc7c74469321c44a257946 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 7cfa554418..ee439fa33e 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -1421,13 +1421,17 @@ bool QMYSQLDriver::open(const QString& db, if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) { // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters) mysql_set_character_set(d->mysql, "utf8mb4"); - } else { +#ifndef QT_NO_TEXTCODEC + d->tc = QTextCodec::codecForName("UTF-8"); +#endif + } else + { // force the communication to be utf8 mysql_set_character_set(d->mysql, "utf8"); - } -#endif #ifndef QT_NO_TEXTCODEC - d->tc = codec(d->mysql); + d->tc = codec(d->mysql); +#endif + } #endif #if MYSQL_VERSION_ID >= 40108 -- cgit v1.2.3 From 4a31eca4ce4351fc6e9c275c519306d36f25d152 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 17 Feb 2017 17:17:45 +0100 Subject: Make it possible to specify the RCC data version format After commit d20773824529d191e7b483b505107dce6c1b1c3d we unconditionally write version two, but it seems useful to allow users to specify the version explicitly. Change-Id: I81d3de3d7f87318653f89bf10e3618becd8329d6 Task-number: QTBUG-58769 Reviewed-by: hjk --- src/tools/rcc/main.cpp | 17 +++++++++++++- src/tools/rcc/rcc.cpp | 29 +++++++++++++++--------- src/tools/rcc/rcc.h | 5 +++- tests/auto/tools/rcc/data/images/images.expected | 4 ++-- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 423b566896..d09d36c659 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -153,6 +153,9 @@ int runRcc(int argc, char *argv[]) QCommandLineOption projectOption(QStringLiteral("project"), QStringLiteral("Output a resource file containing all files from the current directory.")); parser.addOption(projectOption); + QCommandLineOption formatVersionOption(QStringLiteral("format-version"), QStringLiteral("The RCC format version to write"), QStringLiteral("number")); + parser.addOption(formatVersionOption); + parser.addPositionalArgument(QStringLiteral("inputs"), QStringLiteral("Input files (*.qrc).")); @@ -160,7 +163,19 @@ int runRcc(int argc, char *argv[]) parser.process(app); QString errorMsg; - RCCResourceLibrary library; + + quint8 formatVersion = 2; + if (parser.isSet(formatVersionOption)) { + bool ok = false; + formatVersion = parser.value(formatVersionOption).toUInt(&ok); + if (!ok) { + errorMsg = QLatin1String("Invalid format version specified"); + } else if (formatVersion != 1 && formatVersion != 2) { + errorMsg = QLatin1String("Unsupported format version specified"); + } + } + + RCCResourceLibrary library(formatVersion); if (parser.isSet(nameOption)) library.setInitName(parser.value(nameOption)); if (parser.isSet(rootOption)) { diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index c8ac554cd4..26dacc48ec 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -204,11 +204,13 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) if (text || pass1) lib.writeChar('\n'); - // last modified time stamp - const QDateTime lastModified = m_fileInfo.lastModified(); - lib.writeNumber8(quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0)); - if (text || pass1) - lib.writeChar('\n'); + if (lib.formatVersion() >= 2) { + // last modified time stamp + const QDateTime lastModified = m_fileInfo.lastModified(); + lib.writeNumber8(quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0)); + if (text || pass1) + lib.writeChar('\n'); + } } qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset, @@ -341,7 +343,7 @@ RCCResourceLibrary::Strings::Strings() : { } -RCCResourceLibrary::RCCResourceLibrary() +RCCResourceLibrary::RCCResourceLibrary(quint8 formatVersion) : m_root(0), m_format(C_Code), m_verbose(false), @@ -352,7 +354,8 @@ RCCResourceLibrary::RCCResourceLibrary() m_dataOffset(0), m_useNameSpace(CONSTANT_USENAMESPACE), m_errorDevice(0), - m_outDevice(0) + m_outDevice(0), + m_formatVersion(formatVersion) { m_out.reserve(30 * 1000 * 1000); } @@ -1114,7 +1117,9 @@ bool RCCResourceLibrary::writeInitializer() if (m_root) { writeString(" "); writeAddNamespaceFunction("qRegisterResourceData"); - writeString("\n (0x02, qt_resource_struct, " + writeString("\n ("); + writeHex(m_formatVersion); + writeString(" qt_resource_struct, " "qt_resource_name, qt_resource_data);\n"); } writeString(" return 1;\n"); @@ -1135,7 +1140,9 @@ bool RCCResourceLibrary::writeInitializer() if (m_root) { writeString(" "); writeAddNamespaceFunction("qUnregisterResourceData"); - writeString("\n (0x02, qt_resource_struct, " + writeString("\n ("); + writeHex(m_formatVersion); + writeString(" qt_resource_struct, " "qt_resource_name, qt_resource_data);\n"); } writeString(" return 1;\n"); @@ -1152,10 +1159,10 @@ bool RCCResourceLibrary::writeInitializer() } else if (m_format == Binary) { int i = 4; char *p = m_out.data(); - p[i++] = 0; // 0x02 p[i++] = 0; p[i++] = 0; - p[i++] = 2; + p[i++] = 0; + p[i++] = m_formatVersion; p[i++] = (m_treeOffset >> 24) & 0xff; p[i++] = (m_treeOffset >> 16) & 0xff; diff --git a/src/tools/rcc/rcc.h b/src/tools/rcc/rcc.h index 157cd4809f..19e04e401d 100644 --- a/src/tools/rcc/rcc.h +++ b/src/tools/rcc/rcc.h @@ -48,7 +48,7 @@ class RCCResourceLibrary RCCResourceLibrary &operator=(const RCCResourceLibrary &); public: - RCCResourceLibrary(); + RCCResourceLibrary(quint8 formatVersion); ~RCCResourceLibrary(); bool output(QIODevice &outDevice, QIODevice &tempDevice, QIODevice &errorDevice); @@ -91,6 +91,8 @@ public: QStringList failedResources() const { return m_failedResources; } + int formatVersion() const { return m_formatVersion; } + private: struct Strings { Strings(); @@ -141,6 +143,7 @@ private: QIODevice *m_errorDevice; QIODevice *m_outDevice; QByteArray m_out; + quint8 m_formatVersion; }; QT_END_NAMESPACE diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected index eb5d9222c8..45e96dccd0 100644 --- a/tests/auto/tools/rcc/data/images/images.expected +++ b/tests/auto/tools/rcc/data/images/images.expected @@ -126,7 +126,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources)(); int QT_RCC_MANGLE_NAMESPACE(qInitResources)() { QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData) - (0x02, qt_resource_struct, qt_resource_name, qt_resource_data); + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } @@ -134,7 +134,7 @@ int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)() { QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData) - (0x02, qt_resource_struct, qt_resource_name, qt_resource_data); + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } -- cgit v1.2.3 From 657bea873b9bf66764848d612b4188039ec7e583 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 25 Jan 2017 15:20:26 +0100 Subject: Doc: added info about return type for function QMutex::try_lock() qmutex.cpp:266: warning: Undocumented return value Change-Id: Ib93a5a2505f663f266871dbe5582fb5856096889 Reviewed-by: Venugopal Shivashankar --- src/corelib/thread/qmutex.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index b9b16e066f..29095f8b51 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -266,6 +266,9 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT /*! \fn bool QMutex::try_lock() \since 5.8 + This function returns \c true if the lock was obtained; otherwise it + returns \c false. + This function is provided for compatibility with the Standard Library concept \c Lockable. It is equivalent to tryLock(). -- cgit v1.2.3 From 17d780ad457fb9cbfc92bf6114bfcf4cc4ac5a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 28 Feb 2017 08:54:56 +0100 Subject: QTimer: Avoid implicit conversion warnings This fixes compiling an application using QTimer and -Wshorten-64-to-32 on a 64-bit system without getting this warning: ... 5.8/clang_64/lib/QtCore.framework/Headers/qtimer.h:171:21: warning: implicit conversion loses integer precision: 'rep' (aka 'long long') to 'int' [-Wshorten-64-to-32] setInterval(value.count()); ~~~~~~~~~~~ ^~~~~~~~~~~~~ Change-Id: I3e0407a7193c841308f7271c41a8dd5a2eb2a534 Reviewed-by: Marc Mutz --- src/corelib/kernel/qtimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 96c7efd8f5..9303f82544 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -168,7 +168,7 @@ public: Q_ALWAYS_INLINE void setInterval(std::chrono::milliseconds value) { - setInterval(value.count()); + setInterval(int(value.count())); } Q_ALWAYS_INLINE -- cgit v1.2.3 From 2ae8292d03beab5869a1319e3d18ea281a5d014c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 28 Feb 2017 09:22:41 +0100 Subject: QList: Avoid implicit conversion warning This fixes compiling an application using QList and -Wshorten-64-to-32 on a 64-bit system without getting this warning: ... 5.8/clang_64/lib/QtCore.framework/Headers/qlist.h:897:26: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] int removedCount = e - n; ~~~~~~~~~~~~ ~~^~~ Change-Id: I688ed086805c431821c2ee6078fa5aeb631e7a07 Reviewed-by: Marc Mutz --- src/corelib/tools/qlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index c0a92aaa10..5995be47a9 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -894,7 +894,7 @@ Q_OUTOFLINE_TEMPLATE int QList::removeAll(const T &_t) *n++ = *i; } - int removedCount = e - n; + int removedCount = int(e - n); d->end -= removedCount; return removedCount; } -- cgit v1.2.3 From 04b8db3d57970631351fc6330af9553e94f1b14d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 25 Feb 2017 11:21:44 -0800 Subject: Fix parsing of day-of-week names that start with another name Task-number: QTBUG-59159 Change-Id: I95c9e502ccc74af3bcf0fffd14a69e0cd27ce96b Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetimeparser.cpp | 41 ++++-------------- .../auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 50 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index d66416207b..c8aa4fbc89 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -49,7 +49,7 @@ //#define QDATETIMEPARSER_DEBUG #if defined (QDATETIMEPARSER_DEBUG) && !defined(QT_NO_DEBUG_STREAM) -# define QDTPDEBUG qDebug() << QString("%1:%2").arg(__FILE__).arg(__LINE__) +# define QDTPDEBUG qDebug() # define QDTPDEBUGN qDebug #else # define QDTPDEBUG if (false) qDebug() @@ -1325,39 +1325,16 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex } const QLocale l = locale(); for (int day=startDay; day<=7; ++day) { - const QString str2 = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); - - if (str1.startsWith(str2.toLower())) { - if (used) - *used = str2.size(); - if (usedDay) { - *usedDay = str2; - } - return day; - } - if (context == FromString) - continue; + const QString dayName = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); + const QString str2 = dayName.toLower(); const int limit = qMin(str1.size(), str2.size()); - bool found = true; - for (int i=0; i bestCount) { - bestCount = i; - bestMatch = day; - } - found = false; - break; - } - - } - if (found) { - if (used) - *used = limit; - if (usedDay) - *usedDay = str2; - - return day; + int i = 0; + while (i < limit && str1.at(i) == str2.at(i)) + ++i; + if (i > bestCount) { + bestCount = i; + bestMatch = day; } } if (usedDay && bestMatch != -1) { diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 33844feafe..b6c740998e 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -117,6 +117,8 @@ private slots: void fromStringDateFormat(); void fromStringStringFormat_data(); void fromStringStringFormat(); + void fromStringStringFormatLocale_data(); + void fromStringStringFormatLocale(); #ifdef Q_OS_WIN void fromString_LOCALE_ILDATE(); #endif @@ -2337,6 +2339,54 @@ void tst_QDateTime::fromStringStringFormat() QCOMPARE(dt, expected); } +void tst_QDateTime::fromStringStringFormatLocale_data() +{ + QTest::addColumn("string"); + QTest::addColumn("format"); + QTest::addColumn("locale"); + QTest::addColumn("expected"); + + QLocale c = QLocale::c(); + QDateTime dt(QDate(2017, 02, 25), QTime(17, 21, 25)); + + // The formats correspond to the locale formats, with the timezone removed. + // We hardcode them in case an update to the locale DB changes them. + + QTest::newRow("C:long") << "Saturday, 25 February 2017 17:21:25" << "dddd, d MMMM yyyy HH:mm:ss" << c << dt; + QTest::newRow("C:short") << "25 Feb 2017 17:21:25" << "d MMM yyyy HH:mm:ss" << c << dt; + QTest::newRow("C:narrow") << "25 Feb 2017 17:21:25" << "d MMM yyyy HH:mm:ss" << c << dt; + + QLocale fr(QLocale::French); + QTest::newRow("fr:long") << "Samedi 25 fĂ©vrier 2017 17:21:25" << "dddd d MMMM yyyy HH:mm:ss" << fr << dt; + QTest::newRow("fr:short") << "25/02/2017 17:21" << "dd/MM/yyyy HH:mm" << fr << dt.addSecs(-25); + + // In Turkish, the word for Friday ("Cuma") is a prefix for the word for + // Saturday ("Cumartesi") + QLocale tr(QLocale::Turkish); + QTest::newRow("tr:long") << "25 Ĺžubat 2017 Cumartesi 17:21:25" << "d MMMM yyyy dddd HH:mm:ss" << tr << dt; + QTest::newRow("tr:long2") << "24 Ĺžubat 2017 Cuma 17:21:25" << "d MMMM yyyy dddd HH:mm:ss" << tr << dt.addDays(-1); + QTest::newRow("tr:mashed") << "25 Ĺžubat2017 Cumartesi17:21:25" << "d MMMMyyyy ddddHH:mm:ss" << tr << dt; + QTest::newRow("tr:mashed2") << "24 Ĺžubat2017 Cuma17:21:25" << "d MMMMyyyy ddddHH:mm:ss" << tr << dt.addDays(-1); + QTest::newRow("tr:short") << "25.02.2017 17:21" << "d.MM.yyyy HH:mm" << tr << dt.addSecs(-25); +} + +void tst_QDateTime::fromStringStringFormatLocale() +{ + QFETCH(QString, string); + QFETCH(QString, format); + QFETCH(QLocale, locale); + QFETCH(QDateTime, expected); + + QDateTime parsed = locale.toDateTime(string, format); + QCOMPARE(parsed, expected); + + parsed = locale.toDateTime(string.toLower(), format); + QCOMPARE(parsed, expected); + + parsed = locale.toDateTime(string.toUpper(), format); + QCOMPARE(parsed, expected); +} + #ifdef Q_OS_WIN // Windows only void tst_QDateTime::fromString_LOCALE_ILDATE() -- cgit v1.2.3 From 706bfa499a1fadae4094831b639ba4ed68ea4a80 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Mon, 27 Feb 2017 12:47:01 +0100 Subject: Fix "zero as null pointer constant" warning qsqlrelationaldelegate.h:60:52: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant] explicit QSqlRelationalDelegate(QObject *aParent = 0) qsqlrelationaldelegate.h:72:87: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant] QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0; qsqlrelationaldelegate.h:93:87: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant] QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0; Change-Id: I6e7de3cccf705b74018f522165886104194bf9be Reviewed-by: Marc Mutz --- src/sql/models/qsqlrelationaldelegate.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sql/models/qsqlrelationaldelegate.h b/src/sql/models/qsqlrelationaldelegate.h index f295de7396..32c994363e 100644 --- a/src/sql/models/qsqlrelationaldelegate.h +++ b/src/sql/models/qsqlrelationaldelegate.h @@ -56,7 +56,7 @@ class QSqlRelationalDelegate: public QItemDelegate { public: -explicit QSqlRelationalDelegate(QObject *aParent = 0) +explicit QSqlRelationalDelegate(QObject *aParent = nullptr) : QItemDelegate(aParent) {} @@ -68,7 +68,7 @@ QWidget *createEditor(QWidget *aParent, const QModelIndex &index) const override { const QSqlRelationalTableModel *sqlModel = qobject_cast(index.model()); - QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0; + QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : nullptr; if (!childModel) return QItemDelegate::createEditor(aParent, option, index); @@ -86,7 +86,7 @@ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex return; QSqlRelationalTableModel *sqlModel = qobject_cast(model); - QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0; + QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : nullptr; QComboBox *combo = qobject_cast(editor); if (!sqlModel || !childModel || !combo) { QItemDelegate::setModelData(editor, model, index); -- cgit v1.2.3 From 9c7ef72c876b8a7d9730137107c9b40af6eaa6e1 Mon Sep 17 00:00:00 2001 From: Jason Erb Date: Sat, 25 Feb 2017 18:33:02 -0500 Subject: Fix registry function link error on Windows Added library required by registry functions called by QWindowsFontDatabase::readRegistryString. Task-number: QTBUG-59160 Change-Id: I8f6beee3cff4443c56bd835021d15122867e76e3 Reviewed-by: Friedemann Kleint --- src/platformsupport/fontdatabases/windows/windows.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/fontdatabases/windows/windows.pri b/src/platformsupport/fontdatabases/windows/windows.pri index 4fc4e7b8ec..4ca0080ad9 100644 --- a/src/platformsupport/fontdatabases/windows/windows.pri +++ b/src/platformsupport/fontdatabases/windows/windows.pri @@ -25,4 +25,4 @@ qtConfig(directwrite) { DEFINES *= QT_NO_DIRECTWRITE } -LIBS += -lole32 -lgdi32 -luser32 +LIBS += -lole32 -lgdi32 -luser32 -ladvapi32 -- cgit v1.2.3 From fe2ab724de8bf9bef92f2e889efd6546ac828743 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 27 Feb 2017 21:58:17 -0800 Subject: tst_utf8: Fix one of the overlong sequences to be what we meant C0 to DF take one continuation byte; E0 to EF take two. It's invalid UTF-8 anyway, but at least this is what the test row meant: overlong sequence with 3 bytes of what should have been two. This updates the comment to match the character that we were actually testing. Change-Id: I85a8bd6da2c44f52b4e3fffd14a75df2600487aa Reviewed-by: Edward Welbourne --- tests/auto/corelib/codecs/utf8/utf8data.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/codecs/utf8/utf8data.cpp b/tests/auto/corelib/codecs/utf8/utf8data.cpp index 603ebbbcef..2267dc8514 100644 --- a/tests/auto/corelib/codecs/utf8/utf8data.cpp +++ b/tests/auto/corelib/codecs/utf8/utf8data.cpp @@ -85,10 +85,10 @@ void loadInvalidUtf8Rows() // overlong 6: xxxx:xxz0 xz00:0000 xz00:0000 xz00:0000 xz00:0001 xz00:0001 QTest::newRow("overlong-1-6") << QByteArray("\xFC\x80\x80\x80\x81\x81"); - // NBSP: U+00A0: 10 00 0000 + // U+0080: 10 00 0000 // proper encoding: xxz0:0010 xz00:0000 // overlong 3: xxxz:0000 xz00:0010 xz00:0000 - QTest::newRow("overlong-2-3") << QByteArray("\xC0\x82\x80"); + QTest::newRow("overlong-2-3") << QByteArray("\xE0\x82\x80"); // overlong 4: xxxx:z000 xz00:0000 xz00:0010 xz00:0000 QTest::newRow("overlong-2-4") << QByteArray("\xF0\x80\x82\x80"); // overlong 5: xxxx:xz00 xz00:0000 xz00:0000 xz00:0010 xz00:0000 -- cgit v1.2.3 From 1a5deb7e0ea9a129d4ebc59677893c7477ad5a3a Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 1 Mar 2017 14:29:25 +0100 Subject: xcb: fix misuse of xcb_send_event This fixes the following Valgrind warning: "Syscall param writev(vector[...]) points to uninitialised byte(s) Uninitialised value was created by a stack allocation" The xcb_send_event() requires all events to have 32 bytes. It calls memcpy() on the passed in event. If the passed in event is less than 32 bytes, memcpy() reaches into unrelated memory. And as it turns out, this behavior is actually described in the xcb_send_event function's documentation. This patch adds a macro that declares an event for safe usage with xcb_send_event. Change-Id: Ifcaab5e9a3b52b7f64ac930b423e0c7798bbfedb Done-with: Uli Schlachter Task-number: QTBUG-56518 Reviewed-by: Marc Mutz --- src/plugins/platforms/xcb/qxcbclipboard.cpp | 2 +- src/plugins/platforms/xcb/qxcbconnection.h | 13 +++++++++++++ src/plugins/platforms/xcb/qxcbdrag.cpp | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index cee011bbdf..a293066b93 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -607,7 +607,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) return; } - xcb_selection_notify_event_t event; + Q_DECLARE_XCB_EVENT(event, xcb_selection_notify_event_t); event.response_type = XCB_SELECTION_NOTIFY; event.requestor = req->requestor; event.selection = req->selection; diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index a9208ffe09..01a97a187a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -734,6 +734,19 @@ private: QXcbConnection *m_connection; }; +template +union q_padded_xcb_event { + T event; + char padding[32]; +}; + +// The xcb_send_event() requires all events to have 32 bytes. It calls memcpy() on the +// passed in event. If the passed in event is less than 32 bytes, memcpy() reaches into +// unrelated memory. +#define Q_DECLARE_XCB_EVENT(event_var, event_type) \ + q_padded_xcb_event store = {}; \ + auto &event_var = store.event; + #ifdef Q_XCB_DEBUG template cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 58fb1f3918..60d142157f 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -1163,7 +1163,7 @@ static xcb_window_t findXdndAwareParent(QXcbConnection *c, xcb_window_t window) void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event) { - xcb_selection_notify_event_t notify; + Q_DECLARE_XCB_EVENT(notify, xcb_selection_notify_event_t); notify.response_type = XCB_SELECTION_NOTIFY; notify.requestor = event->requestor; notify.selection = event->selection; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index ffbe9a2325..78d000c774 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -864,7 +864,7 @@ void QXcbWindow::hide() Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window)); // send synthetic UnmapNotify event according to icccm 4.1.4 - xcb_unmap_notify_event_t event; + Q_DECLARE_XCB_EVENT(event, xcb_unmap_notify_event_t); event.response_type = XCB_UNMAP_NOTIFY; event.event = xcbScreen()->root(); event.window = m_window; -- cgit v1.2.3 From 6965b8a59217e5f1db9e5986d6ccc8f5ff5f4e9c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 1 Mar 2017 13:29:50 +0100 Subject: Fix crash for glyphs with height > 128 In fe97ecf408da60931fc49b502a223d59b5f93f99 we added support for arbitrarily sized glyphs, since there is no guarantee that a glyph will fit inside the em square. There was, however, a hardcoded max size in the distance field generator, so for very tall glyphs we could potentially get a crash. [ChangeLog][QtGui][Text] Fixed crash for very tall glyphs Task-number: QTBUG-57241 Change-Id: Id95c0f10d82a1294f7e7a51ac32e88a5a2e0a790 Reviewed-by: Yoann Lopes Reviewed-by: Konstantin Ritt --- src/gui/text/qdistancefield.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 933dd1bf54..064c2aca7f 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -436,8 +436,8 @@ static void drawPolygons(qint32 *bits, int width, int height, const QPoint *vert const quint32 *indices, int indexCount, qint32 value) { Q_ASSERT(indexCount != 0); - Q_ASSERT(height <= 128); - QVarLengthArray scans[128]; + typedef QVarLengthArray ScanLine; + QVarLengthArray scans(height); int first = 0; for (int i = 1; i < indexCount; ++i) { quint32 idx1 = indices[i - 1]; -- cgit v1.2.3 From 8387d87bdcf7dfb359515f44b17f523791bc8edb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 2 Mar 2017 08:55:35 +0100 Subject: QDialogButtonGroup: Fix removal of deleted buttons As the destroyed() signal is emitted from ~QObject, it is not allowed to use static_cast to a QAbstractButton on that pointer anymore. And the qobject_cast will also fail which will keep a dangling pointer in the hash. Change-Id: If0d22fcc30cde87e771e70914c3afb04ea207289 Reviewed-by: Marc Mutz --- src/widgets/widgets/qdialogbuttonbox.cpp | 5 ++--- .../widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 23158cf82f..984669f29a 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -716,8 +716,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) return; // Remove it from the standard button hash first and then from the roles - if (QPushButton *pushButton = qobject_cast(button)) - d->standardButtonHash.remove(pushButton); + d->standardButtonHash.remove(reinterpret_cast(button)); for (int i = 0; i < NRoles; ++i) { QList &list = d->buttonLists[i]; for (int j = 0; j < list.count(); ++j) { @@ -883,7 +882,7 @@ void QDialogButtonBoxPrivate::_q_handleButtonDestroyed() Q_Q(QDialogButtonBox); if (QObject *object = q->sender()) { QBoolBlocker skippy(internalRemove); - q->removeButton(static_cast(object)); + q->removeButton(reinterpret_cast(object)); } } diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index a35ea8eb6e..f127fd98f7 100644 --- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -97,6 +97,8 @@ private slots: void testDefaultButton(); void task191642_default(); + void testDeletedStandardButton(); + private: qint64 timeStamp; qint64 buttonClicked1TimeStamp; @@ -843,5 +845,22 @@ void tst_QDialogButtonBox::task191642_default() QCOMPARE(clicked.count(), 1); } +void tst_QDialogButtonBox::testDeletedStandardButton() +{ + QDialogButtonBox buttonBox; + delete buttonBox.addButton(QDialogButtonBox::Ok); + QPointer buttonC = buttonBox.addButton(QDialogButtonBox::Cancel); + delete buttonBox.addButton(QDialogButtonBox::Cancel); + QPointer buttonA = buttonBox.addButton(QDialogButtonBox::Apply); + delete buttonBox.addButton(QDialogButtonBox::Help); + // A few button have been deleted, they should automatically be removed + QCOMPARE(buttonBox.standardButtons(), QDialogButtonBox::Apply | QDialogButtonBox::Cancel); + + buttonBox.setStandardButtons(QDialogButtonBox::Reset | QDialogButtonBox::Cancel); + // setStanderdButton should delete previous buttons + QVERIFY(!buttonA); + QVERIFY(!buttonC); +} + QTEST_MAIN(tst_QDialogButtonBox) #include "tst_qdialogbuttonbox.moc" -- cgit v1.2.3 From 2b13ba0ca0a70605c4a189072e4bc0cf6d0601d2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 2 Mar 2017 08:57:48 +0100 Subject: Fix UB in QWidgetItemV2::~QWidgetItemV2 We might get there because 'wid' is already partially deleted (called from ~QObject). In that case, it is an undefined behavior to call a QWidget member function on it. Use QObjectPrivate::get instead. Change-Id: I6da314bf8385684d1332aa031a2d92012941303b Reviewed-by: Marc Mutz --- src/widgets/kernel/qlayoutitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index ee0c28ec76..51793bf060 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -767,7 +767,7 @@ QWidgetItemV2::QWidgetItemV2(QWidget *widget) QWidgetItemV2::~QWidgetItemV2() { if (wid) { - QWidgetPrivate *wd = wid->d_func(); + auto *wd = static_cast(QObjectPrivate::get(wid)); if (wd->widgetItem == this) wd->widgetItem = 0; } -- cgit v1.2.3 From 62e6aa6195680fde73807bab3a43c63f10c585f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 28 Feb 2017 09:42:08 +0100 Subject: QVector: Avoid implicit conversion warnings This fixes compiling an application using QVector and -Wshorten-64-to-32 on a 64-bit system without getting this warning: ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:695:18: warning: implicit conversion loses integer precision: 'typename iterator_traits::difference_type' (aka 'long') to 'int' [-Wshorten-64-to-32] int offset = std::distance(d->begin(), before); ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:731:35: warning: implicit conversion loses integer precision: 'long' to 'const int' [-Wshorten-64-to-32] const int itemsToErase = aend - abegin; ~~~~~~~~~~~~ ~~~~~^~~~~~~~ ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:740:39: warning: implicit conversion loses integer precision: 'long' to 'const int' [-Wshorten-64-to-32] const int itemsUntouched = abegin - d->begin(); ~~~~~~~~~~~~~~ ~~~~~~~^~~~~~~~~~~~ Change-Id: I52d85908f4aac20c7e9ac8063ac760ce52f85541 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/tools/qvector.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 5225b68d40..a526d35ddc 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -692,7 +692,7 @@ typename QVector::iterator QVector::insert(iterator before, size_type n, c { Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); - int offset = std::distance(d->begin(), before); + const auto offset = std::distance(d->begin(), before); if (n != 0) { const T copy(t); if (!isDetached() || d->size + n > int(d->alloc)) @@ -728,7 +728,7 @@ typename QVector::iterator QVector::erase(iterator abegin, iterator aend) Q_ASSERT_X(isValidIterator(abegin), "QVector::erase", "The specified iterator argument 'abegin' is invalid"); Q_ASSERT_X(isValidIterator(aend), "QVector::erase", "The specified iterator argument 'aend' is invalid"); - const int itemsToErase = aend - abegin; + const auto itemsToErase = aend - abegin; if (!itemsToErase) return abegin; @@ -737,7 +737,7 @@ typename QVector::iterator QVector::erase(iterator abegin, iterator aend) Q_ASSERT(aend <= d->end()); Q_ASSERT(abegin <= aend); - const int itemsUntouched = abegin - d->begin(); + const auto itemsUntouched = abegin - d->begin(); // FIXME we could do a proper realloc, which copy constructs only needed data. // FIXME we are about to delete data - maybe it is good time to shrink? @@ -766,7 +766,7 @@ typename QVector::iterator QVector::erase(iterator abegin, iterator aend) memmove(static_cast(abegin), static_cast(aend), (d->size - itemsToErase - itemsUntouched) * sizeof(T)); } - d->size -= itemsToErase; + d->size -= int(itemsToErase); } return d->begin() + itemsUntouched; } -- cgit v1.2.3 From b736d2d7ce24b43882255a2af7db90dcaa227bfd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 27 Feb 2017 09:17:51 -0800 Subject: Remove the last remaining non-SSL use of QMutexPool in Qt Task-number: QTBUG-59164 Change-Id: Idd5ceba1eba34cb78c46fffd14a734735991f4fb Reviewed-by: David Faure --- src/network/kernel/qauthenticator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 107addae58..099d9586d2 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -1445,7 +1445,8 @@ static PSecurityFunctionTable pSecurityFunctionTable = NULL; static bool q_NTLM_SSPI_library_load() { - QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&pSecurityFunctionTable)); + static QBasicMutex mutex; + QMutexLocker l(&mutex); // Initialize security interface if (pSecurityFunctionTable == NULL) { -- cgit v1.2.3 From 840aa67146773d36c98fbdd0c446a1076551efaa Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 16 Feb 2017 23:44:22 -0800 Subject: Fix Bitcode handling for both makefile and Xcode generators This fixes an issue which caused certain iOS projects to fail to link when building with Xcode, and also fixes an issue where projects were only ever built with -fembed-bitcode instead of -fembed-bitcode-marker for debug builds with the makefile generator. Task-number: QTBUG-58754 Change-Id: Icf0c9f0d64dbc0b38d6c48bf635c5383a78bd6d5 Reviewed-by: Oswald Buddenhagen Reviewed-by: Gabriel de Dietrich --- mkspecs/features/uikit/bitcode.prf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/uikit/bitcode.prf b/mkspecs/features/uikit/bitcode.prf index a1dff19eb3..df298171c0 100644 --- a/mkspecs/features/uikit/bitcode.prf +++ b/mkspecs/features/uikit/bitcode.prf @@ -1,7 +1,13 @@ lessThan(QMAKE_XCODE_VERSION, "7.0") { warning("You need to update Xcode to version 7 or newer to support bitcode") -} else { - release:device { +} else: !macx-xcode { + # Simulator builds and all debug builds SHOULD use -fembed-bitcode-marker, + # but unfortunately the -fembed-bitcode and -fembed-bitcode-marker driver + # flags do not work in conjunction with -Xarch, so we'll have to let it use + # the "wrong" flags for now (note that this issue affects only the Makefile + # generator). We also don't want the flags to be passed in Xcode builds, as + # the Xcode ENABLE_BITCODE setting will take care of that for us. + release { QMAKE_CFLAGS += -fembed-bitcode QMAKE_CXXFLAGS += -fembed-bitcode QMAKE_OBJECTIVE_CFLAGS += -fembed-bitcode -- cgit v1.2.3 From d46afc24c177642734ed7a228fc6d3a0d7fa429f Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Wed, 22 Feb 2017 12:49:49 -0800 Subject: QMacStyle::sizeFromContents(CT_Menu): take proxy style into account This is missed in 10d0f4cba99d2386db28a3afd71832e35992b797 Change-Id: If3566eb4b1f00f6882c290c83e10e51e1bf1d6d9 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 238e96ab4f..f23f6c00b2 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -6759,7 +6759,15 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, break; } case CT_Menu: { - sz = csz; + if (proxy() == this) { + sz = csz; + } else { + QStyleHintReturnMask menuMask; + QStyleOption myOption = *opt; + myOption.rect.setSize(sz); + if (proxy()->styleHint(SH_Menu_Mask, &myOption, widget, &menuMask)) + sz = menuMask.region.boundingRect().size(); + } break; } case CT_HeaderSection:{ const QStyleOptionHeader *header = qstyleoption_cast(opt); -- cgit v1.2.3 From ad5565b6438cb239ad36722605a31b1006cd6478 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Thu, 12 Jan 2017 10:03:10 -0800 Subject: Wide QMenu: fix size and position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes 2 issues related to wide menus: 1) Menu took on full screen height when menu width was larger than screen width; 2) On a multi-display system wide menu might appear on wrong monitor (not the one where show event was triggered). The idea is we limit parent menu and all its submenus within the screen where it was opened. Note that this patch fixes only geometry-related issues and there are also some style flaws which need to be addressed (for example, currently the text does not elide if it doesn’t fit to the menu’s width). Task-number: QTBUG-56917 Change-Id: I7e9ff4a48bf03060d76e34d33a13ad6cc890c133 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmenu.cpp | 45 +++++++++----------------- src/widgets/widgets/qmenu_p.h | 1 - tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 37 +++++++++++++++++++++ 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 2917083415..16f8734d7b 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -401,17 +401,6 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const itemsDirty = 0; } -QSize QMenuPrivate::adjustMenuSizeForScreen(const QRect &screen) -{ - Q_Q(QMenu); - QSize ret = screen.size(); - itemsDirty = true; - updateActionRects(screen); - const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); - ret.setWidth(actionRects.at(getLastVisibleAction()).right() + fw); - return ret; -} - int QMenuPrivate::getLastVisibleAction() const { //let's try to get the last visible action @@ -2265,7 +2254,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction) else pos = p; - QSize size = sizeHint(); + const QSize menuSizeHint(sizeHint()); + QSize size = menuSizeHint; QRect screen; #ifndef QT_NO_GRAPHICSVIEW bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); @@ -2278,13 +2268,11 @@ void QMenu::popup(const QPoint &p, QAction *atAction) bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen); // if the screens have very different geometries and the menu is too big, we have to recalculate - if (size.height() > screen.height() || size.width() > screen.width()) { - size = d->adjustMenuSizeForScreen(screen); - adjustToDesktop = true; - } - // Layout is not right, we might be able to save horizontal space - if (d->ncols >1 && size.height() < screen.height()) { - size = d->adjustMenuSizeForScreen(screen); + if ((size.height() > screen.height() || size.width() > screen.width()) || + // Layout is not right, we might be able to save horizontal space + (d->ncols >1 && size.height() < screen.height())) { + size.setWidth(qMin(menuSizeHint.width(), screen.width() - desktopFrame * 2)); + size.setHeight(qMin(menuSizeHint.height(), screen.height() - desktopFrame * 2)); adjustToDesktop = true; } @@ -2337,7 +2325,6 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->mousePopupPos = mouse; const bool snapToMouse = !d->causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse)); - const QSize menuSize(sizeHint()); if (adjustToDesktop) { // handle popup falling "off screen" if (isRightToLeft()) { @@ -2371,7 +2358,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if (pos.y() < screen.top() + desktopFrame) pos.setY(screen.top() + desktopFrame); - if (pos.y() + menuSize.height() - 1 > screen.bottom() - desktopFrame) { + if (pos.y() + menuSizeHint.height() - 1 > screen.bottom() - desktopFrame) { if (d->scroll) { d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown); int y = qMax(screen.y(),pos.y()); @@ -2384,29 +2371,29 @@ void QMenu::popup(const QPoint &p, QAction *atAction) } const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); QMenu *caused = qobject_cast(d_func()->causedPopup.widget); - if (caused && caused->geometry().width() + menuSize.width() + subMenuOffset < screen.width()) { + if (caused && caused->geometry().width() + menuSizeHint.width() + subMenuOffset < screen.width()) { QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction)); const QPoint actionTopLeft = caused->mapToGlobal(parentActionRect.topLeft()); parentActionRect.moveTopLeft(actionTopLeft); if (isRightToLeft()) { - if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset) + if ((pos.x() + menuSizeHint.width() > parentActionRect.left() - subMenuOffset) && (pos.x() < parentActionRect.right())) { - pos.rx() = parentActionRect.left() - menuSize.width(); + pos.rx() = parentActionRect.left() - menuSizeHint.width(); if (pos.x() < screen.x()) pos.rx() = parentActionRect.right(); - if (pos.x() + menuSize.width() > screen.x() + screen.width()) + if (pos.x() + menuSizeHint.width() > screen.x() + screen.width()) pos.rx() = screen.x(); } } else { if ((pos.x() < parentActionRect.right() + subMenuOffset) - && (pos.x() + menuSize.width() > parentActionRect.left())) + && (pos.x() + menuSizeHint.width() > parentActionRect.left())) { pos.rx() = parentActionRect.right(); - if (pos.x() + menuSize.width() > screen.x() + screen.width()) - pos.rx() = parentActionRect.left() - menuSize.width(); + if (pos.x() + menuSizeHint.width() > screen.x() + screen.width()) + pos.rx() = parentActionRect.left() - menuSizeHint.width(); if (pos.x() < screen.x()) - pos.rx() = screen.x() + screen.width() - menuSize.width(); + pos.rx() = screen.x() + screen.width() - menuSizeHint.width(); } } } diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 64291e842f..898fa3161b 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -311,7 +311,6 @@ public: mutable uint ncols : 4; //4 bits is probably plenty uint collapsibleSeparators : 1; uint toolTipsVisible : 1; - QSize adjustMenuSizeForScreen(const QRect & screen); int getLastVisibleAction() const; bool activationRecursionGuard; diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 3218b8ac68..4e82099706 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -110,6 +111,8 @@ private slots: void QTBUG_37933_ampersands_data(); void QTBUG_37933_ampersands(); #endif + void QTBUG_56917_wideMenuSize(); + void QTBUG_56917_wideMenuScreenNumber(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -1311,5 +1314,39 @@ void tst_QMenu::QTBUG_37933_ampersands() } #endif +void tst_QMenu::QTBUG_56917_wideMenuSize() +{ + // menu shouldn't to take on full screen height when menu width is larger than screen width + QMenu menu; + QString longString; + longString.fill(QLatin1Char('Q'), 3000); + menu.addAction(longString); + QSize menuSizeHint = menu.sizeHint(); + menu.popup(QPoint()); + QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + QVERIFY(menu.isVisible()); + QVERIFY(menu.height() <= menuSizeHint.height()); +} + +void tst_QMenu::QTBUG_56917_wideMenuScreenNumber() +{ + if (QApplication::styleHints()->showIsFullScreen()) + QSKIP("The platform defaults to windows being fullscreen."); + // menu must appear on the same screen where show action is triggered + QString longString; + longString.fill(QLatin1Char('Q'), 3000); + + for (int i = 0; i < QApplication::desktop()->screenCount(); i++) { + QMenu menu; + menu.addAction(longString); + menu.popup(QApplication::desktop()->screen(i)->geometry().center()); + QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + QVERIFY(menu.isVisible()); + QCOMPARE(QApplication::desktop()->screenNumber(&menu), i); + } +} + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" -- cgit v1.2.3 From f2e103296f9077a747e0dd43504e3e7630f56605 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Fri, 13 Jan 2017 10:33:49 -0800 Subject: QMenu: make wide submenu appear on the same screen with its parent menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a multi-display system wide submenu might either appear on wrong screen or not appear at all (depending on the specific display configuration). Task-number: QTBUG-56917 Change-Id: I40013b0bee340a01ae1c08a5e074afa63da4dbfd Reviewed-by: Gabriel de Dietrich Reviewed-by: BĹ‚aĹĽej SzczygieĹ‚ --- src/widgets/widgets/qmenu.cpp | 15 +++++++++++++-- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 16f8734d7b..1925b58326 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -3501,11 +3501,22 @@ void QMenu::internalDelayedPopup() d->activeMenu->d_func()->causedPopup.widget = this; d->activeMenu->d_func()->causedPopup.action = d->currentAction; + QRect screen; +#ifndef QT_NO_GRAPHICSVIEW + bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); + if (isEmbedded) + screen = d->popupGeometry(this); + else +#endif + screen = d->popupGeometry(QApplication::desktop()->screenNumber(pos())); + int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); const QRect actionRect(d->actionRect(d->currentAction)); - const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); + QPoint subMenuPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); + if (subMenuPos.x() > screen.right()) + subMenuPos.setX(QCursor::pos().x()); - d->activeMenu->popup(rightPos); + d->activeMenu->popup(subMenuPos); d->sloppyState.setSubMenuPopup(actionRect, d->currentAction, d->activeMenu); #if !defined(Q_OS_DARWIN) diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 4e82099706..b037cc2141 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -113,6 +113,7 @@ private slots: #endif void QTBUG_56917_wideMenuSize(); void QTBUG_56917_wideMenuScreenNumber(); + void QTBUG_56917_wideSubmenuScreenNumber(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -1348,5 +1349,29 @@ void tst_QMenu::QTBUG_56917_wideMenuScreenNumber() } } +void tst_QMenu::QTBUG_56917_wideSubmenuScreenNumber() +{ + if (QApplication::styleHints()->showIsFullScreen()) + QSKIP("The platform defaults to windows being fullscreen."); + // submenu must appear on the same screen where its parent menu is shown + QString longString; + longString.fill(QLatin1Char('Q'), 3000); + + for (int i = 0; i < QApplication::desktop()->screenCount(); i++) { + QMenu menu; + QMenu submenu("Submenu"); + submenu.addAction(longString); + QAction *action = menu.addMenu(&submenu); + menu.popup(QApplication::desktop()->screen(i)->geometry().center()); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + QVERIFY(menu.isVisible()); + QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.actionGeometry(action).center()); + QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowExposed(&submenu)); + QVERIFY(submenu.isVisible()); + QCOMPARE(QApplication::desktop()->screenNumber(&submenu), i); + } +} + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" -- cgit v1.2.3 From a1c27748d22f94d608cc499db527bf989a5516f2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 2 Mar 2017 14:23:05 +0100 Subject: Make QLocale consistent about special handling of the C locale QLocale::matchingLocales() simply created each locale using the basic data, without (unless the matching conditions stipulated Language C) applying number-options hacks that it applies everywhere else, when creating the C locale. Thus the C locale in its returned list (if it wasn't the only entry) ended up with the default number options, without omiting separators in numbers. Thus QLocale::c() didn't actually appear as an entry in the list. Discovered while investigating QTBUG-58947. Added a dumb autotest that checks various ways of getting the C locale do actually give us equal locale objects. Fixed matchingLocales() to apply the same hack as is used elsewhere for the C locale. Change-Id: I263f31da623052b63171f5b5a83c65802383df21 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 4 ++-- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 2ce410062a..c183224c82 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2115,8 +2115,8 @@ QList QLocale::matchingLocales(QLocale::Language language, && (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) { if ((script == QLocale::AnyScript || data->m_script_id == uint(script)) && (country == QLocale::AnyCountry || data->m_country_id == uint(country))) { - QLocale locale(*QLocalePrivate::create(data)); - result.append(locale); + result.append(QLocale(*(data->m_language_id == C ? c_private() + : QLocalePrivate::create(data)))); } ++data; } diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 06b0fe8d51..d18af71e20 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -80,6 +80,7 @@ private slots: void ctor(); void emptyCtor(); void legacyNames(); + void consistentC(); void unixLocaleName(); void matchingLocales(); void stringToDouble_data(); @@ -579,6 +580,15 @@ void tst_QLocale::legacyNames() #undef TEST_CTOR } +void tst_QLocale::consistentC() +{ + const QLocale c(QLocale::C); + QCOMPARE(c, QLocale::c()); + QCOMPARE(c, QLocale(QLocale::C, QLocale::AnyScript, QLocale::AnyCountry)); + QVERIFY(QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, + QLocale::AnyCountry).contains(c)); +} + void tst_QLocale::matchingLocales() { const QLocale c(QLocale::C); -- cgit v1.2.3 From 37fd42459e98fe84234ecf65083fc75096a75b52 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 2 Mar 2017 22:27:32 -0800 Subject: forkfd: fix calling the old signal handler when there wasn't one On some stupid systems, execve() may clear the handler but not clear the SA_SIGINFO flag. This change now requires that sa_handler and sa_sigaction be in a union together. We can't operate otherwise. Task-number: QTBUG-59246 Change-Id: I33850dcdb2ce4a47878efffd14a84b48a8f6b1e8 Reviewed-by: Simon Hausmann --- src/3rdparty/forkfd/forkfd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index 309458a3a7..8113fdb9e7 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -297,10 +297,12 @@ static void sigchld_handler(int signum, siginfo_t *handler_info, void *handler_c * But we pass them anyway. Let's call the chained handler first, while * those two arguments have a chance of being correct. */ - if (old_sigaction.sa_flags & SA_SIGINFO) - old_sigaction.sa_sigaction(signum, handler_info, handler_context); - else if (old_sigaction.sa_handler != SIG_IGN && old_sigaction.sa_handler != SIG_DFL) - old_sigaction.sa_handler(signum); + if (old_sigaction.sa_handler != SIG_IGN && old_sigaction.sa_handler != SIG_DFL) { + if (old_sigaction.sa_flags & SA_SIGINFO) + old_sigaction.sa_sigaction(signum, handler_info, handler_context); + else + old_sigaction.sa_handler(signum); + } if (ffd_atomic_load(&forkfd_status, FFD_ATOMIC_RELAXED) == 1) { /* is this one of our children? */ -- cgit v1.2.3 From f31dbeb4c7cd0d7559a8d7f523a3feea7d376186 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 6 Mar 2017 11:29:26 +0100 Subject: tst_QVersionNumber: fix Clang warning about superfluous move Parameters passed by value, like local function variables, are subject to NRVO/return-by-move already, so adding std::move, even disguised as qMove(), makes Clang warn about a pessimizing move. Change-Id: I7d59bfee4cf7ecddee0874ee489367044c702643 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index c37a15089a..2e34e82388 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -134,7 +134,7 @@ void tst_QVersionNumber::singleInstanceData() namespace UglyOperator { // ugh, but the alternative (operator <<) is even worse... -static inline QVector operator+(QVector v, int i) { v.push_back(i); return qMove(v); } +static inline QVector operator+(QVector v, int i) { v.push_back(i); return v; } } void tst_QVersionNumber::comparisonData() -- cgit v1.2.3 From d6330a19b29ebff359a6746250c78437dbcaf77d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 19 Dec 2016 10:34:32 +0100 Subject: Use QT_CONFIG(library) instead of QT_NO_LIBRARY For the windows file system engine, we add an extra macro to use library loading if configured to do so, but avoid it on WinRT, as none of the symbols would be found. We also QT_REQUIRE_CONFIG(library) in the library headers and exclude the sources from the build if library loading is disabled. This, in turn, makes it necessary to clean up some header inclusions. Change-Id: I2b152cb5b47a2658996b6f4702b038536a5704ec Reviewed-by: Oswald Buddenhagen --- src/corelib/codecs/qiconvcodec.cpp | 1 - src/corelib/global/qconfig-bootstrapped.h | 1 - src/corelib/io/qfilesystemengine_win.cpp | 29 ++++++------ src/corelib/io/qfsfileengine_win.cpp | 6 +-- src/corelib/kernel/qcoreapplication.cpp | 12 ++--- src/corelib/kernel/qcoreapplication.h | 4 +- src/corelib/plugin/plugin.pri | 53 +++++++++++----------- src/corelib/plugin/qelfparser_p.cpp | 2 - src/corelib/plugin/qelfparser_p.h | 4 +- src/corelib/plugin/qfactoryloader.cpp | 12 ++--- src/corelib/plugin/qfactoryloader_p.h | 6 ++- src/corelib/plugin/qlibrary.cpp | 4 -- src/corelib/plugin/qlibrary.h | 6 +-- src/corelib/plugin/qlibrary_p.h | 7 +-- src/corelib/plugin/qlibrary_unix.cpp | 4 -- src/corelib/plugin/qlibrary_win.cpp | 4 -- src/corelib/plugin/qmachparser.cpp | 2 +- src/corelib/plugin/qmachparser_p.h | 4 +- src/corelib/plugin/qpluginloader.cpp | 4 +- src/corelib/plugin/qpluginloader.h | 7 ++- src/corelib/tools/qharfbuzz.cpp | 4 +- src/corelib/tools/qlocale_icu.cpp | 1 - src/dbus/qdbus_symbols.cpp | 12 ++--- src/dbus/qdbusintegrator.cpp | 2 +- src/gui/kernel/qguiapplication.cpp | 6 +-- src/gui/kernel/qplatformintegrationfactory.cpp | 8 ++-- src/gui/kernel/qplatformthemefactory.cpp | 6 +-- src/gui/opengl/qopenglframebufferobject.cpp | 1 - src/network/kernel/qdnslookup_unix.cpp | 6 ++- src/network/kernel/qhostinfo_unix.cpp | 4 +- src/network/ssl/qsslsocket_openssl.cpp | 5 +- src/network/ssl/qsslsocket_openssl_symbols.cpp | 13 +++--- src/opengl/qgl.cpp | 1 - src/opengl/qglframebufferobject.cpp | 1 - .../eglfs/api/qeglfsdeviceintegration.cpp | 8 ++-- .../gl_integrations/qxcbglintegrationfactory.cpp | 6 +-- .../gl_integrations/xcb_glx/qglxintegration.cpp | 4 +- src/plugins/platforms/xcb/qxcbcursor.cpp | 12 +++-- src/plugins/platforms/xcb/qxcbcursor.h | 2 +- src/widgets/styles/qfusionstyle.cpp | 1 - src/widgets/styles/qmacstyle_mac_p_p.h | 1 - src/widgets/styles/qwindowsvistastyle_p_p.h | 1 - src/widgets/widgets/qabstractscrollarea.cpp | 1 - tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 1 - .../qcoreapplication/tst_qcoreapplication.cpp | 2 +- .../kernel/qcoreapplication/tst_qcoreapplication.h | 2 +- .../plugin/qfactoryloader/tst_qfactoryloader.cpp | 5 +- .../tst_qtextboundaryfinder.cpp | 4 +- .../auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 2 +- tests/auto/dbus/qdbustype/tst_qdbustype.cpp | 2 +- .../network/kernel/qhostinfo/tst_qhostinfo.cpp | 1 - .../kernel/qapplication/tst_qapplication.cpp | 4 +- 52 files changed, 143 insertions(+), 158 deletions(-) diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index e4fb359f2c..d6362b6fbc 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -43,7 +43,6 @@ QT_REQUIRE_CONFIG(iconv); #include "qiconvcodec_p.h" #include "qtextcodec_p.h" -#include #include #include diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index a2c0b011e7..bda8ad7916 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -71,7 +71,6 @@ #define QT_FEATURE_iconv -1 #define QT_FEATURE_icu -1 #define QT_FEATURE_journald -1 -#define QT_NO_LIBRARY #define QT_FEATURE_library -1 #define QT_NO_QOBJECT #define QT_FEATURE_process -1 diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index cdb64d08e1..0d4ef94622 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -158,14 +158,15 @@ Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0; #if defined(Q_OS_WINRT) static QString qfsPrivateCurrentDir = QLatin1String(""); -// As none of the functions we try to resolve do exist on WinRT -// we use QT_NO_LIBRARY to shorten everything up a little bit. -# ifndef QT_NO_LIBRARY -# define QT_NO_LIBRARY 1 -# endif +// As none of the functions we try to resolve do exist on WinRT we +// avoid library loading on WinRT in general to shorten everything +// up a little bit. +# define QT_FEATURE_fslibs -1 +#else +# define QT_FEATURE_fslibs QT_FEATURE_library #endif // Q_OS_WINRT -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) QT_BEGIN_INCLUDE_NAMESPACE typedef DWORD (WINAPI *PtrGetNamedSecurityInfoW)(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*); static PtrGetNamedSecurityInfoW ptrGetNamedSecurityInfoW = 0; @@ -273,7 +274,7 @@ static void resolveLibs() ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); } } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(fslibs) typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD); static PtrNetShareEnum ptrNetShareEnum = 0; @@ -343,7 +344,7 @@ static QString readSymLink(const QFileSystemEntry &link) free(rdb); CloseHandle(handle); -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) resolveLibs(); QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive); if (matchVolName.indexIn(result) == 0) { @@ -353,7 +354,7 @@ static QString readSymLink(const QFileSystemEntry &link) if (GetVolumePathNamesForVolumeName(reinterpret_cast(volumeName.utf16()), buffer, MAX_PATH, &len) != 0) result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); } -#endif // !Q_OS_WINRT +#endif // QT_CONFIG(fslibs) } #else Q_UNUSED(link); @@ -363,7 +364,7 @@ static QString readSymLink(const QFileSystemEntry &link) static QString readLink(const QFileSystemEntry &link) { -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) QString ret; bool neededCoInit = false; @@ -402,7 +403,7 @@ static QString readLink(const QFileSystemEntry &link) #else Q_UNUSED(link); return QString(); -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(fslibs) } static bool uncShareExists(const QString &server) @@ -648,7 +649,7 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own) { QString name; -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) extern int qt_ntfs_permission_lookup; if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { resolveLibs(); @@ -698,7 +699,7 @@ QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEng bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { resolveLibs(); if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) { @@ -1162,7 +1163,7 @@ QString QFileSystemEngine::rootPath() QString QFileSystemEngine::homePath() { QString ret; -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) resolveLibs(); if (ptrGetUserProfileDirectoryW) { HANDLE hnd = ::GetCurrentProcess(); diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 117c224318..e427b62136 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -589,7 +589,7 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons bool QFSFileEngine::link(const QString &newName) { #if !defined(Q_OS_WINRT) -# if !defined(QT_NO_LIBRARY) +# if QT_CONFIG(library) bool ret = false; QString linkName = newName; @@ -630,10 +630,10 @@ bool QFSFileEngine::link(const QString &newName) CoUninitialize(); return ret; -# else // QT_NO_LIBRARY +# else // QT_CONFIG(library) Q_UNUSED(newName); return false; -# endif // QT_NO_LIBRARY +# endif // QT_CONFIG(library) #else // !Q_OS_WINRT Q_UNUSED(newName); Q_UNIMPLEMENTED(); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index c5f2e71f8c..baf140b3b2 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -339,7 +339,7 @@ struct QCoreApplicationData { QString applicationVersion; bool applicationNameSet; // true if setApplicationName was called -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QScopedPointer app_libpaths; QScopedPointer manual_libpaths; #endif @@ -534,7 +534,7 @@ void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver) void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QStringList *app_libpaths = coreappdata()->app_libpaths.data(); if (!app_libpaths) coreappdata()->app_libpaths.reset(app_libpaths = new QStringList); @@ -735,7 +735,7 @@ void QCoreApplicationPrivate::init() QLoggingRegistry::instance()->init(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) // Reset the lib paths, so that they will be recomputed, taking the availability of argv[0] // into account. If necessary, recompute right away and replay the manual changes on top of the // new lib paths. @@ -834,7 +834,7 @@ QCoreApplication::~QCoreApplication() QCoreApplicationPrivate::eventDispatcher = 0; #endif -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) coreappdata()->app_libpaths.reset(); coreappdata()->manual_libpaths.reset(); #endif @@ -2414,7 +2414,7 @@ QString QCoreApplication::applicationVersion() return coreappdata()->applicationVersion; } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive)) @@ -2626,7 +2626,7 @@ void QCoreApplication::removeLibraryPath(const QString &path) QFactoryLoader::refreshAll(); } -#endif //QT_NO_LIBRARY +#endif // QT_CONFIG(library) #ifndef QT_NO_QOBJECT diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index a22e1c4f9e..5e10136dc5 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -141,12 +141,12 @@ public: static QString applicationFilePath(); static qint64 applicationPid(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) static void setLibraryPaths(const QStringList &); static QStringList libraryPaths(); static void addLibraryPath(const QString &); static void removeLibraryPath(const QString &); -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) #ifndef QT_NO_TRANSLATION static bool installTranslator(QTranslator * messageFile); diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri index bb3843cc36..a0e0d76044 100644 --- a/src/corelib/plugin/plugin.pri +++ b/src/corelib/plugin/plugin.pri @@ -1,38 +1,37 @@ # Qt core library plugin module HEADERS += \ - plugin/qfactoryinterface.h \ - plugin/qpluginloader.h \ - plugin/qlibrary.h \ - plugin/qlibrary_p.h \ - plugin/qplugin.h \ - plugin/quuid.h \ - plugin/qfactoryloader_p.h \ - plugin/qsystemlibrary_p.h \ - plugin/qelfparser_p.h \ - plugin/qmachparser_p.h + plugin/qfactoryinterface.h \ + plugin/qpluginloader.h \ + plugin/qplugin.h \ + plugin/quuid.h \ + plugin/qfactoryloader_p.h SOURCES += \ - plugin/qfactoryinterface.cpp \ - plugin/qpluginloader.cpp \ - plugin/qfactoryloader.cpp \ - plugin/quuid.cpp \ - plugin/qlibrary.cpp \ - plugin/qelfparser_p.cpp \ - plugin/qmachparser.cpp + plugin/qfactoryinterface.cpp \ + plugin/qpluginloader.cpp \ + plugin/qfactoryloader.cpp \ + plugin/quuid.cpp win32 { - SOURCES += \ - plugin/qlibrary_win.cpp \ - plugin/qsystemlibrary.cpp + HEADERS += plugin/qsystemlibrary_p.h + SOURCES += plugin/qsystemlibrary.cpp } -unix { - SOURCES += plugin/qlibrary_unix.cpp -} +qtConfig(library) { + HEADERS += \ + plugin/qlibrary.h \ + plugin/qlibrary_p.h \ + plugin/qelfparser_p.h \ + plugin/qmachparser_p.h -integrity { - SOURCES += plugin/qlibrary_unix.cpp -} + SOURCES += \ + plugin/qlibrary.cpp \ + plugin/qelfparser_p.cpp \ + plugin/qmachparser.cpp + + unix: SOURCES += plugin/qlibrary_unix.cpp + else: SOURCES += plugin/qlibrary_win.cpp -qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl + qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl +} diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp index ef1fc4ded3..85478e376e 100644 --- a/src/corelib/plugin/qelfparser_p.cpp +++ b/src/corelib/plugin/qelfparser_p.cpp @@ -39,7 +39,6 @@ #include "qelfparser_p.h" -#ifndef QT_NO_LIBRARY #if defined (Q_OF_ELF) && defined(Q_CC_GNU) #include "qlibrary_p.h" @@ -235,4 +234,3 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h index bcda19e8b5..3e73c5d149 100644 --- a/src/corelib/plugin/qelfparser_p.h +++ b/src/corelib/plugin/qelfparser_p.h @@ -54,7 +54,8 @@ #include #include -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); + #if defined (Q_OF_ELF) && defined(Q_CC_GNU) QT_BEGIN_NAMESPACE @@ -101,6 +102,5 @@ public: QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY #endif // QELFPARSER_P_H diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index b8e18cc9a8..21f1007d5b 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -62,7 +62,7 @@ class QFactoryLoaderPrivate : public QObjectPrivate public: QFactoryLoaderPrivate(){} QByteArray iid; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) ~QFactoryLoaderPrivate(); mutable QMutex mutex; QList libraryList; @@ -73,7 +73,7 @@ public: #endif }; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC(QList, qt_factory_loaders) @@ -232,7 +232,7 @@ void QFactoryLoader::refreshAll() } } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) QFactoryLoader::QFactoryLoader(const char *iid, const QString &suffix, @@ -242,7 +242,7 @@ QFactoryLoader::QFactoryLoader(const char *iid, moveToThread(QCoreApplicationPrivate::mainThread()); Q_D(QFactoryLoader); d->iid = iid; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) d->cs = cs; d->suffix = suffix; @@ -259,7 +259,7 @@ QList QFactoryLoader::metaData() const { Q_D(const QFactoryLoader); QList metaData; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QMutexLocker locker(&d->mutex); for (int i = 0; i < d->libraryList.size(); ++i) metaData.append(d->libraryList.at(i)->metaData); @@ -281,7 +281,7 @@ QObject *QFactoryLoader::instance(int index) const if (index < 0) return 0; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QMutexLocker lock(&d->mutex); if (index < d->libraryList.size()) { QLibraryPrivate *library = d->libraryList.at(index); diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h index 70a934c976..7be18942ae 100644 --- a/src/corelib/plugin/qfactoryloader_p.h +++ b/src/corelib/plugin/qfactoryloader_p.h @@ -60,7 +60,9 @@ #include "QtCore/qjsondocument.h" #include "QtCore/qmap.h" #include "QtCore/qendian.h" +#if QT_CONFIG(library) #include "private/qlibrary_p.h" +#endif QT_BEGIN_NAMESPACE @@ -84,7 +86,7 @@ public: const QString &suffix = QString(), Qt::CaseSensitivity = Qt::CaseSensitive); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) ~QFactoryLoader(); void update(); @@ -93,7 +95,7 @@ public: #if defined(Q_OS_UNIX) && !defined (Q_OS_MAC) QLibraryPrivate *library(const QString &key) const; #endif // Q_OS_UNIX && !Q_OS_MAC -#endif // !QT_NO_LIBRARY +#endif // QT_CONFIG(library) QMultiMap keyMap() const; int indexOf(const QString &needle) const; diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index a4a654cd88..6421e7c5d8 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -40,8 +40,6 @@ #include "qplatformdefs.h" #include "qlibrary.h" -#ifndef QT_NO_LIBRARY - #include "qfactoryloader_p.h" #include "qlibrary_p.h" #include @@ -1131,5 +1129,3 @@ bool qt_debug_component() } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h index 2b91fa4007..89be52aac3 100644 --- a/src/corelib/plugin/qlibrary.h +++ b/src/corelib/plugin/qlibrary.h @@ -42,9 +42,9 @@ #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(library); -#ifndef QT_NO_LIBRARY +QT_BEGIN_NAMESPACE class QLibraryPrivate; @@ -99,8 +99,6 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QLibrary::LoadHints) -#endif //QT_NO_LIBRARY - QT_END_NAMESPACE #endif //QLIBRARY_H diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 7147ff6ca2..3f650501c8 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -62,10 +62,9 @@ # include "QtCore/qt_windows.h" #endif -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); +QT_BEGIN_NAMESPACE bool qt_debug_component(); @@ -130,8 +129,6 @@ private: friend class QLibraryStore; }; -#endif // QT_NO_LIBRARY - QT_END_NAMESPACE #endif // QLIBRARY_P_H diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index 8b16021303..6c1253ea08 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -44,8 +44,6 @@ #include #include -#ifndef QT_NO_LIBRARY - #ifdef Q_OS_MAC # include #endif @@ -308,5 +306,3 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp index 48aa0cdbb6..a4d3f67c27 100644 --- a/src/corelib/plugin/qlibrary_win.cpp +++ b/src/corelib/plugin/qlibrary_win.cpp @@ -44,8 +44,6 @@ #include "qfileinfo.h" #include -#ifndef QT_NO_LIBRARY - #include QT_BEGIN_NAMESPACE @@ -174,5 +172,3 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) return QFunctionPointer(address); } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp index a599fbcb23..f506a6a6b1 100644 --- a/src/corelib/plugin/qmachparser.cpp +++ b/src/corelib/plugin/qmachparser.cpp @@ -39,7 +39,7 @@ #include "qmachparser_p.h" -#if defined(Q_OF_MACH_O) && !defined(QT_NO_LIBRARY) +#if defined(Q_OF_MACH_O) #include #include "qlibrary_p.h" diff --git a/src/corelib/plugin/qmachparser_p.h b/src/corelib/plugin/qmachparser_p.h index ff7eaadb70..3884c92797 100644 --- a/src/corelib/plugin/qmachparser_p.h +++ b/src/corelib/plugin/qmachparser_p.h @@ -54,7 +54,8 @@ #include #include -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); + #if defined(Q_OF_MACH_O) QT_BEGIN_NAMESPACE @@ -72,6 +73,5 @@ public: QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY #endif // QMACHPARSER_P_H diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index 6723877ad5..dbd3bee556 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) /*! \class QPluginLoader @@ -417,7 +417,7 @@ QLibrary::LoadHints QPluginLoader::loadHints() const return d ? d->loadHints() : QLibrary::LoadHints(); } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) typedef QVector StaticPluginList; Q_GLOBAL_STATIC(StaticPluginList, staticPluginList) diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h index 5dca59c271..80b10f76bf 100644 --- a/src/corelib/plugin/qpluginloader.h +++ b/src/corelib/plugin/qpluginloader.h @@ -40,12 +40,15 @@ #ifndef QPLUGINLOADER_H #define QPLUGINLOADER_H +#include +#if QT_CONFIG(library) #include +#endif #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) class QLibraryPrivate; class QJsonObject; @@ -93,7 +96,7 @@ public: static QVector staticPlugins(); }; -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) QT_END_NAMESPACE diff --git a/src/corelib/tools/qharfbuzz.cpp b/src/corelib/tools/qharfbuzz.cpp index fdd861690d..a3e266ccd2 100644 --- a/src/corelib/tools/qharfbuzz.cpp +++ b/src/corelib/tools/qharfbuzz.cpp @@ -40,7 +40,9 @@ #include "qharfbuzz_p.h" #include "qunicodetables_p.h" +#if QT_CONFIG(library) #include "qlibrary.h" +#endif QT_USE_NAMESPACE @@ -70,7 +72,7 @@ HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch) void (*HB_Library_Resolve(const char *library, int version, const char *symbol))() { -#ifdef QT_NO_LIBRARY +#if !QT_CONFIG(library) Q_UNUSED(library); Q_UNUSED(version); Q_UNUSED(symbol); diff --git a/src/corelib/tools/qlocale_icu.cpp b/src/corelib/tools/qlocale_icu.cpp index 0066e95d88..afe0aae583 100644 --- a/src/corelib/tools/qlocale_icu.cpp +++ b/src/corelib/tools/qlocale_icu.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qglobal.h" -#include "qlibrary.h" #include "qdebug.h" #include "qlocale_p.h" #include "qmutex.h" diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index f91a8d2176..1e93a46c0c 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -39,7 +39,7 @@ ****************************************************************************/ #include -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(library) #include #endif #include @@ -54,7 +54,7 @@ void (*qdbus_resolve_me(const char *name))(); #if !defined QT_LINKED_LIBDBUS -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) static QLibrary *qdbus_libdbus = 0; void qdbus_unloadLibDBus() @@ -71,7 +71,7 @@ void qdbus_unloadLibDBus() bool qdbus_loadLibDBus() { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) #ifdef QT_BUILD_INTERNAL // this is to simulate a library load failure for our autotest suite. if (!qEnvironmentVariableIsEmpty("QT_SIMULATE_DBUS_LIBFAIL")) @@ -126,7 +126,7 @@ bool qdbus_loadLibDBus() #endif } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) void (*qdbus_resolve_conditionally(const char *name))() { if (qdbus_loadLibDBus()) @@ -137,7 +137,7 @@ void (*qdbus_resolve_conditionally(const char *name))() void (*qdbus_resolve_me(const char *name))() { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) if (Q_UNLIKELY(!qdbus_loadLibDBus())) qFatal("Cannot find libdbus-1 in your system to resolve symbol '%s'.", name); @@ -161,7 +161,7 @@ static void qdbus_unloadLibDBus() #endif // !QT_LINKED_LIBDBUS -#if defined(QT_LINKED_LIBDBUS) || !defined(QT_NO_LIBRARY) +#if defined(QT_LINKED_LIBDBUS) || QT_CONFIG(library) Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus) #endif diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index c63fb05e74..20186ef9f0 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1772,7 +1772,7 @@ static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnecti # if DBUS_VERSION-0 >= 0x010400 can_send_type = dbus_connection_can_send_type; # endif -#elif !defined(QT_NO_LIBRARY) +#elif QT_CONFIG(library) // run-time check if the next functions are available can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); #endif diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 3ba0d59102..46e5f6be70 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -98,7 +98,7 @@ #include #endif -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) #include #endif @@ -1449,7 +1449,7 @@ void QGuiApplicationPrivate::init() session_manager = new QSessionManager(q, session_id, session_key); #endif -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) if (qEnvironmentVariableIntValue("QT_LOAD_TESTABILITY") > 0) loadTestability = true; @@ -1469,7 +1469,7 @@ void QGuiApplicationPrivate::init() } #else Q_UNUSED(loadTestability); -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) if (layout_direction == Qt::LayoutDirectionAuto || force_reverse) QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight); diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp index 1e04a673eb..3fcf9014a7 100644 --- a/src/gui/kernel/qplatformintegrationfactory.cpp +++ b/src/gui/kernel/qplatformintegrationfactory.cpp @@ -51,14 +51,14 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive)) -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif // !QT_NO_LIBRARY +#endif // QT_CONFIG(library) QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList ¶mList, int &argc, char **argv, const QString &platformPluginPath) { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) // Try loading the plugin from platformPluginPath first: if (!platformPluginPath.isEmpty()) { QCoreApplication::addLibraryPath(platformPluginPath); @@ -81,7 +81,7 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platfor QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath) { QStringList list; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) if (!platformPluginPath.isEmpty()) { QCoreApplication::addLibraryPath(platformPluginPath); list = directLoader()->keyMap().values(); diff --git a/src/gui/kernel/qplatformthemefactory.cpp b/src/gui/kernel/qplatformthemefactory.cpp index 223d7344e3..447d385abe 100644 --- a/src/gui/kernel/qplatformthemefactory.cpp +++ b/src/gui/kernel/qplatformthemefactory.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QPlatformThemeFactoryInterface_iid, QLatin1String("/platformthemes"), Qt::CaseInsensitive)) -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QPlatformThemeFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) #endif @@ -60,7 +60,7 @@ QPlatformTheme *QPlatformThemeFactory::create(const QString& key, const QString { QStringList paramList = key.split(QLatin1Char(':')); const QString platform = paramList.takeFirst().toLower(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) // Try loading the plugin from platformPluginPath first: if (!platformPluginPath.isEmpty()) { QCoreApplication::addLibraryPath(platformPluginPath); @@ -83,7 +83,7 @@ QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath) { QStringList list; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) if (!platformPluginPath.isEmpty()) { QCoreApplication::addLibraryPath(platformPluginPath); list += directLoader()->keyMap().values(); diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index cedbe19191..98ff49ea31 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -47,7 +47,6 @@ #include #include -#include #include #include diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp index 41038dc8da..1da00813ce 100644 --- a/src/network/kernel/qdnslookup_unix.cpp +++ b/src/network/kernel/qdnslookup_unix.cpp @@ -39,7 +39,9 @@ #include "qdnslookup_p.h" +#if QT_CONFIG(library) #include +#endif #include #include #include @@ -58,7 +60,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) #if defined(Q_OS_OPENBSD) typedef struct __res_state* res_state; @@ -382,6 +384,6 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN return; } -#endif /* ifndef QT_NO_LIBRARY */ +#endif /* QT_CONFIG(library) */ QT_END_NAMESPACE diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index 7af8db73e0..cf08a15f96 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -45,7 +45,9 @@ #include "private/qnativesocketengine_p.h" #include "qiodevice.h" #include +#if QT_CONFIG(library) #include +#endif #include #include #include @@ -93,7 +95,7 @@ static res_state_ptr local_res = 0; static bool resolveLibraryInternal() { -#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_QNX) +#if QT_CONFIG(library) && !defined(Q_OS_QNX) QLibrary lib; #ifdef LIBRESOLV_SO lib.setFileName(QStringLiteral(LIBRESOLV_SO)); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index aca7507d13..644dfdb6a8 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -78,7 +78,6 @@ #include #include #include -#include // for loading the security lib for the CA store #include @@ -530,7 +529,7 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded() resetDefaultCiphers(); resetDefaultEllipticCurves(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) //load symbols needed to receive certificates from system store #if defined(Q_OS_WIN) HINSTANCE hLib = LoadLibraryW(L"Crypt32"); @@ -558,7 +557,7 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded() } } #endif -#endif //QT_NO_LIBRARY +#endif // QT_CONFIG(library) // if on-demand loading was not enabled, load the certs now if (!s_loadRootCertsOnDemand) setDefaultCaCertificates(systemCaCertificates()); diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 2a0d746fde..1b2419ef07 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -58,7 +58,7 @@ #ifdef Q_OS_WIN # include -#else +#elif QT_CONFIG(library) # include #endif #include @@ -125,7 +125,7 @@ void qsslSocketUnresolvedSymbolWarning(const char *functionName) qCWarning(lcSsl, "QSslSocket: cannot call unresolved function %s", functionName); } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) void qsslSocketCannotResolveSymbolWarning(const char *functionName) { qCWarning(lcSsl, "QSslSocket: cannot resolve %s", functionName); @@ -468,12 +468,11 @@ DEFINEFUNC(void, PKCS12_free, PKCS12 *pkcs12, pkcs12, return, DUMMYARG) #if !defined QT_LINKED_OPENSSL -#ifdef QT_NO_LIBRARY +#if !QT_CONFIG(library) bool q_resolveOpenSslSymbols() { - qCWarning(lcSsl, "QSslSocket: unable to resolve symbols. " - "QT_NO_LIBRARY is defined which means runtime resolving of " - "libraries won't work."); + qCWarning(lcSsl, "QSslSocket: unable to resolve symbols. Qt is configured without the " + "'library' feature, which means runtime resolving of libraries won't work."); qCWarning(lcSsl, "Either compile Qt statically or with support for runtime resolving " "of libraries."); return false; @@ -1034,7 +1033,7 @@ bool q_resolveOpenSslSymbols() delete libs.second; return true; } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) #else // !defined QT_LINKED_OPENSSL diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 42baf448ac..a2124974d7 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -65,7 +65,6 @@ #include #include "qcolormap.h" #include "qfile.h" -#include "qlibrary.h" #include #include "qsurfaceformat.h" diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 857a89195c..0b386ededc 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -45,7 +45,6 @@ #include #include "gl2paintengineex/qpaintengineex_opengl2_p.h" -#include #include #include diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp index 863a115b74..3558b929fa 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp @@ -69,16 +69,16 @@ Q_LOGGING_CATEGORY(qLcEglDevDebug, "qt.qpa.egldeviceintegration") Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QEglFSDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive)) -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QEglFSDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) QStringList QEglFSDeviceIntegrationFactory::keys(const QString &pluginPath) { QStringList list; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) if (!pluginPath.isEmpty()) { QCoreApplication::addLibraryPath(pluginPath); list = directLoader()->keyMap().values(); @@ -102,7 +102,7 @@ QStringList QEglFSDeviceIntegrationFactory::keys(const QString &pluginPath) QEglFSDeviceIntegration *QEglFSDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath) { QEglFSDeviceIntegration *integration = Q_NULLPTR; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) if (!pluginPath.isEmpty()) { QCoreApplication::addLibraryPath(pluginPath); integration = qLoadPlugin(directLoader(), key); diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp index 6650ca44ae..d69d969783 100644 --- a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp @@ -50,14 +50,14 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QXcbGlIntegrationFactoryInterface_iid, QLatin1String("/xcbglintegrations"), Qt::CaseInsensitive)) -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QXcbGlIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif // !QT_NO_LIBRARY +#endif // QT_CONFIG(library) QXcbGlIntegration *QXcbGlIntegrationFactory::create(const QString &platform, const QString &pluginPath) { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) // Try loading the plugin from pluginPath first: if (!pluginPath.isEmpty()) { QCoreApplication::addLibraryPath(pluginPath); diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 56b2b1fd23..4e0c73450e 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -38,7 +38,9 @@ ****************************************************************************/ #include +#if QT_CONFIG(library) #include +#endif #include "qxcbwindow.h" #include "qxcbscreen.h" @@ -573,7 +575,7 @@ QFunctionPointer QGLXContext::getProcAddress(const char *procName) if (!glXGetProcAddressARB) #endif { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) extern const QString qt_gl_library_name(); // QLibrary lib(qt_gl_library_name()); QLibrary lib(QLatin1String("GL")); diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 80fe5a2199..d257ab1242 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -43,7 +43,9 @@ #include "qxcbimage.h" #include "qxcbxsettings.h" +#if QT_CONFIG(library) #include +#endif #include #include #include @@ -58,7 +60,7 @@ typedef char *(*PtrXcursorLibraryGetTheme)(void *); typedef int (*PtrXcursorLibrarySetTheme)(void *, const char *); typedef int (*PtrXcursorLibraryGetDefaultSize)(void *); -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) #include enum { XCursorShape = CursorShape @@ -306,7 +308,7 @@ QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen) const char *cursorStr = "cursor"; xcb_open_font(xcb_connection(), cursorFont, strlen(cursorStr), cursorStr); -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) static bool function_ptrs_not_initialized = true; if (function_ptrs_not_initialized) { QLibrary xcursorLib(QLatin1String("Xcursor"), 1); @@ -507,7 +509,7 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) return cursor; } -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) bool updateCursorTheme(void *dpy, const QByteArray &theme) { if (!ptrXcursorLibraryGetTheme || !ptrXcursorLibrarySetTheme) @@ -551,7 +553,7 @@ static xcb_cursor_t loadCursor(void *dpy, int cshape) } return cursor; } -#endif //XCB_USE_XLIB / QT_NO_LIBRARY +#endif // XCB_USE_XLIB / QT_CONFIG(library) xcb_cursor_t QXcbCursor::createFontCursor(int cshape) { @@ -560,7 +562,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape) xcb_cursor_t cursor = XCB_NONE; // Try Xcursor first -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) if (cshape >= 0 && cshape <= Qt::LastCursor) { void *dpy = connection()->xlib_display(); // special case for non-standard dnd-* cursors diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h index c15225f6d2..41ec4dbbf8 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.h +++ b/src/plugins/platforms/xcb/qxcbcursor.h @@ -101,7 +101,7 @@ private: #ifndef QT_NO_CURSOR CursorHash m_cursorHash; #endif -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) static void cursorThemePropertyChanged(QXcbVirtualDesktop *screen, const QByteArray &name, const QVariant &property, diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 7cfb51743d..f1cd48556c 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 798f6ed90b..601dd643fb 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -89,7 +89,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index 18b6f9c3f7..e12203f0a9 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -58,7 +58,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 35b9851cad..5d3a054922 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -65,7 +65,6 @@ #include #endif #ifdef Q_OS_WIN -# include # include #endif diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 7bdebd1593..87b579bb2b 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 0691297497..0feffe0e96 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -893,7 +893,7 @@ void tst_QCoreApplication::threadedEventDelivery() QCOMPARE(receiver.recordedEvents.contains(QEvent::User + 1), eventsReceived); } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) void tst_QCoreApplication::addRemoveLibPaths() { QStringList paths = QCoreApplication::libraryPaths(); diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h index 7fb1bde459..381ff5d497 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h @@ -58,7 +58,7 @@ private slots: void applicationEventFilters_auxThread(); void threadedEventDelivery_data(); void threadedEventDelivery(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) void addRemoveLibPaths(); #endif }; diff --git a/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp index fe6b1ca299..34dc103672 100644 --- a/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp +++ b/tests/auto/corelib/plugin/qfactoryloader/tst_qfactoryloader.cpp @@ -29,11 +29,12 @@ #include #include #include +#include #include #include "plugin1/plugininterface1.h" #include "plugin2/plugininterface2.h" -#ifdef QT_NO_LIBRARY +#if !QT_CONFIG(library) Q_IMPORT_PLUGIN(Plugin1) Q_IMPORT_PLUGIN(Plugin2) #endif @@ -54,7 +55,7 @@ void tst_QFactoryLoader::initTestCase() { const QString binFolder = QFINDTESTDATA(binFolderC); QVERIFY2(!binFolder.isEmpty(), "Unable to locate 'bin' folder"); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QCoreApplication::setLibraryPaths(QStringList(QFileInfo(binFolder).absolutePath())); #endif } diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 4c9916cc52..5467d438a3 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -751,7 +751,9 @@ void tst_QTextBoundaryFinder::isAtSoftHyphen() doTestData(testString, expectedSoftHyphenPositions, QTextBoundaryFinder::Line, QTextBoundaryFinder::SoftHyphen); } +#if QT_CONFIG(library) #include +#endif #define LIBTHAI_MAJOR 0 typedef int (*th_brk_def) (const unsigned char*, int*, size_t); @@ -759,7 +761,7 @@ static th_brk_def th_brk = 0; static bool init_libthai() { -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(library) static bool triedResolve = false; if (!triedResolve) { th_brk = (th_brk_def) QLibrary::resolve("thai", (int)LIBTHAI_MAJOR, "th_brk"); diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index c5117228d3..6b4ddeaba5 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -1084,7 +1084,7 @@ static bool canSendUnixFd(DBusConnection *connection) # if DBUS_VERSION-0 >= 0x010400 can_send_type = dbus_connection_can_send_type; # endif -#elif !defined(QT_NO_LIBRARY) +#elif QT_CONFIG(library) // run-time check if the next functions are available can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); #endif diff --git a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp index d9a4a6c43f..f475e87a2b 100644 --- a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp +++ b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp @@ -90,7 +90,7 @@ static void addFixedTypes() // the library recognizes this as valid type first. // The following function was added for Unix FD support, so if it is // present, so is support for Unix FDs. -# ifndef QT_NO_LIBRARY +# if QT_CONFIG(library) bool supportsUnixFds = qdbus_resolve_conditionally("dbus_connection_can_send_type"); # else bool supportsUnixFds = false; diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index f6d9b71aa2..0c01657956 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -54,7 +54,6 @@ #endif #include -#include #if defined(Q_OS_WIN) #include #else diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 13994e3b02..49095b9625 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -121,7 +121,7 @@ private slots: void testDeleteLater(); void testDeleteLaterProcessEvents(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) void libraryPaths(); void libraryPaths_qt_plugin_path(); void libraryPaths_qt_plugin_path_2(); @@ -885,7 +885,7 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r) return j == r.count(); } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) #define QT_TST_QAPP_DEBUG void tst_QApplication::libraryPaths() { -- cgit v1.2.3 From 8a1880029d080d63d5cf7e02c164925e34a0a718 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 3 Mar 2017 10:31:56 +0100 Subject: Doc: Add macro for embedding YouTube videos This macro adds a \youtube command that embeds a YouTube link into the documentation. The video container scales to a specified percentage of the available horizontal area. It assumes a source aspect ratio of 16:9, but looks acceptable with other ratios. For backends that do not support \n" diff --git a/doc/global/template/style/offline-simple.css b/doc/global/template/style/offline-simple.css index a805b924a3..043e42981d 100644 --- a/doc/global/template/style/offline-simple.css +++ b/doc/global/template/style/offline-simple.css @@ -160,3 +160,7 @@ td#buildversion { .footer p { margin: 0px; } + +.video { + margin: 15px 0 0 15px; +} diff --git a/doc/global/template/style/offline.css b/doc/global/template/style/offline.css index e2081596c9..a65cf48d91 100644 --- a/doc/global/template/style/offline.css +++ b/doc/global/template/style/offline.css @@ -780,3 +780,23 @@ div.multi-column div { margin-right: 4em; width: 24em; } + +.mainContent .video { + width:40%; + max-width:640px; + margin: 15px 0 0 15px; + position:relative; + display:table +} + +.mainContent .video > .vspan { + padding-top:60%; + display:block +} +.mainContent .video iframe { + width:100%; + height:100%; + position:absolute; + top:0; + left:0 +} diff --git a/doc/global/template/style/online.css b/doc/global/template/style/online.css index 3c305f3ddb..2d758f5301 100644 --- a/doc/global/template/style/online.css +++ b/doc/global/template/style/online.css @@ -1721,3 +1721,22 @@ a.qa-mark:target:before { color: #ff0000; } +.mainContent .video { + width:60%; + max-width:640px; + margin: 0.5em 0 1.5em 0.5em; + position:relative; + display:table +} + +.mainContent .video > .vspan { + padding-top:60%; + display:block +} +.mainContent .video iframe { + width:100%; + height:100%; + position:absolute; + top:0; + left:0 +} -- cgit v1.2.3 From c925400bdecd94c7eac65a7e31aa4f8fd010bb5b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 2 Mar 2017 11:29:08 +0100 Subject: qmake: Check for QT_CONFIG(process) in qmakebuiltins The code in question is obviously checking for support of QProcess, not for general bootstrap mode. You can manually disable QProcess, in which case it is still not available after bootstrapping is done. Change-Id: Ia99810b8900621911a31912034358a01af4f18a0 Reviewed-by: Oswald Buddenhagen --- qmake/library/qmakebuiltins.cpp | 6 +++--- qmake/library/qmakeevaluator.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index b30373b596..d61a6c1b15 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -469,7 +469,7 @@ QMakeEvaluator::writeFile(const QString &ctx, const QString &fn, QIODevice::Open return ReturnTrue; } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) void QMakeEvaluator::runProcess(QProcess *proc, const QString &command) const { proc->setWorkingDirectory(currentDirectory()); @@ -490,7 +490,7 @@ void QMakeEvaluator::runProcess(QProcess *proc, const QString &command) const QByteArray QMakeEvaluator::getCommandOutput(const QString &args, int *exitCode) const { QByteArray out; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) QProcess proc; runProcess(&proc, args); *exitCode = (proc.exitStatus() == QProcess::NormalExit) ? proc.exitCode() : -1; @@ -1711,7 +1711,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( #ifdef PROEVALUATOR_FULL if (m_cumulative) // Anything else would be insanity return ReturnFalse; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) QProcess proc; proc.setProcessChannelMode(QProcess::ForwardedChannels); runProcess(&proc, args.at(0).toQString(m_tmp2)); diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h index 544c257f07..5948bd7d14 100644 --- a/qmake/library/qmakeevaluator.h +++ b/qmake/library/qmakeevaluator.h @@ -44,7 +44,7 @@ #include #include #include -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) # include #else # include @@ -237,7 +237,7 @@ public: VisitReturn writeFile(const QString &ctx, const QString &fn, QIODevice::OpenMode mode, bool exe, const QString &contents); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) void runProcess(QProcess *proc, const QString &command) const; #endif QByteArray getCommandOutput(const QString &args, int *exitCode) const; -- cgit v1.2.3 From a170c974a53bde5c6027d3cb25311b819678c546 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 2 Mar 2017 11:31:30 +0100 Subject: Fix building of various examples and tools with -no-feature-process We should not check for platforms, but rather for features. Also, if dbus is available it doesn't automatically mean that QProcess is. Change-Id: I27ef5863fcb107cca1aa47abba95b734962adc33 Reviewed-by: Oswald Buddenhagen --- examples/dbus/dbus.pro | 2 +- examples/network/network.pro | 3 +-- tests/auto/auto.pro | 1 + tests/auto/dbus/dbus.pro | 5 +++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/dbus/dbus.pro b/examples/dbus/dbus.pro index afeb1de0d5..1b2164c4ae 100644 --- a/examples/dbus/dbus.pro +++ b/examples/dbus/dbus.pro @@ -4,7 +4,7 @@ TEMPLATE = subdirs SUBDIRS = listnames \ pingpong -!uikit: SUBDIRS += complexpingpong +qtConfig(process): SUBDIRS += complexpingpong qtHaveModule(widgets) { SUBDIRS += chat \ diff --git a/examples/network/network.pro b/examples/network/network.pro index ed46ad3588..8334165ed9 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -20,8 +20,7 @@ qtHaveModule(widgets) { multicastsender qtConfig(bearermanagement) { - # no QProcess - !vxworks:!qnx:!winrt:!integrity:!uikit: SUBDIRS += network-chat + qtConfig(process): SUBDIRS += network-chat SUBDIRS += \ bearermonitor \ diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index cadd97fb3a..d3c4d470f5 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -23,6 +23,7 @@ uikit: SUBDIRS = corelib gui wince: SUBDIRS -= printsupport cross_compile: SUBDIRS -= tools cmake installed_cmake +else:!qtConfig(process): SUBDIRS -= tools !qtHaveModule(opengl): SUBDIRS -= opengl !qtHaveModule(gui): SUBDIRS -= gui !qtHaveModule(widgets): SUBDIRS -= widgets diff --git a/tests/auto/dbus/dbus.pro b/tests/auto/dbus/dbus.pro index 1769583fca..2c58d7e235 100644 --- a/tests/auto/dbus/dbus.pro +++ b/tests/auto/dbus/dbus.pro @@ -29,3 +29,8 @@ SUBDIRS+=\ !qtConfig(private_tests): SUBDIRS -= \ qdbusmarshall \ +!qtConfig(process): SUBDIRS -= \ + qdbusabstractadaptor \ + qdbusabstractinterface \ + qdbusinterface \ + qdbusmarshall -- cgit v1.2.3 From 6797570a59529b90b5a28923825b56703173fa56 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 27 Feb 2017 12:13:13 +0100 Subject: Fix UB in QFutureInterface: invalid casts from ResultStoreBase to ResultStore<> ResultStore never actually exists, only ResutStoreBase does. So casting to ResultStore and calling its member functions is UB. Put the type dependent function as template member functions within ResultStoreBase and so we don't need QtPrivate::ResultStore anymore. Same goes for the iterator. Change-Id: I739b9d234ba2238977863df77fde3a4471a9abd2 Reviewed-by: Marc Mutz --- src/corelib/thread/qfutureinterface.h | 28 +++---- src/corelib/thread/qresultstore.cpp | 6 ++ src/corelib/thread/qresultstore.h | 64 ++++------------ tests/auto/corelib/thread/qfuture/tst_qfuture.cpp | 87 ++++++++++++---------- .../thread/qresultstore/tst_qresultstore.cpp | 82 ++++++++++---------- 5 files changed, 122 insertions(+), 145 deletions(-) diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index 559d26e231..7b12f51e3e 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -159,7 +159,7 @@ public: ~QFutureInterface() { if (!derefT()) - resultStore().clear(); + resultStoreBase().template clear(); } static QFutureInterface canceledResult() @@ -169,7 +169,7 @@ public: { other.refT(); if (!derefT()) - resultStore().clear(); + resultStoreBase().template clear(); QFutureInterfaceBase::operator=(other); return *this; } @@ -184,11 +184,6 @@ public: inline const T &resultReference(int index) const; inline const T *resultPointer(int index) const; inline QList results(); -private: - QtPrivate::ResultStore &resultStore() - { return static_cast &>(resultStoreBase()); } - const QtPrivate::ResultStore &resultStore() const - { return static_cast &>(resultStoreBase()); } }; template @@ -199,15 +194,14 @@ inline void QFutureInterface::reportResult(const T *result, int index) return; } - QtPrivate::ResultStore &store = resultStore(); - + QtPrivate::ResultStoreBase &store = resultStoreBase(); if (store.filterMode()) { const int resultCountBefore = store.count(); - store.addResult(index, result); + store.addResult(index, result); this->reportResultsReady(resultCountBefore, resultCountBefore + store.count()); } else { - const int insertIndex = store.addResult(index, result); + const int insertIndex = store.addResult(index, result); this->reportResultsReady(insertIndex, insertIndex + 1); } } @@ -226,7 +220,7 @@ inline void QFutureInterface::reportResults(const QVector &_results, int b return; } - QtPrivate::ResultStore &store = resultStore(); + auto &store = resultStoreBase(); if (store.filterMode()) { const int resultCountBefore = store.count(); @@ -250,14 +244,14 @@ template inline const T &QFutureInterface::resultReference(int index) const { QMutexLocker lock(mutex()); - return resultStore().resultAt(index).value(); + return resultStoreBase().resultAt(index).template value(); } template inline const T *QFutureInterface::resultPointer(int index) const { QMutexLocker lock(mutex()); - return resultStore().resultAt(index).pointer(); + return resultStoreBase().resultAt(index).template pointer(); } template @@ -272,9 +266,9 @@ inline QList QFutureInterface::results() QList res; QMutexLocker lock(mutex()); - QtPrivate::ResultIterator it = resultStore().begin(); - while (it != resultStore().end()) { - res.append(it.value()); + QtPrivate::ResultIteratorBase it = resultStoreBase().begin(); + while (it != resultStoreBase().end()) { + res.append(it.value()); ++it; } diff --git a/src/corelib/thread/qresultstore.cpp b/src/corelib/thread/qresultstore.cpp index aa7ec02d6e..9a6fcec678 100644 --- a/src/corelib/thread/qresultstore.cpp +++ b/src/corelib/thread/qresultstore.cpp @@ -98,6 +98,12 @@ bool ResultIteratorBase::canIncrementVectorIndex() const ResultStoreBase::ResultStoreBase() : insertIndex(0), resultCount(0), m_filterMode(false), filteredResults(0) { } +ResultStoreBase::~ResultStoreBase() +{ + // QFutureInterface's dtor must delete the contents of m_results. + Q_ASSERT(m_results.isEmpty()); +} + void ResultStoreBase::setFilterMode(bool enable) { m_filterMode = enable; diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index 56cfcb6ed6..be9f632557 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -93,20 +93,14 @@ public: protected: QMap::const_iterator mapIterator; int m_vectorIndex; -}; - -template -class ResultIterator : public ResultIteratorBase -{ public: - ResultIterator(const ResultIteratorBase &base) - : ResultIteratorBase(base) { } - + template const T &value() const { - return *pointer(); + return *pointer(); } + template const T *pointer() const { if (mapIterator.value().isVector()) @@ -130,7 +124,7 @@ public: ResultIteratorBase resultAt(int index) const; bool contains(int index) const; int count() const; - virtual ~ResultStoreBase() { } + virtual ~ResultStoreBase(); protected: int insertResultItem(int index, ResultItem &resultItem); @@ -147,64 +141,44 @@ protected: QMap pendingResults; int filteredResults; -}; - -template -class ResultStore : public ResultStoreBase -{ public: - ResultStore() { } - - ResultStore(const ResultStoreBase &base) - : ResultStoreBase(base) { } - - int addResult(int index, const T *result) + template + int addResult(int index, const T *result) { if (result == 0) - return ResultStoreBase::addResult(index, result); + return addResult(index, static_cast(nullptr)); else - return ResultStoreBase::addResult(index, new T(*result)); + return addResult(index, static_cast(new T(*result))); } + template int addResults(int index, const QVector *results) { - return ResultStoreBase::addResults(index, new QVector(*results), results->count(), results->count()); + return addResults(index, new QVector(*results), results->count(), results->count()); } + template int addResults(int index, const QVector *results, int totalCount) { if (m_filterMode == true && results->count() != totalCount && 0 == results->count()) - return ResultStoreBase::addResults(index, 0, 0, totalCount); + return addResults(index, 0, 0, totalCount); else - return ResultStoreBase::addResults(index, new QVector(*results), results->count(), totalCount); + return addResults(index, new QVector(*results), results->count(), totalCount); } int addCanceledResult(int index) { - return addResult(index, 0); + return addResult(index, static_cast(nullptr)); } + template int addCanceledResults(int index, int _count) { QVector empty; return addResults(index, &empty, _count); } - ResultIterator begin() const - { - return static_cast >(ResultStoreBase::begin()); - } - - ResultIterator end() const - { - return static_cast >(ResultStoreBase::end()); - } - - ResultIterator resultAt(int index) const - { - return static_cast >(ResultStoreBase::resultAt(index)); - } - + template void clear() { QMap::const_iterator mapIterator = m_results.constBegin(); @@ -218,12 +192,6 @@ public: resultCount = 0; m_results.clear(); } - - ~ResultStore() - { - clear(); - } - }; } // namespace QtPrivate diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp index b8841bb6a3..a546cad225 100644 --- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp +++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp @@ -43,6 +43,11 @@ # undef interface #endif +struct ResultStoreInt : QtPrivate::ResultStoreBase +{ + ~ResultStoreInt() { clear(); } +}; + class tst_QFuture: public QObject { Q_OBJECT @@ -78,7 +83,7 @@ void tst_QFuture::resultStore() int int2 = 2; { - QtPrivate::ResultStore store; + ResultStoreInt store; QCOMPARE(store.begin(), store.end()); QCOMPARE(store.resultAt(0), store.end()); QCOMPARE(store.resultAt(1), store.end()); @@ -86,9 +91,9 @@ void tst_QFuture::resultStore() { - QtPrivate::ResultStoreBase store; - store.addResult(-1, &int0); // note to self: adding a pointer to the stack here is ok since - store.addResult(1, &int1); // ResultStoreBase does not take ownership, only ResultStore<> does. + ResultStoreInt store; + store.addResult(-1, &int0); + store.addResult(1, &int1); QtPrivate::ResultIteratorBase it = store.begin(); QCOMPARE(it.resultIndex(), 0); QVERIFY(it == store.begin()); @@ -108,9 +113,9 @@ void tst_QFuture::resultStore() QVector vec1 = QVector() << 4 << 5; { - QtPrivate::ResultStoreBase store; - store.addResults(-1, &vec0, 2, 2); - store.addResults(-1, &vec1, 2, 2); + ResultStoreInt store; + store.addResults(-1, &vec0, 2); + store.addResults(-1, &vec1, 2); QtPrivate::ResultIteratorBase it = store.begin(); QCOMPARE(it.resultIndex(), 0); QCOMPARE(it, store.begin()); @@ -131,9 +136,9 @@ void tst_QFuture::resultStore() QCOMPARE(it, store.end()); } { - QtPrivate::ResultStoreBase store; + ResultStoreInt store; store.addResult(-1, &int0); - store.addResults(-1, &vec1, 2, 2); + store.addResults(-1, &vec1, 2); store.addResult(-1, &int1); QtPrivate::ResultIteratorBase it = store.begin(); @@ -162,7 +167,7 @@ void tst_QFuture::resultStore() QCOMPARE(store.resultAt(4), store.end()); } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResult(-1, &int0); store.addResults(-1, &vec0); store.addResult(-1, &int1); @@ -186,36 +191,36 @@ void tst_QFuture::resultStore() ++it; QVERIFY(it == store.end()); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(3).value(), int1); + QCOMPARE(store.resultAt(0).value(), int0); + QCOMPARE(store.resultAt(1).value(), vec0[0]); + QCOMPARE(store.resultAt(2).value(), vec0[1]); + QCOMPARE(store.resultAt(3).value(), int1); } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResult(-1, &int0); store.addResults(-1, &vec0); store.addResult(200, &int1); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(200).value(), int1); + QCOMPARE(store.resultAt(0).value(), int0); + QCOMPARE(store.resultAt(1).value(), vec0[0]); + QCOMPARE(store.resultAt(2).value(), vec0[1]); + QCOMPARE(store.resultAt(200).value(), int1); } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResult(1, &int1); store.addResult(0, &int0); store.addResult(-1, &int2); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), int1); - QCOMPARE(store.resultAt(2).value(), int2); + QCOMPARE(store.resultAt(0).value(), int0); + QCOMPARE(store.resultAt(1).value(), int1); + QCOMPARE(store.resultAt(2).value(), int2); } { - QtPrivate::ResultStore store; + ResultStoreInt store; QCOMPARE(store.contains(0), false); QCOMPARE(store.contains(1), false); QCOMPARE(store.contains(INT_MAX), false); @@ -223,7 +228,7 @@ void tst_QFuture::resultStore() { // Test filter mode, where "gaps" in the result array aren't allowed. - QtPrivate::ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(0, &int0); @@ -257,7 +262,7 @@ void tst_QFuture::resultStore() { // test canceled results - QtPrivate::ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(0, &int0); @@ -294,7 +299,7 @@ void tst_QFuture::resultStore() { // test addResult return value - QtPrivate::ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(0, &int0); @@ -340,7 +345,7 @@ void tst_QFuture::resultStore() { // test resultCount in non-filtered mode. It should always be possible // to iterate through the results 0 to resultCount. - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResult(0, &int0); QCOMPARE(store.count(), 1); @@ -354,7 +359,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResult(2, &int0); QCOMPARE(store.count(), 0); @@ -366,7 +371,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResults(2, &vec1); QCOMPARE(store.count(), 0); @@ -378,7 +383,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResults(2, &vec1); QCOMPARE(store.count(), 0); @@ -386,7 +391,7 @@ void tst_QFuture::resultStore() QCOMPARE(store.count(), 4); } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResults(3, &vec1); QCOMPARE(store.count(), 0); @@ -398,7 +403,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); @@ -411,22 +416,22 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); - store.addCanceledResults(0, 3); + store.addCanceledResults(0, 3); QCOMPARE(store.count(), 2); } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); - store.addCanceledResults(0, 3); + store.addCanceledResults(0, 3); QCOMPARE(store.count(), 2); // results at 3 and 4 become available at index 0, 1 store.addResult(5, &int0); @@ -434,7 +439,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.addResult(1, &int0); store.addResult(3, &int0); store.addResults(6, &vec0); @@ -449,7 +454,7 @@ void tst_QFuture::resultStore() } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(1, &int0); store.addResult(3, &int0); @@ -465,7 +470,7 @@ void tst_QFuture::resultStore() store.addCanceledResult(0); store.addCanceledResult(2); - store.addCanceledResults(4, 2); + store.addCanceledResults(4, 2); QCOMPARE(store.contains(0), true); QCOMPARE(store.contains(1), true); @@ -477,7 +482,7 @@ void tst_QFuture::resultStore() QCOMPARE(store.contains(7), false); } { - QtPrivate::ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addCanceledResult(0); QCOMPARE(store.contains(0), false); diff --git a/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp b/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp index 3626b8db33..fba617e34d 100644 --- a/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp +++ b/tests/auto/corelib/thread/qresultstore/tst_qresultstore.cpp @@ -32,6 +32,11 @@ using namespace QtPrivate; +struct ResultStoreInt : ResultStoreBase +{ + ~ResultStoreInt() { clear(); } +}; + class tst_QtConcurrentResultStore : public QObject { Q_OBJECT @@ -67,20 +72,20 @@ void tst_QtConcurrentResultStore::init() void tst_QtConcurrentResultStore::construction() { - ResultStore store; + ResultStoreBase store; QCOMPARE(store.count(), 0); } void tst_QtConcurrentResultStore::iterators() { { - ResultStore store; + ResultStoreBase store; QCOMPARE(store.begin(), store.end()); QCOMPARE(store.resultAt(0), store.end()); QCOMPARE(store.resultAt(1), store.end()); } { - ResultStoreBase storebase; + ResultStoreInt storebase; storebase.addResult(-1, &int0); // note to self: adding a pointer to the stack here is ok since storebase.addResult(1, &int1); // ResultStoreBase does not take ownership, only ResultStore<> does. ResultIteratorBase it = storebase.begin(); @@ -103,7 +108,7 @@ void tst_QtConcurrentResultStore::addResult() { { // test addResult return value - ResultStore store; + ResultStoreInt store; store.setFilterMode(true); QCOMPARE(store.addResult(0, &int0), 0); @@ -149,10 +154,9 @@ void tst_QtConcurrentResultStore::addResult() void tst_QtConcurrentResultStore::addResults() { - - ResultStoreBase store; - store.addResults(-1, &vec0, 2, 2); - store.addResults(-1, &vec1, 2, 2); + ResultStoreInt store; + store.addResults(-1, &vec0); + store.addResults(-1, &vec1); ResultIteratorBase it = store.begin(); QCOMPARE(it.resultIndex(), 0); QCOMPARE(it, store.begin()); @@ -175,7 +179,7 @@ void tst_QtConcurrentResultStore::addResults() void tst_QtConcurrentResultStore::resultIndex() { - ResultStore store; + ResultStoreInt store; store.addResult(-1, &int0); store.addResults(-1, &vec0); store.addResult(-1, &int1); @@ -199,41 +203,41 @@ void tst_QtConcurrentResultStore::resultIndex() ++it; QVERIFY(it == store.end()); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(3).value(), int1); + QCOMPARE(store.resultAt(0).value(), int0); + QCOMPARE(store.resultAt(1).value(), vec0[0]); + QCOMPARE(store.resultAt(2).value(), vec0[1]); + QCOMPARE(store.resultAt(3).value(), int1); } void tst_QtConcurrentResultStore::resultAt() { { - ResultStore store; + ResultStoreInt store; store.addResult(-1, &int0); store.addResults(-1, &vec0); store.addResult(200, &int1); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), vec0[0]); - QCOMPARE(store.resultAt(2).value(), vec0[1]); - QCOMPARE(store.resultAt(200).value(), int1); + QCOMPARE(store.resultAt(0).value(), int0); + QCOMPARE(store.resultAt(1).value(), vec0[0]); + QCOMPARE(store.resultAt(2).value(), vec0[1]); + QCOMPARE(store.resultAt(200).value(), int1); } { - ResultStore store; + ResultStoreInt store; store.addResult(1, &int1); store.addResult(0, &int0); store.addResult(-1, &int2); - QCOMPARE(store.resultAt(0).value(), int0); - QCOMPARE(store.resultAt(1).value(), int1); - QCOMPARE(store.resultAt(2).value(), int2); + QCOMPARE(store.resultAt(0).value(), int0); + QCOMPARE(store.resultAt(1).value(), int1); + QCOMPARE(store.resultAt(2).value(), int2); } } void tst_QtConcurrentResultStore::contains() { { - ResultStore store; + ResultStoreInt store; QCOMPARE(store.contains(0), false); QCOMPARE(store.contains(1), false); QCOMPARE(store.contains(INT_MAX), false); @@ -245,7 +249,7 @@ void tst_QtConcurrentResultStore::contains() QVERIFY(store.contains(int2)); } { - ResultStore store; + ResultStoreInt store; store.addResult(1, &int0); store.addResult(3, &int0); store.addResults(6, &vec0); @@ -260,7 +264,7 @@ void tst_QtConcurrentResultStore::contains() } { - ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(1, &int0); store.addResult(3, &int0); @@ -276,7 +280,7 @@ void tst_QtConcurrentResultStore::contains() store.addCanceledResult(0); store.addCanceledResult(2); - store.addCanceledResults(4, 2); + store.addCanceledResults(4, 2); QCOMPARE(store.contains(0), true); QCOMPARE(store.contains(1), true); @@ -288,7 +292,7 @@ void tst_QtConcurrentResultStore::contains() QCOMPARE(store.contains(7), false); } { - ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addCanceledResult(0); QCOMPARE(store.contains(0), false); @@ -302,7 +306,7 @@ void tst_QtConcurrentResultStore::contains() void tst_QtConcurrentResultStore::filterMode() { // Test filter mode, where "gaps" in the result array aren't allowed. - ResultStore store; + ResultStoreInt store; QCOMPARE(store.filterMode(), false); store.setFilterMode(true); QVERIFY(store.filterMode()); @@ -339,7 +343,7 @@ void tst_QtConcurrentResultStore::filterMode() void tst_QtConcurrentResultStore::addCanceledResult() { // test canceled results - ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResult(0, &int0); @@ -379,7 +383,7 @@ void tst_QtConcurrentResultStore::count() { // test resultCount in non-filtered mode. It should always be possible // to iterate through the results 0 to resultCount. - ResultStore store; + ResultStoreInt store; store.addResult(0, &int0); QCOMPARE(store.count(), 1); @@ -393,7 +397,7 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore store; + ResultStoreInt store; store.addResult(2, &int0); QCOMPARE(store.count(), 0); @@ -405,7 +409,7 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore store; + ResultStoreInt store; store.addResults(2, &vec1); QCOMPARE(store.count(), 0); @@ -417,7 +421,7 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore store; + ResultStoreInt store; store.addResults(2, &vec1); QCOMPARE(store.count(), 0); @@ -425,7 +429,7 @@ void tst_QtConcurrentResultStore::count() QCOMPARE(store.count(), 4); } { - ResultStore store; + ResultStoreInt store; store.addResults(3, &vec1); QCOMPARE(store.count(), 0); @@ -437,7 +441,7 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); @@ -450,22 +454,22 @@ void tst_QtConcurrentResultStore::count() } { - ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); - store.addCanceledResults(0, 3); + store.addCanceledResults(0, 3); QCOMPARE(store.count(), 2); } { - ResultStore store; + ResultStoreInt store; store.setFilterMode(true); store.addResults(3, &vec1); QCOMPARE(store.count(), 0); - store.addCanceledResults(0, 3); + store.addCanceledResults(0, 3); QCOMPARE(store.count(), 2); // results at 3 and 4 become available at index 0, 1 store.addResult(5, &int0); -- cgit v1.2.3 From 473248df1458c34c73e63f14f9831104b266bd4a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 27 Feb 2017 13:37:09 +0100 Subject: put load(qt_plugin) at end of project file amends a28364bc1. Change-Id: I8e6044abcbfffde8688d87cd3aa722c0c362534c Reviewed-by: Andy Nichols --- src/plugins/platforms/vnc/vnc.pro | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index 3cd7e9b160..1fa682303f 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -1,10 +1,5 @@ TARGET = qvnc -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QVncIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += \ core-private network gui-private \ service_support-private theme_support-private fb_support-private \ @@ -29,3 +24,8 @@ HEADERS = \ qvncclient.h OTHER_FILES += vnc.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QVncIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) -- cgit v1.2.3 From c0af8cef2ff67e4883b8491224b30a2c3d1f7b17 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 16 Feb 2017 22:18:56 -0800 Subject: Don't pass -headerpad_max_install_names when using Bitcode It is ignored (and is unnecessary to begin with) in that case, and emits an annoying warning which this patch silences. Change-Id: I6059969724b203d6e0e2eea81ad3e3e8f8d536d6 Reviewed-by: Oswald Buddenhagen --- mkspecs/common/gcc-base-mac.conf | 2 -- mkspecs/darwin-g++/qmake.conf | 1 - mkspecs/features/mac/default_post.prf | 7 +++++++ mkspecs/macx-icc/qmake.conf | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mkspecs/common/gcc-base-mac.conf b/mkspecs/common/gcc-base-mac.conf index e9bf780ec1..b36bbfb81a 100644 --- a/mkspecs/common/gcc-base-mac.conf +++ b/mkspecs/common/gcc-base-mac.conf @@ -12,8 +12,6 @@ include(gcc-base.conf) QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__=4 __APPLE_CC__ -QMAKE_LFLAGS += -headerpad_max_install_names - QMAKE_LFLAGS_SHLIB += -single_module -dynamiclib QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB QMAKE_LFLAGS_INCREMENTAL += -undefined suppress -flat_namespace diff --git a/mkspecs/darwin-g++/qmake.conf b/mkspecs/darwin-g++/qmake.conf index 09c55456ec..feef711625 100644 --- a/mkspecs/darwin-g++/qmake.conf +++ b/mkspecs/darwin-g++/qmake.conf @@ -56,7 +56,6 @@ QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib QMAKE_LINK = c++ QMAKE_LINK_SHLIB = c++ -QMAKE_LFLAGS += -headerpad_max_install_names QMAKE_LFLAGS = QMAKE_LFLAGS_RELEASE = QMAKE_LFLAGS_DEBUG = diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index d93c6ed27c..f39e610e88 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -24,6 +24,13 @@ qt { } } +# Don't pass -headerpad_max_install_names when using Bitcode. +# In that case the linker emits a warning stating that the flag is ignored when +# used with bitcode, for reasons that cannot be determined (rdar://problem/20748962). +# Using this flag is also unnecessary in practice on UIKit platforms since they +# are sandboxed, and only UIKit platforms support bitcode to begin with. +!bitcode: QMAKE_LFLAGS += -headerpad_max_install_names + macx-xcode { !isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) { debug_information_format.name = DEBUG_INFORMATION_FORMAT diff --git a/mkspecs/macx-icc/qmake.conf b/mkspecs/macx-icc/qmake.conf index 9c309647a6..a103536521 100644 --- a/mkspecs/macx-icc/qmake.conf +++ b/mkspecs/macx-icc/qmake.conf @@ -64,7 +64,7 @@ QMAKE_CXXFLAGS_DISABLE_LTCG = $$QMAKE_CFLAGS_DISABLE_LTCG QMAKE_LINK = icpc QMAKE_LINK_SHLIB = icpc -QMAKE_LFLAGS = -headerpad_max_install_names +QMAKE_LFLAGS = QMAKE_LFLAGS_RELEASE = QMAKE_LFLAGS_DEBUG = QMAKE_LFLAGS_SHLIB = -single_module -dynamiclib -- cgit v1.2.3 From 7eb11df19e0c0c52b877bc9ded357763bc014316 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 23 Feb 2017 15:49:38 +0100 Subject: Don't call releaseKey a second time if the insertion fails When the insertion into the cache fails then it will delete the entry for us which already calls releaseKey(). So we should not call it a second time. Task-number: QTBUG-58259 Change-Id: I816c6f29ef97fe3a245f145c4faf1e0649f72dc5 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Friedemann Kleint --- src/gui/image/qpixmapcache.cpp | 7 ------- tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp | 11 +++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 73448943e1..625e145647 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -341,7 +341,6 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) } else { //Insertion failed we released the new allocated key cacheKeys.remove(key); - releaseKey(cacheKey); } return success; } @@ -355,9 +354,6 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) theid = startTimer(flush_time); t = false; } - } else { - //Insertion failed we released the key and return an invalid one - releaseKey(cacheKey); } return cacheKey; } @@ -377,9 +373,6 @@ bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int t = false; } const_cast(key) = cacheKey; - } else { - //Insertion failed we released the key - releaseKey(cacheKey); } return success; } diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp index 8dcf104035..8a2a35f86c 100644 --- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp @@ -56,6 +56,7 @@ private slots: void pixmapKey(); void noLeak(); void strictCacheLimit(); + void noCrashOnLargeInsert(); }; static QPixmapCache::KeyData* getPrivate(QPixmapCache::Key &key) @@ -525,5 +526,15 @@ void tst_QPixmapCache::strictCacheLimit() QVERIFY(QPixmapCache::totalUsed() <= limit); } +void tst_QPixmapCache::noCrashOnLargeInsert() +{ + QPixmapCache::clear(); + QPixmapCache::setCacheLimit(100); + QPixmap pixmap(500, 500); + pixmap.fill(Qt::transparent); + QPixmapCache::insert("test", pixmap); + QVERIFY(true); // no crash +} + QTEST_MAIN(tst_QPixmapCache) #include "tst_qpixmapcache.moc" -- cgit v1.2.3 From e7295c959b73cec09e36d3703d5619e8e7aa5fb1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 16 Dec 2016 12:56:23 -0800 Subject: Add -Wfloat-equal to Qt's header clean check Task-number: QTBUG-57649 Change-Id: I15b62e0f9cec482fbb40fffd1490d802c54bf0fe Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- mkspecs/features/qt_module_headers.prf | 2 +- src/corelib/tools/qrect.h | 6 ++++++ src/gui/math3d/qmatrix4x4.h | 5 +++++ src/gui/math3d/qquaternion.h | 15 +++++++++------ src/gui/math3d/qvector2d.h | 4 ++++ src/gui/math3d/qvector3d.h | 4 ++++ src/gui/math3d/qvector4d.h | 4 ++++ src/gui/painting/qtransform.h | 6 ++++++ 8 files changed, 39 insertions(+), 7 deletions(-) diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf index a0be15c4a0..0e04b46448 100644 --- a/mkspecs/features/qt_module_headers.prf +++ b/mkspecs/features/qt_module_headers.prf @@ -182,7 +182,7 @@ headersclean:!internal_module { # Turn on some extra warnings not found in -Wall -Wextra. # Common to GCC, Clang and ICC (and other compilers that masquerade as GCC): hcleanFLAGS = -Wall -Wextra -Werror \ - -Woverloaded-virtual -Wshadow -Wundef \ + -Woverloaded-virtual -Wshadow -Wundef -Wfloat-equal \ -Wnon-virtual-dtor -Wpointer-arith -Wformat-security \ -Wno-long-long -Wno-variadic-macros -pedantic-errors diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index f973cf3494..4030cccbd5 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -662,12 +662,18 @@ Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) Q_DECL_NOTHROW { } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") + Q_DECL_CONSTEXPR inline bool QRectF::isNull() const Q_DECL_NOTHROW { return w == 0. && h == 0.; } Q_DECL_CONSTEXPR inline bool QRectF::isEmpty() const Q_DECL_NOTHROW { return w <= 0. || h <= 0.; } +QT_WARNING_POP + Q_DECL_CONSTEXPR inline bool QRectF::isValid() const Q_DECL_NOTHROW { return w > 0. && h > 0.; } diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index e143884f9d..aca685920e 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -212,6 +212,9 @@ private: friend class QGraphicsRotation; }; +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") Q_DECLARE_TYPEINFO(QMatrix4x4, Q_MOVABLE_TYPE); inline QMatrix4x4::QMatrix4x4 @@ -1093,6 +1096,8 @@ inline void QMatrix4x4::viewport(const QRectF &rect) viewport(rect.x(), rect.y(), rect.width(), rect.height()); } +QT_WARNING_POP + #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QMatrix4x4 &m); #endif diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index 808e0ee6d7..eff427117f 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -168,7 +168,9 @@ inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {} inline QQuaternion::QQuaternion(float aScalar, float xpos, float ypos, float zpos) : wp(aScalar), xp(xpos), yp(ypos), zp(zpos) {} - +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") inline bool QQuaternion::isNull() const { return wp == 0.0f && xp == 0.0f && yp == 0.0f && zp == 0.0f; @@ -179,6 +181,12 @@ inline bool QQuaternion::isIdentity() const return wp == 1.0f && xp == 0.0f && yp == 0.0f && zp == 0.0f; } +inline bool operator==(const QQuaternion &q1, const QQuaternion &q2) +{ + return q1.wp == q2.wp && q1.xp == q2.xp && q1.yp == q2.yp && q1.zp == q2.zp; +} +QT_WARNING_POP + inline float QQuaternion::x() const { return xp; } inline float QQuaternion::y() const { return yp; } inline float QQuaternion::z() const { return zp; } @@ -277,11 +285,6 @@ inline QQuaternion &QQuaternion::operator/=(float divisor) return *this; } -inline bool operator==(const QQuaternion &q1, const QQuaternion &q2) -{ - return q1.wp == q2.wp && q1.xp == q2.xp && q1.yp == q2.yp && q1.zp == q2.zp; -} - inline bool operator!=(const QQuaternion &q1, const QQuaternion &q2) { return !operator==(q1, q2); diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index d2724c9498..bdb56c9c1f 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -204,6 +204,9 @@ inline QVector2D &QVector2D::operator/=(const QVector2D &vector) return *this; } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") Q_DECL_CONSTEXPR inline bool operator==(const QVector2D &v1, const QVector2D &v2) { return v1.xp == v2.xp && v1.yp == v2.yp; @@ -213,6 +216,7 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QVector2D &v1, const QVector2D &v2 { return v1.xp != v2.xp || v1.yp != v2.yp; } +QT_WARNING_POP Q_DECL_CONSTEXPR inline const QVector2D operator+(const QVector2D &v1, const QVector2D &v2) { diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h index c1d881a735..a728fd76bf 100644 --- a/src/gui/math3d/qvector3d.h +++ b/src/gui/math3d/qvector3d.h @@ -229,6 +229,9 @@ inline QVector3D &QVector3D::operator/=(const QVector3D &vector) return *this; } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") Q_DECL_CONSTEXPR inline bool operator==(const QVector3D &v1, const QVector3D &v2) { return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp; @@ -238,6 +241,7 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QVector3D &v1, const QVector3D &v2 { return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp; } +QT_WARNING_POP Q_DECL_CONSTEXPR inline const QVector3D operator+(const QVector3D &v1, const QVector3D &v2) { diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 9387e8d187..f63b2f141b 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -229,6 +229,9 @@ inline QVector4D &QVector4D::operator/=(const QVector4D &vector) return *this; } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") Q_DECL_CONSTEXPR inline bool operator==(const QVector4D &v1, const QVector4D &v2) { return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp && v1.wp == v2.wp; @@ -238,6 +241,7 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QVector4D &v1, const QVector4D &v2 { return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp || v1.wp != v2.wp; } +QT_WARNING_POP Q_DECL_CONSTEXPR inline const QVector4D operator+(const QVector4D &v1, const QVector4D &v2) { diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 2aea19eca0..5ca1d46982 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -291,6 +291,10 @@ inline qreal QTransform::dy() const return affine._dy; } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") + inline QTransform &QTransform::operator*=(qreal num) { if (num == 1.) @@ -348,6 +352,8 @@ inline QTransform &QTransform::operator-=(qreal num) return *this; } +QT_WARNING_POP + inline bool qFuzzyCompare(const QTransform& t1, const QTransform& t2) { return qFuzzyCompare(t1.m11(), t2.m11()) -- cgit v1.2.3 From 895b4e6f89d4a9c4cae8af6c129e85c6c0d29f6c Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Sat, 4 Mar 2017 19:11:17 +0200 Subject: Enable QStyleHints::useHoverEffects for KDE and other unix systems By default, it enabled only for Gnome Task-number: QTBUG-59298 Change-Id: Ib44f52b3175ed1904f24ec9e21f00ea3f3334287 Reviewed-by: J-P Nurmi --- src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 1e1b1af4b5..4eefcace0f 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -225,6 +225,8 @@ QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const } case QPlatformTheme::KeyboardScheme: return QVariant(int(X11KeyboardScheme)); + case QPlatformTheme::UiEffects: + return QVariant(int(HoverEffect)); default: break; } @@ -540,6 +542,8 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const return QVariant(d->singleClick); case QPlatformTheme::WheelScrollLines: return QVariant(d->wheelScrollLines); + case QPlatformTheme::UiEffects: + return QVariant(int(HoverEffect)); default: break; } -- cgit v1.2.3 From 9e933de7f2f83946cc3926e4ea5ae0d8e4ce93bb Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Tue, 7 Mar 2017 21:52:58 +0100 Subject: Example: fix memory leak in relationnaltablemodel example The example creates a view on the heap but doesn't delete it on application end. This patch uses a QScopedPointer to fix that. Change-Id: I3b0c8589999d243c193bd02e1470c03eabfabe40 Reviewed-by: Sze Howe Koh --- examples/sql/relationaltablemodel/relationaltablemodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sql/relationaltablemodel/relationaltablemodel.cpp b/examples/sql/relationaltablemodel/relationaltablemodel.cpp index c8faece1dd..5292256cd9 100644 --- a/examples/sql/relationaltablemodel/relationaltablemodel.cpp +++ b/examples/sql/relationaltablemodel/relationaltablemodel.cpp @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) initializeModel(&model); - QTableView *view = createView(QObject::tr("Relational Table Model"), &model); + QScopedPointer view(createView(QObject::tr("Relational Table Model"), &model)); view->show(); return app.exec(); -- cgit v1.2.3 From 2d81968c3bbab42a03e0e64f4de92fea10968424 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 23:15:21 +0100 Subject: Example: migrate treemodelcompleter example to use QRegularExpression Update the treemodelcompleter example to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: I9fa91ca6e847603de37019e4ca86fc69a51a3772 Reviewed-by: Sze Howe Koh --- examples/widgets/tools/treemodelcompleter/mainwindow.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp index c00e058fc4..4aabb04023 100644 --- a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp +++ b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp @@ -194,16 +194,17 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString& fileName) if (line.isEmpty() || trimmedLine.isEmpty()) continue; - QRegExp re("^\\s+"); - int nonws = re.indexIn(line); + QRegularExpression re("^\\s+"); + QRegularExpressionMatch match = re.match(line); + int nonws = match.capturedStart(); int level = 0; if (nonws == -1) { level = 0; } else { if (line.startsWith("\t")) { - level = re.cap(0).length(); + level = match.capturedLength(); } else { - level = re.cap(0).length()/4; + level = match.capturedLength()/4; } } -- cgit v1.2.3 From 3a1f4b186d8ce79717da37f808ff9a4b3e949d9c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 7 Mar 2017 17:48:28 +0100 Subject: Stop trying to discover the system timer resolution on Windows Let's take the beginning of the description: WaitForSingleObjectEx can be up to 16 milliseconds early. This is proven by the fact that there are tests doing: wait(waitTime); QVERIFY(timer.elapsed() >= waitTime - systemTimersResolution); and failing. Task-number: QTBUG-59337 Change-Id: Iae839f6a131a4f0784bffffd14a9a79523d69d94 Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/thread/qmutex/tst_qmutex.cpp | 61 ++++--------------------- 1 file changed, 10 insertions(+), 51 deletions(-) diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index bf778e9fd1..3e4a6eb7e7 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -36,11 +36,6 @@ #include #include -#ifdef Q_OS_WIN -#include -#include -#endif - class tst_QMutex : public QObject { Q_OBJECT @@ -54,7 +49,6 @@ public: Q_ENUM(TimeUnit); private slots: - void initTestCase(); void convertToMilliseconds_data(); void convertToMilliseconds(); void tryLock_non_recursive(); @@ -70,8 +64,6 @@ private slots: void tryLockNegative_data(); void tryLockNegative(); void moreStress(); -private: - void initializeSystemTimersResolution(); }; static const int iterations = 100; @@ -81,57 +73,24 @@ QMutex normalMutex, recursiveMutex(QMutex::Recursive); QSemaphore testsTurn; QSemaphore threadsTurn; -enum { waitTime = 100 }; -uint systemTimersResolution = 1; - -#if QT_HAS_INCLUDE() -static Q_CONSTEXPR std::chrono::milliseconds waitTimeAsDuration(waitTime); -#endif - /* Depending on the OS, tryWaits may return early than expected because of the resolution of the underlying timer is too coarse. E.g.: on Windows WaitForSingleObjectEx does *not* use high resolution multimedia timers, and it's actually very coarse, about 16msec by default. - - Try to find out the timer resolution in here, so that the tryLock tests can - actually take into account early wakes. */ -void tst_QMutex::initializeSystemTimersResolution() -{ +enum { #ifdef Q_OS_WIN - // according to MSDN, Windows can default up to this - systemTimersResolution = 16; - - // private API. There's no way on Windows to otherwise know the - // actual resolution of the application's timers (you can only set it) - // cf. https://stackoverflow.com/questions/7685762/windows-7-timing-functions-how-to-use-getsystemtimeadjustment-correctly/11743614#11743614 - typedef NTSTATUS (NTAPI *NtQueryTimerResolutionType)(OUT PULONG MinimumResolution, - OUT PULONG MaximumResolution, - OUT PULONG ActualResolution); - - const NtQueryTimerResolutionType NtQueryTimerResolutionPtr = - reinterpret_cast(QSystemLibrary::resolve(QStringLiteral("ntdll"), "NtQueryTimerResolution")); - - if (!NtQueryTimerResolutionPtr) - return; - - ULONG minimumResolution; - ULONG maximumResolution; - ULONG actualResolution; - - if (!NtQueryTimerResolutionPtr(&minimumResolution, &maximumResolution, &actualResolution)) { - // the result is in 100ns units => adjust to msec - const double actualResolutionMsec = actualResolution / 10000.0; - systemTimersResolution = static_cast(std::ceil(actualResolutionMsec)); - } -#endif // Q_OS_WIN -} + systemTimersResolution = 16, +#else + systemTimersResolution = 1, +#endif + waitTime = 100 +}; -void tst_QMutex::initTestCase() -{ - initializeSystemTimersResolution(); -} +#if QT_HAS_INCLUDE() +static Q_CONSTEXPR std::chrono::milliseconds waitTimeAsDuration(waitTime); +#endif void tst_QMutex::convertToMilliseconds_data() { -- cgit v1.2.3 From 63a39927a098aeb60a03b77361502b5be7659f1d Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Fri, 10 Mar 2017 13:52:29 -0800 Subject: QMacStyle: fix QTabBar tab size A few small visual issues were introduced during recent QTabBar restyling (see 175f33ed855b0a8a30daafacd4f48fa3f8e76a9b) Change-Id: Ifab8b9f24e2cad6e1a827b1061471882a1bc9f5e Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 0d2203f843..ae536b6bd9 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1076,11 +1076,6 @@ void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widg if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth) verticalShift = -verticalShift; tr.adjust(hpadding, verticalShift - vpadding, horizontalShift - hpadding, vpadding); - const bool selected = opt->state & QStyle::State_Selected; - if (selected) { - tr.setTop(tr.top() - verticalShift); - tr.setRight(tr.right() - horizontalShift); - } // left widget if (!opt->leftButtonSize.isEmpty()) { @@ -2488,7 +2483,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW case QAquaSizeUnknown: const QStyleOptionTab *tb = qstyleoption_cast(opt); if (tb && tb->documentMode) - ret = 24; + ret = 30; else ret = QCommonStyle::pixelMetric(metric, opt, widget); break; @@ -6610,7 +6605,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = sz.transposed(); int defaultTabHeight; int extraHSpace = proxy()->pixelMetric(PM_TabBarTabHSpace, tab, widget); - int extraVSpace = proxy()->pixelMetric(PM_TabBarTabVSpace, tab, widget); QFontMetrics fm = opt->fontMetrics; switch (AquaSize) { case QAquaSizeUnknown: @@ -6630,13 +6624,13 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, bool setWidth = false; if (differentFont || !tab->icon.isNull()) { sz.rheight() = qMax(defaultTabHeight, sz.height()); - sz.rwidth() += extraHSpace; } else { QSize textSize = fm.size(Qt::TextShowMnemonic, tab->text); sz.rheight() = qMax(defaultTabHeight, textSize.height()); - sz.rwidth() = textSize.width() + extraVSpace; + sz.rwidth() = textSize.width(); setWidth = true; } + sz.rwidth() += extraHSpace; if (vertTabs) sz = sz.transposed(); -- cgit v1.2.3 From 75f5e2bef2ab942f89d5d025ecd45ee4d18e3d57 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 10 Mar 2017 15:27:40 +0100 Subject: Deprecate QString::null It's a Qt 3 compatibility vehicle, and as such inherits the now-alien property to distinguish empty and null strings. Particularly worrisome is the following asymmetry: QString("") == QString::null // false QString("") == QString(QString::null) // true Instead of fixing this behavior, recognize that people might use it as a weird way to call isNull(), albeit one that once was idiomatic, and simply deprecate everything that deals with QString::null. [ChangeLog][QtCore][QString] QString::null is now deprecated. When used to construct a QString, use QString() instead. When used to compare to a QString, replace with QString::isNull(). Change-Id: I9f7e84a92522c75666da15f49324c500ae93af42 Reviewed-by: Thiago Macieira Reviewed-by: Anton Kudryavtsev --- src/corelib/tools/qstring.cpp | 2 ++ src/corelib/tools/qstring.h | 10 +++++++++- src/widgets/accessible/simplewidgets.cpp | 2 +- src/widgets/widgets/qmdisubwindow.cpp | 4 ++-- tests/auto/corelib/io/qfile/tst_qfile.cpp | 2 +- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 4 ++-- tests/auto/network/access/qftp/tst_qftp.cpp | 2 +- tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 2 +- tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp | 4 ++-- tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 10 +++++----- .../auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp | 2 +- tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp | 2 +- 12 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index d76eb11073..50893536af 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -779,7 +779,9 @@ inline char qToLower(char ch) } +#if QT_DEPRECATED_SINCE(5, 9) const QString::Null QString::null = { }; +#endif /*! \macro QT_RESTRICTED_CAST_FROM_ASCII diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index e06927d434..1bd436c387 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -770,10 +770,13 @@ public: NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED; #endif // compatibility +#if QT_DEPRECATED_SINCE(5, 9) struct Null { }; + QT_DEPRECATED_X("use QString()") static const Null null; inline QString(const Null &): d(Data::sharedNull()) {} inline QString &operator=(const Null &) { *this = QString(); return *this; } +#endif inline bool isNull() const { return d == Data::sharedNull(); } @@ -1134,13 +1137,18 @@ inline bool QString::contains(QLatin1String s, Qt::CaseSensitivity cs) const inline bool QString::contains(QChar c, Qt::CaseSensitivity cs) const { return indexOf(c, 0, cs) != -1; } - +#if QT_DEPRECATED_SINCE(5, 9) inline bool operator==(QString::Null, QString::Null) { return true; } +QT_DEPRECATED_X("use QString::isNull()") inline bool operator==(QString::Null, const QString &s) { return s.isNull(); } +QT_DEPRECATED_X("use QString::isNull()") inline bool operator==(const QString &s, QString::Null) { return s.isNull(); } inline bool operator!=(QString::Null, QString::Null) { return false; } +QT_DEPRECATED_X("use !QString::isNull()") inline bool operator!=(QString::Null, const QString &s) { return !s.isNull(); } +QT_DEPRECATED_X("use !QString::isNull()") inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); } +#endif inline bool operator==(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW { return s1.size() == s2.size() && (!s1.size() || !memcmp(s1.latin1(), s2.latin1(), s1.size())); } diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 113172ff5a..600754f90c 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -519,7 +519,7 @@ QString QAccessibleDisplay::imageDescription() const #ifndef QT_NO_TOOLTIP return widget()->toolTip(); #else - return QString::null; + return QString(); #endif } diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index a627c86871..a8cdca1719 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1863,7 +1863,7 @@ void QMdiSubWindowPrivate::removeButtonsFromMenuBar() topLevelWindow->removeEventFilter(q); if (baseWidget && !drawTitleBarWhenMaximized()) topLevelWindow->setWindowModified(false); - originalTitle = QString::null; + originalTitle.clear(); } #endif // QT_NO_MENUBAR @@ -2769,7 +2769,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) #ifndef QT_NO_MENUBAR } else if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar() ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) { - d->originalTitle = QString::null; + d->originalTitle.clear(); if (d->baseWidget && d->baseWidget->windowTitle() == windowTitle()) d->updateWindowTitle(true); else diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 57e197aa83..3620043eb1 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -1684,7 +1684,7 @@ void tst_QFile::isSequential() void tst_QFile::encodeName() { - QCOMPARE(QFile::encodeName(QString::null), QByteArray()); + QCOMPARE(QFile::encodeName(QString()), QByteArray()); } void tst_QFile::truncate() diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 48e856f406..03436375dd 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -3818,7 +3818,7 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith(QLatin1Char('x')) ); QVERIFY( !a.startsWith(QChar()) ); - a = QString::null; + a = QString(); QVERIFY( !a.startsWith("") ); QVERIFY( a.startsWith(QString::null) ); QVERIFY( !a.startsWith("ABC") ); @@ -3928,7 +3928,7 @@ void tst_QString::endsWith() QVERIFY( a.endsWith(QLatin1String(0)) ); QVERIFY( !a.endsWith(QLatin1String("ABC")) ); - a = QString::null; + a = QString(); QVERIFY( !a.endsWith("") ); QVERIFY( a.endsWith(QString::null) ); QVERIFY( !a.endsWith("ABC") ); diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index a13fa86405..a1c8399a26 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -124,7 +124,7 @@ protected slots: private: QFtp *newFtp(); void addCommand( QFtp::Command, int ); - bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString::null ); + bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString() ); bool dirExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &cdDir, const QString &dirToCreate ); void renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile ); diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 8126e72ad2..d7772f5c34 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -2191,7 +2191,7 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093() CHECK_DATABASE(db); // select a record with NULL value - QSqlQuery q(QString::null, db); + QSqlQuery q(QString(), db); QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__, db) + " where id = 4")); QVERIFY_SQL(q, next()); diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index 62c75cadf3..9d0c939d84 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -701,14 +701,14 @@ void tst_QShortcut::disabledItems() sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 ); QCOMPARE( currentResult, NoResult ); if (over_330) - QCOMPARE( sbText, QString::null ); + QCOMPARE( sbText, QString() ); currentResult = NoResult; sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 ); sendKeyEvents( Qt::CTRL+Qt::Key_L, 0 ); QCOMPARE( currentResult, Slot1Triggered ); if (over_330) - QCOMPARE( sbText, QString::null ); + QCOMPARE( sbText, QString() ); #endif clearAllShortcuts(); cut1 = 0; diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 4c0ffdc77c..330ce3a836 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -713,8 +713,8 @@ void tst_QLineEdit::clearInputMask() { QLineEdit *testWidget = ensureTestWidget(); testWidget->setInputMask("000.000.000.000"); - QVERIFY(testWidget->inputMask() != QString::null); - testWidget->setInputMask(QString::null); + QVERIFY(!testWidget->inputMask().isNull()); + testWidget->setInputMask(QString()); QCOMPARE(testWidget->inputMask(), QString()); } @@ -2277,7 +2277,7 @@ void tst_QLineEdit::textChangedAndTextEdited() changed_count = 0; edited_count = 0; - changed_string = QString::null; + changed_string.clear(); testWidget->setText("foo"); QCOMPARE(changed_count, 1); @@ -2286,7 +2286,7 @@ void tst_QLineEdit::textChangedAndTextEdited() changed_count = 0; edited_count = 0; - changed_string = QString::null; + changed_string.clear(); testWidget->setText(""); QCOMPARE(changed_count, 1); @@ -3108,7 +3108,7 @@ void tst_QLineEdit::maxLengthAndInputMask() QVERIFY(testWidget->inputMask().isNull()); testWidget->setMaxLength(10); QCOMPARE(testWidget->maxLength(), 10); - testWidget->setInputMask(QString::null); + testWidget->setInputMask(QString()); QVERIFY(testWidget->inputMask().isNull()); QCOMPARE(testWidget->maxLength(), 10); } diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index 31bbcf9c7f..af0ad1a601 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -362,7 +362,7 @@ void tst_QPlainTextEdit::emptyAppend() { ed->appendPlainText("Blah"); QCOMPARE(blockCount(), 1); - ed->appendPlainText(QString::null); + ed->appendPlainText(QString()); QCOMPARE(blockCount(), 2); ed->appendPlainText(QString(" ")); QCOMPARE(blockCount(), 3); diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index cecec48113..b9ea310d80 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -676,7 +676,7 @@ void tst_QTextEdit::emptyAppend() { ed->append("Blah"); QCOMPARE(blockCount(), 1); - ed->append(QString::null); + ed->append(QString()); QCOMPARE(blockCount(), 2); ed->append(QString(" ")); QCOMPARE(blockCount(), 3); -- cgit v1.2.3 From f06f1adb6cc3835793a15eafa2d5a3affad712a2 Mon Sep 17 00:00:00 2001 From: Vikas Pachdha Date: Fri, 10 Mar 2017 15:39:59 +0100 Subject: Add QMake variables for development team and provisioning profile Adding both development team and provisioning profile to Xcode switches off the automatic signing Task-number: QTBUG-38782 Change-Id: Ic869e16490c11e369b6674c815e860cac66c5afa Reviewed-by: Jake Petroules --- qmake/generators/mac/pbuilder_pbx.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index 728e654be8..7507b26c09 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -1477,13 +1477,20 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) QMap settings; if (!project->isActiveConfig("no_xcode_development_team")) { - const QList teams = provisioningTeams(); - if (!teams.isEmpty()) { - // first suitable team we find is the one we'll use by default - settings.insert("DEVELOPMENT_TEAM", - teams.first().value(QLatin1String("teamID")).toString()); + QString teamId; + if (!project->isEmpty("QMAKE_DEVELOPMENT_TEAM")) { + teamId = project->first("QMAKE_DEVELOPMENT_TEAM").toQString(); + } else { + const QList teams = provisioningTeams(); + if (!teams.isEmpty()) // first suitable team we find is the one we'll use by default + teamId = teams.first().value(QLatin1String("teamID")).toString(); } + if (!teamId.isEmpty()) + settings.insert("DEVELOPMENT_TEAM", teamId); + if (!project->isEmpty("QMAKE_PROVISIONING_PROFILE")) + settings.insert("PROVISIONING_PROFILE_SPECIFIER", project->first("QMAKE_PROVISIONING_PROFILE").toQString()); } + settings.insert("COPY_PHASE_STRIP", (as_release ? "YES" : "NO")); settings.insert("APPLICATION_EXTENSION_API_ONLY", project->isActiveConfig("app_extension_api_only") ? "YES" : "NO"); // required for tvOS (and watchos), optional on iOS (deployment target >= iOS 6.0) -- cgit v1.2.3 From d08deb0b4a64e24884eedaf5d8e20f967c38e82a Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 8 Mar 2017 20:11:43 +0100 Subject: Add feature.abstractbutton Change-Id: Ie93c6d0a8256bc466d3419408b753d5f3738aa6b Reviewed-by: Lars Knoll --- src/widgets/accessible/complexwidgets.cpp | 1 - src/widgets/accessible/qaccessiblewidgetfactory.cpp | 2 ++ src/widgets/accessible/qaccessiblewidgets.cpp | 1 - src/widgets/accessible/simplewidgets.cpp | 5 ++++- src/widgets/accessible/simplewidgets_p.h | 2 ++ src/widgets/configure.json | 14 +++++++++++--- src/widgets/itemviews/qtableview.cpp | 10 ++++++++++ src/widgets/itemviews/qtableview.h | 4 ++++ src/widgets/itemviews/qtableview_p.h | 2 ++ src/widgets/styles/qfusionstyle.cpp | 13 ++++++++++--- src/widgets/styles/qstylesheetstyle.cpp | 2 ++ src/widgets/styles/qwindowsxpstyle.cpp | 10 ++++++++-- src/widgets/widgets/qabstractbutton.h | 2 ++ src/widgets/widgets/qlabel.cpp | 6 +++++- src/widgets/widgets/qtoolbutton.h | 9 +++++---- src/widgets/widgets/widgets.pri | 12 +++++++++--- 16 files changed, 76 insertions(+), 19 deletions(-) diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index ea3b88468b..397a58a5d4 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -41,7 +41,6 @@ #include #include -#include #include #include #include diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index c95b5b1097..e7db53c251 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -103,11 +103,13 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QToolButton")) { iface = new QAccessibleToolButton(widget); #endif // QT_NO_TOOLBUTTON +#if QT_CONFIG(abstractbutton) } else if (classname == QLatin1String("QCheckBox") || classname == QLatin1String("QRadioButton") || classname == QLatin1String("QPushButton") || classname == QLatin1String("QAbstractButton")) { iface = new QAccessibleButton(widget); +#endif } else if (classname == QLatin1String("QDialog")) { iface = new QAccessibleWidget(widget, QAccessible::Dialog); } else if (classname == QLatin1String("QMessageBox")) { diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 40aca37f11..7f77f7c524 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -64,7 +64,6 @@ #include #include #include -#include #include #include diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 600754f90c..a53e5eaf30 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -39,7 +39,9 @@ #include "simplewidgets_p.h" +#if QT_CONFIG(abstractbutton) #include +#endif #if QT_CONFIG(checkbox) #include #endif @@ -80,6 +82,7 @@ extern QList childWidgets(const QWidget *widget); QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); +#if QT_CONFIG(abstractbutton) /*! \class QAccessibleButton \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets. @@ -267,7 +270,7 @@ QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) c } return QStringList(); } - +#endif // QT_CONFIG(abstractbutton) #ifndef QT_NO_TOOLBUTTON /*! diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h index 8bd0af8261..1e4ae5ab67 100644 --- a/src/widgets/accessible/simplewidgets_p.h +++ b/src/widgets/accessible/simplewidgets_p.h @@ -65,6 +65,7 @@ class QToolButton; class QGroupBox; class QProgressBar; +#if QT_CONFIG(abstractbutton) class QAccessibleButton : public QAccessibleWidget { Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) @@ -83,6 +84,7 @@ public: protected: QAbstractButton *button() const; }; +#endif #ifndef QT_NO_TOOLBUTTON class QAccessibleToolButton : public QAccessibleButton diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 99e1bd6940..14e4d10d38 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -117,6 +117,12 @@ "condition": "features.tableview", "output": [ "publicFeature", "feature" ] }, + "abstractbutton": { + "label": "QAbstractButton", + "purpose": "Abstract base class of button widgets, providing functionality common to buttons.", + "section": "Widgets", + "output": [ "publicFeature" ] + }, "commandlinkbutton": { "label": "QCommandLinkButton", "purpose": "Provides a Vista style command link button.", @@ -193,6 +199,7 @@ "label": "QRadioButton", "purpose": "Provides a radio button with a text label.", "section": "Widgets", + "condition": "features.abstractbutton", "output": [ "publicFeature" ] }, "spinbox": { @@ -234,20 +241,21 @@ "label": "QCheckBox(", "purpose": "Provides a checkbox with a text label.", "section": "Widgets", + "condition": "features.abstractbutton", "output": [ "publicFeature" ] }, "pushbutton": { "label": "QPushButton", "purpose": "Provides a command button.", "section": "Widgets", - "condition": "features.action", + "condition": "features.abstractbutton && features.action", "output": [ "publicFeature" ] }, "toolbutton": { "label": "QToolButton", "purpose": "Provides quick-access buttons to commands and options.", "section": "Widgets", - "condition": "features.action", + "condition": "features.abstractbutton && features.action", "output": [ "publicFeature", "feature" ] }, "toolbar": { @@ -274,7 +282,7 @@ "label": "QButtonGroup", "purpose": "Supports organizing groups of button widgets.", "section": "Widgets", - "condition": "features.groupbox", + "condition": "features.abstractbutton && features.groupbox", "output": [ "publicFeature", "feature" ] }, "mainwindow": { diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index c7cc1d155e..ed6482a8bc 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(abstractbutton) #include +#endif #include #include #include @@ -578,6 +580,7 @@ bool QSpanCollection::checkConsistency() const } #endif +#if QT_CONFIG(abstractbutton) class QTableCornerButton : public QAbstractButton { Q_OBJECT @@ -600,6 +603,7 @@ public: style()->drawControl(QStyle::CE_Header, &opt, &painter, this); } }; +#endif void QTableViewPrivate::init() { @@ -619,9 +623,11 @@ void QTableViewPrivate::init() tabKeyNavigation = true; +#if QT_CONFIG(abstractbutton) cornerWidget = new QTableCornerButton(q); cornerWidget->setFocusPolicy(Qt::NoFocus); QObject::connect(cornerWidget, SIGNAL(clicked()), q, SLOT(selectAll())); +#endif } /*! @@ -2121,6 +2127,7 @@ void QTableView::updateGeometries() if (d->horizontalHeader->isHidden()) QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); +#if QT_CONFIG(abstractbutton) // update cornerWidget if (d->horizontalHeader->isHidden() || d->verticalHeader->isHidden()) { d->cornerWidget->setHidden(true); @@ -2128,6 +2135,7 @@ void QTableView::updateGeometries() d->cornerWidget->setHidden(false); d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height); } +#endif // update scroll bars @@ -2642,6 +2650,7 @@ bool QTableView::wordWrap() const return d->wrapItemText; } +#if QT_CONFIG(abstractbutton) /*! \property QTableView::cornerButtonEnabled \brief whether the button in the top-left corner is enabled @@ -2664,6 +2673,7 @@ bool QTableView::isCornerButtonEnabled() const Q_D(const QTableView); return d->cornerWidget->isEnabled(); } +#endif /*! \internal diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h index 8c9ac379bc..b1c38d521f 100644 --- a/src/widgets/itemviews/qtableview.h +++ b/src/widgets/itemviews/qtableview.h @@ -58,7 +58,9 @@ class Q_WIDGETS_EXPORT QTableView : public QAbstractItemView Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle) Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled) Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap) +#if QT_CONFIG(abstractbutton) Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled) +#endif public: explicit QTableView(QWidget *parent = Q_NULLPTR); @@ -103,8 +105,10 @@ public: void setWordWrap(bool on); bool wordWrap() const; +#if QT_CONFIG(abstractbutton) void setCornerButtonEnabled(bool enable); bool isCornerButtonEnabled() const; +#endif QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE; void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE; diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 2ca158d657..d2f45d557d 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -192,7 +192,9 @@ public: QVector rowsToUpdate; QHeaderView *horizontalHeader; QHeaderView *verticalHeader; +#if QT_CONFIG(abstractbutton) QWidget *cornerWidget; +#endif bool sortingEnabled; bool geometryRecursionBlock; QPoint visualCursor; // (Row,column) cell coordinates to track through span navigation. diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 1267907303..02e0ad2a9b 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -45,7 +45,8 @@ #include #if QT_CONFIG(pushbutton) #include -#else +#endif +#if QT_CONFIG(abstractbutton) #include #endif #include @@ -3284,7 +3285,10 @@ void QFusionStyle::polish(QApplication *app) void QFusionStyle::polish(QWidget *widget) { QCommonStyle::polish(widget); - if (qobject_cast(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast(widget) +#endif #if QT_CONFIG(combobox) || qobject_cast(widget) #endif @@ -3325,7 +3329,10 @@ void QFusionStyle::polish(QPalette &pal) void QFusionStyle::unpolish(QWidget *widget) { QCommonStyle::unpolish(widget); - if (qobject_cast(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast(widget) +#endif #if QT_CONFIG(combobox) || qobject_cast(widget) #endif diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 275a0550d2..2886093732 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4268,6 +4268,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op case PE_PanelButtonTool: case PE_PanelButtonCommand: +#if QT_CONFIG(abstractbutton) if (qobject_cast(w) && rule.hasBackground() && rule.hasNativeBorder()) { //the window style will draw the borders ParentStyle::drawPrimitive(pe, opt, p, w); @@ -4276,6 +4277,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } return; } +#endif if (!rule.hasNativeBorder()) { rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin)); return; diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index f3c6069f8a..b50c4b6be4 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1139,7 +1139,10 @@ void QWindowsXPStyle::polish(QWidget *widget) if (!QWindowsXPStylePrivate::useXP()) return; - if (qobject_cast(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast(widget) +#endif || qobject_cast(widget) || qobject_cast(widget) #ifndef QT_NO_COMBOBOX @@ -1211,7 +1214,10 @@ void QWindowsXPStyle::unpolish(QWidget *widget) // already in the map might be old (other style). d->cleanupHandleMap(); } - if (qobject_cast(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast(widget) +#endif || qobject_cast(widget) || qobject_cast(widget) #ifndef QT_NO_COMBOBOX diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index 7bf0e0b9d6..4e438bd851 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -45,6 +45,8 @@ #include #include +QT_REQUIRE_CONFIG(abstractbutton); + QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index fa0cff45c9..39e072234e 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -41,7 +41,9 @@ #include "qevent.h" #include "qdrawutil.h" #include "qapplication.h" +#if QT_CONFIG(abstractbutton) #include "qabstractbutton.h" +#endif #include "qstyle.h" #include "qstyleoption.h" #include @@ -972,12 +974,14 @@ bool QLabel::event(QEvent *e) QShortcutEvent *se = static_cast(e); if (se->shortcutId() == d->shortcutId) { QWidget * w = d->buddy; - QAbstractButton *button = qobject_cast(w); if (w->focusPolicy() != Qt::NoFocus) w->setFocus(Qt::ShortcutFocusReason); +#if QT_CONFIG(abstractbutton) + QAbstractButton *button = qobject_cast(w); if (button && !se->isAmbiguous()) button->animateClick(); else +#endif window()->setAttribute(Qt::WA_KeyboardFocusChange); return true; } diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 95d159f12d..e2470524da 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -41,13 +41,14 @@ #define QTOOLBUTTON_H #include + +#if QT_CONFIG(toolbutton) + #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_TOOLBUTTON - class QToolButtonPrivate; class QMenu; class QStyleOptionToolButton; @@ -134,8 +135,8 @@ private: }; -#endif // QT_NO_TOOLBUTTON - QT_END_NAMESPACE +#endif // QT_CONFIG(toolbutton) + #endif // QTOOLBUTTON_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index f67640e40f..22e083a3d4 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -3,8 +3,6 @@ HEADERS += \ widgets/qbuttongroup.h \ widgets/qbuttongroup_p.h \ - widgets/qabstractbutton.h \ - widgets/qabstractbutton_p.h \ widgets/qabstractspinbox.h \ widgets/qabstractspinbox_p.h \ widgets/qcalendarwidget.h \ @@ -76,7 +74,6 @@ HEADERS += \ SOURCES += \ widgets/qbuttongroup.cpp \ - widgets/qabstractbutton.cpp \ widgets/qabstractspinbox.cpp \ widgets/qcalendarwidget.cpp \ widgets/qcombobox.cpp \ @@ -128,6 +125,15 @@ SOURCES += \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp +qtConfig(abstractbutton) { + HEADERS += \ + widgets/qabstractbutton.h \ + widgets/qabstractbutton_p.h + + SOURCES += \ + widgets/qabstractbutton.cpp +} + qtConfig(abstractslider) { HEADERS += \ widgets/qabstractslider.h \ -- cgit v1.2.3 From b950d9b10fc64b2d73b832aea6569f3f1daf8f4f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 12 Mar 2017 20:01:37 +0100 Subject: QGuiApplication: fix QString comparison The code compared a QString* with a QString, which only compiled because the QStringRef(const QString*) ctor was implicit. We're going to fix that, and it's nice to see that the change exposes bugs like this one. The fix is to deref the QString* argument, which we know from previous checks to be non-nullptr, to enable normal QString/QString comparison. Change-Id: Idc7b214cb26e8b7c18ee1ba0a2b7236f814f0810 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/kernel/qguiapplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index c057fccade..19f6a213f8 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -670,7 +670,7 @@ void QGuiApplication::setApplicationDisplayName(const QString &name) disconnect(qGuiApp, &QGuiApplication::applicationNameChanged, qGuiApp, &QGuiApplication::applicationDisplayNameChanged); - if (QGuiApplicationPrivate::displayName != applicationName()) + if (*QGuiApplicationPrivate::displayName != applicationName()) emit qGuiApp->applicationDisplayNameChanged(); } } else if (name != *QGuiApplicationPrivate::displayName) { -- cgit v1.2.3 From d8a123841c98f5af1707ef818a848268d793eab3 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Wed, 7 Sep 2016 08:16:11 +0800 Subject: Doc: Add links to the signal-slot syntaxes page Change-Id: I5443a09d18ada6de16a5cec503523b7cc284b0dc Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qglobal.cpp | 9 ++++++--- src/corelib/kernel/qobject.cpp | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 7ca22e4a93..6dba733fb4 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -958,7 +958,8 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in \snippet code/src_corelib_global_qglobal.cpp 53 - \sa qConstOverload(), qNonConstOverload() + \sa qConstOverload(), qNonConstOverload(), {Differences between String-Based + and Functor-Based Connections} */ /*! \fn auto qConstOverload(T memberFunctionPointer) @@ -969,7 +970,8 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in \snippet code/src_corelib_global_qglobal.cpp 54 - \sa qOverload, qNonConstOverload + \sa qOverload, qNonConstOverload, {Differences between String-Based + and Functor-Based Connections} */ /*! \fn auto qNonConstOverload(T memberFunctionPointer) @@ -980,7 +982,8 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in \snippet code/src_corelib_global_qglobal.cpp 54 - \sa qOverload, qNonConstOverload + \sa qOverload, qNonConstOverload, {Differences between String-Based + and Functor-Based Connections} */ /*! diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 2f4f76856f..1b05962c07 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2653,7 +2653,8 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM call qRegisterMetaType() to register the data type before you establish the connection. - \sa disconnect(), sender(), qRegisterMetaType(), Q_DECLARE_METATYPE() + \sa disconnect(), sender(), qRegisterMetaType(), Q_DECLARE_METATYPE(), + {Differences between String-Based and Functor-Based Connections} */ QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, @@ -4655,6 +4656,8 @@ void qDeleteInEventHandler(QObject *o) make sure to declare the argument type with Q_DECLARE_METATYPE Overloaded functions can be resolved with help of \l qOverload. + + \sa {Differences between String-Based and Functor-Based Connections} */ /*! -- cgit v1.2.3 From 8c0194f76355c5a0341d276d09c2e49462082901 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 11 Mar 2017 18:50:52 +0100 Subject: moc: put the QPrivateSignal argument in the arg array Even if it is normaly not used, templated code might still try to access it Task-number: QTBUG-59414 Change-Id: I9f7aadd714843059c8f89cdac48c60a3e2ca7294 Reviewed-by: Simon Hausmann --- src/tools/moc/generator.cpp | 9 +++------ tests/auto/tools/moc/tst_moc.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 674398e783..db27067cf6 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1483,10 +1483,7 @@ void Generator::generateSignal(FunctionDef *def,int index) } Q_ASSERT(!def->normalizedType.isEmpty()); - if (def->arguments.isEmpty() && def->normalizedType == "void") { - if (def->isPrivateSignal) - fprintf(out, "QPrivateSignal"); - + if (def->arguments.isEmpty() && def->normalizedType == "void" && !def->isPrivateSignal) { fprintf(out, ")%s\n{\n" " QMetaObject::activate(%s, &staticMetaObject, %d, nullptr);\n" "}\n", constQualifier, thisPtr.constData(), index); @@ -1503,7 +1500,7 @@ void Generator::generateSignal(FunctionDef *def,int index) if (def->isPrivateSignal) { if (!def->arguments.isEmpty()) fprintf(out, ", "); - fprintf(out, "QPrivateSignal"); + fprintf(out, "QPrivateSignal _t%d", offset++); } fprintf(out, ")%s\n{\n", constQualifier); @@ -1527,7 +1524,7 @@ void Generator::generateSignal(FunctionDef *def,int index) } int i; for (i = 1; i < offset; ++i) - if (def->arguments.at(i - 1).type.isVolatile) + if (i <= def->arguments.count() && def->arguments.at(i - 1).type.isVolatile) fprintf(out, ", const_cast(reinterpret_cast(&_t%d))", i); else fprintf(out, ", const_cast(reinterpret_cast(&_t%d))", i); diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 2d7ec2f0b5..7c05b388dc 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -2837,6 +2837,21 @@ void tst_Moc::privateSignalConnection() // We can't use function pointer connections to private signals which are overloaded because we would have to cast in this case to: // static_cast(&ClassWithPrivateSignals::overloadedMaybePrivate) // Which doesn't work as ClassWithPrivateSignals::QPrivateSignal is private. + + // Connecting from one private signal to another + { + ClassWithPrivateSignals classWithPrivateSignals1; + ClassWithPrivateSignals classWithPrivateSignals2; + SignalConnectionTester tester; + QObject::connect(&classWithPrivateSignals1, &ClassWithPrivateSignals::privateSignal1, + &classWithPrivateSignals2, &ClassWithPrivateSignals::privateSignal1); + QObject::connect(&classWithPrivateSignals2, &ClassWithPrivateSignals::privateSignal1, + &tester, &SignalConnectionTester::testSlot); + + QVERIFY(!tester.testPassed); + classWithPrivateSignals1.emitPrivateSignals(); + QVERIFY(tester.testPassed); + } } void tst_Moc::finalClasses_data() -- cgit v1.2.3 From 13cfa3c88be220dbb732975bd76d19dfa70c4469 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 28 Feb 2017 09:51:26 +0100 Subject: Clean-up QRgba64 constructors We can add basic constructors now on all supported platforms, and can make initialization consistent on all platforms, choosing undefined as the default. Note this changes behavior on gcc and clang builds, but is consistent with pre-c++11 gcc and clang builds and with msvc. [ChangeLog][QtGui][QRgba64] The default constructor on Clang and GCC builds now no longer initializes with 0s, but leaves the value uninitialized. This is consistent with MSVC behavior and pre-C++11 behavior of GCC and Clang. Change-Id: Ib0e3d7f4274a13a768db62931b67877e3898945e Reviewed-by: Marc Mutz --- src/gui/painting/qrgba64.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h index a3ae0c9b14..2c8f8fa8c4 100644 --- a/src/gui/painting/qrgba64.h +++ b/src/gui/painting/qrgba64.h @@ -64,26 +64,14 @@ class QRgba64 { #endif }; - // No constructors are allowed in C++98, since this needs to be usable in a union. - // We however require one for constexprs in C++11/C++14 -#ifdef Q_COMPILER_CONSTEXPR explicit Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64(quint64 c) : rgba(c) { } -#endif public: -#ifdef Q_COMPILER_CONSTEXPR - Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64() : rgba(0) { } -#endif + QRgba64() = default; Q_DECL_CONSTEXPR static QRgba64 fromRgba64(quint64 c) { -#ifdef Q_COMPILER_CONSTEXPR return QRgba64(c); -#else - QRgba64 rgba64; - rgba64.rgba = c; - return rgba64; -#endif } Q_DECL_CONSTEXPR static QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha) -- cgit v1.2.3 From 2f10a6f04eb12db5d438c103431c0b35ae0a0ee2 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 13 Mar 2017 11:31:25 +0100 Subject: Suppress -Wfloat-equal when defining float16 equality operators Change-Id: Ie30fa13eb5f8eb44f0c9c21e9483c8aba40cec02 Reviewed-by: Marc Mutz --- src/corelib/global/qfloat16.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 8fd2f212af..651057f8e2 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -196,6 +196,10 @@ QF16_MAKE_ARITH_OP_INT(*) QF16_MAKE_ARITH_OP_INT(/) #undef QF16_MAKE_ARITH_OP_INT +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") + 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); } @@ -230,6 +234,8 @@ QF16_MAKE_BOOL_OP_INT(==) QF16_MAKE_BOOL_OP_INT(!=) #undef QF16_MAKE_BOOL_OP_INT +QT_WARNING_POP + /*! \internal */ -- cgit v1.2.3 From 0d287500be09c800fbcc8f04862d316075ced546 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 1 Mar 2017 12:21:29 +0100 Subject: xpm image format: Reject corrupt images with invalid header info The xpm handler did not properly check that the information read from the file header was sane. Task-number: QTBUG-59211 Change-Id: I84099777a16b2b0c473d139f5fdec1d0cb5d515e Reviewed-by: Paul Olav Tvete --- src/gui/image/qxpmhandler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 1f1f6b388f..ce7f7b8a0f 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -852,6 +852,9 @@ static bool read_xpm_header( #endif return false; // < 4 numbers parsed + if (*w <= 0 || *w > 32767 || *h <= 0 || *h > 32767 || *ncols <= 0 || *ncols > (64 * 64 * 64 * 64) || *cpp <= 0 || *cpp > 15) + return false; // failed sanity check + return true; } -- cgit v1.2.3 From 16d1ddfc42732afc6ba90df66042c7ff4be348c2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 11 Mar 2017 19:39:32 +0100 Subject: moc: Support signals that return movable-only type By adding std::move where it makes sense. This is not only good for move-only types, but for any type which can be moved as it saves copies of the return value in any case. [ChangeLog][moc] Move-only types are now supported as return types of signals and slots. Change-Id: Idc9453af993e7574a6bddd4a87210eddd3da48a9 Reviewed-by: Marc Mutz --- src/corelib/kernel/qobjectdefs_impl.h | 7 +---- src/tools/moc/generator.cpp | 8 ++---- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 32 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index bd08ca1763..3f5f2e78bb 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -90,14 +90,9 @@ namespace QtPrivate { explicit ApplyReturnValue(void *data_) : data(data_) {} }; template - void operator,(const T &value, const ApplyReturnValue &container) { - if (container.data) - *reinterpret_cast(container.data) = value; - } - template void operator,(T &&value, const ApplyReturnValue &container) { if (container.data) - *reinterpret_cast(container.data) = value; + *reinterpret_cast(container.data) = std::forward(value); } template void operator,(T, const ApplyReturnValue &) {} diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index db27067cf6..c4184929ef 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1193,7 +1193,7 @@ void Generator::generateStaticMetacall() } fprintf(out, ");"); if (f.normalizedType != "void") { - fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = _r; } ", + fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = std::move(_r); } ", noRef(f.normalizedType).constData()); isUsed_a = true; } @@ -1506,11 +1506,7 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, ")%s\n{\n", constQualifier); if (def->type.name.size() && def->normalizedType != "void") { QByteArray returnType = noRef(def->normalizedType); - if (returnType.endsWith('*')) { - fprintf(out, " %s _t0 = 0;\n", returnType.constData()); - } else { - fprintf(out, " %s _t0 = %s();\n", returnType.constData(), returnType.constData()); - } + fprintf(out, " %s _t0{};\n", returnType.constData()); } fprintf(out, " void *_a[] = { "); diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index f44c40c27f..a645a7b5c6 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -5306,6 +5306,15 @@ void tst_QObject::connectNoDefaultConstructorArg() QVERIFY(connect(&ob, &NoDefaultContructorArguments::mySignal, &ob, &NoDefaultContructorArguments::mySlot, Qt::QueuedConnection)); } +struct MoveOnly +{ + int value; + explicit MoveOnly(int v = 1) : value(v) {} + MoveOnly(MoveOnly &&o) : value(o.value) { o.value = -1; } + MoveOnly &operator=(MoveOnly &&o) { value = o.value; o.value = -1; return *this; } + Q_DISABLE_COPY(MoveOnly); +}; + class ReturnValue : public QObject { friend class tst_QObject; Q_OBJECT @@ -5315,6 +5324,7 @@ signals: int returnInt(int); void returnVoid(int); CustomType returnCustomType(int); + MoveOnly returnMoveOnly(int); QObject *returnPointer(); public slots: @@ -5327,6 +5337,7 @@ public slots: QString returnHello() { return QStringLiteral("hello"); } QObject *returnThisSlot1() { return this; } ReturnValue *returnThisSlot2() { return this; } + MoveOnly returnMoveOnlySlot(int i) { return MoveOnly(i); } public: struct VariantFunctor { QVariant operator()(int i) { return i; } @@ -5343,6 +5354,9 @@ public: struct VoidFunctor { void operator()(int) {} }; + struct MoveOnlyFunctor { + MoveOnly operator()(int i) { return MoveOnly(i); } + }; }; QString someFunctionReturningString(int i) { @@ -5380,6 +5394,7 @@ void tst_QObject::returnValue() emit r.returnVoid(45); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QCOMPARE((emit r.returnPointer()), static_cast(0)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); } { // connected to a slot returning the same type CheckInstanceCount checker; @@ -5394,6 +5409,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, type)); QCOMPARE((emit r.returnPointer()), static_cast(&receiver)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnMoveOnlySlot, type)); + QCOMPARE((emit r.returnMoveOnly(666)).value, 666); } if (!isBlockingQueued) { // connected to simple functions or functor CheckInstanceCount checker; @@ -5412,6 +5429,10 @@ void tst_QObject::returnValue() ReturnValue::IntFunctor intFunctor; QVERIFY(connect(&r, &ReturnValue::returnInt, intFunctor)); QCOMPARE(emit r.returnInt(45), int(45)); + + ReturnValue::MoveOnlyFunctor moveOnlyFunctor; + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, moveOnlyFunctor)); + QCOMPARE((emit r.returnMoveOnly(666)).value, 666); } { // connected to a slot with different type CheckInstanceCount checker; @@ -5450,6 +5471,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnVoidSlot, type)); QCOMPARE((emit r.returnPointer()), static_cast(0)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnVoidSlot, type)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); } if (!isBlockingQueued) { // queued connection should not forward the return value @@ -5465,6 +5488,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, Qt::QueuedConnection)); QCOMPARE((emit r.returnPointer()), static_cast(0)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnMoveOnlySlot, Qt::QueuedConnection)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); QCoreApplication::processEvents(); @@ -5548,6 +5573,8 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int(45)); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnCustomTypeSlot(int)), type)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnMoveOnlySlot(int)), type)); + QCOMPARE((emit r.returnMoveOnly(45)).value, 45); } { // connected to a slot returning void CheckInstanceCount checker; @@ -5560,6 +5587,8 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int()); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnVoidSlot()), type)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnVoidSlot()), type)); + QCOMPARE((emit r.returnMoveOnly(45)).value, MoveOnly().value); } if (!isBlockingQueued) { // queued connection should not forward the return value @@ -5573,6 +5602,9 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int()); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnCustomTypeSlot(int)), Qt::QueuedConnection)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnMoveOnlySlot(int)), Qt::QueuedConnection)); + QCOMPARE((emit r.returnMoveOnly(45)).value, MoveOnly().value); + QCoreApplication::processEvents(); //Queued conneciton with different return type should be safe -- cgit v1.2.3 From 70e772079f4943822cc469ef83fb9c43afc36514 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 13 Mar 2017 13:24:48 +0100 Subject: Fix parsing of the /utf8 MSVC compiler flag in VS project generator Adding the /utf8 compiler flag resulted in undefining all preprocessor symbols for VS project files, because the ingenious compiler option parsing logic checked for a 'u' prefix, and "utf8" obviously matched. The /utf8 flag is added to the additional options, because there doesn't seem to be an XML tag for that. Task-number: QTBUG-59431 Change-Id: I762fcdcf6caf0606b40633861e265df5edb4a9c4 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msvc_objectmodel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 60734b4d1b..34975f2b7b 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -1153,7 +1153,12 @@ bool VCCLCompilerTool::parseOption(const char* option) } found = false; break; case 'u': - UndefineAllPreprocessorDefinitions = _True; + if (!second) + UndefineAllPreprocessorDefinitions = _True; + else if (second == 't' && third == 'f' && fourth == '8') + AdditionalOptions += option; + else + found = false; break; case 'v': if(second == 'd' || second == 'm') { -- cgit v1.2.3 From e83247a2b96e657b43d86df93b5e67d9f5d63d99 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 12 Mar 2017 22:43:04 +0100 Subject: Do not assume QStringRef(const QString*) to be implicit It won't be for very much longer. Change-Id: I30e3e0cd8c8ecf0833f759557382a3ded7bdea34 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 2 +- src/corelib/tools/qlocale.cpp | 2 +- src/corelib/xml/qxmlutils_p.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index e9f740b7c5..a4a7aabacb 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1971,7 +1971,7 @@ QTime QTime::fromString(const QString& string, Qt::DateFormat format) case Qt::ISODateWithMs: case Qt::TextDate: default: - return fromIsoTimeString(&string, format, 0); + return fromIsoTimeString(QStringRef(&string), format, 0); } } diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 47d64c0df6..59952bd107 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -972,7 +972,7 @@ QLocale::NumberOptions QLocale::numberOptions() const */ QString QLocale::quoteString(const QString &str, QuotationStyle style) const { - return quoteString(&str, style); + return quoteString(QStringRef(&str), style); } /*! diff --git a/src/corelib/xml/qxmlutils_p.h b/src/corelib/xml/qxmlutils_p.h index d8d25e0efe..6db347b3ee 100644 --- a/src/corelib/xml/qxmlutils_p.h +++ b/src/corelib/xml/qxmlutils_p.h @@ -73,7 +73,7 @@ public: static bool isNameChar(const QChar c); static bool isLetter(const QChar c); static bool isNCName(const QStringRef &ncName); - static inline bool isNCName(const QString &ncName) { return isNCName(&ncName); } + static inline bool isNCName(const QString &ncName) { return isNCName(QStringRef(&ncName)); } static bool isPublicID(const QString &candidate); private: -- cgit v1.2.3 From 550d7930d1deed4fa40da0edf2c7a9de4dc0ffd3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 13 Mar 2017 14:04:05 +0100 Subject: xcb: send keyboard modifiers with every QTabletEvent Task-number: QTBUG-59415 Change-Id: If64a6513131fd85189e3621cb2a105e80e919ecf Reviewed-by: Andy Shaw --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 4a30f7b7bc..14c138a911 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1176,6 +1176,7 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD if (!xcbWindow) return; QWindow *window = xcbWindow->window(); + const Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(ev->mods.effective_mods); const double scale = 65536.0; QPointF local(ev->event_x / scale, ev->event_y / scale); QPointF global(ev->root_x / scale, ev->root_y / scale); @@ -1217,18 +1218,18 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %s type %s seq %d detail %d time %d " - "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf", + "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf modifiers 0x%x", tabletData->deviceId, toolName(tabletData->tool), pointerTypeName(tabletData->pointerType), ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), - (int)tabletData->buttons, pressure, xTilt, yTilt, rotation); + (int)tabletData->buttons, pressure, xTilt, yTilt, rotation, (int)modifiers); QWindowSystemInterface::handleTabletEvent(window, ev->time, local, global, tabletData->tool, tabletData->pointerType, tabletData->buttons, pressure, xTilt, yTilt, tangentialPressure, - rotation, 0, tabletData->serialId); + rotation, 0, tabletData->serialId, modifiers); } QXcbConnection::TabletData *QXcbConnection::tabletDataForDevice(int id) -- cgit v1.2.3 From 68009a7d4334b7923dd777af086c234bec7acf98 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 13 Mar 2017 14:05:12 +0100 Subject: QTabletEvent manual test: show keyboard modifiers Task-number: QTBUG-59415 Change-Id: Ibb7ebc29797712535d82c6eb02c78dc28ad4131d Reviewed-by: Andy Shaw --- .../qtabletevent/device_information/tabletwidget.cpp | 20 ++++++++++++++++++++ .../qtabletevent/device_information/tabletwidget.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index b4273bde8e..3a0b1e0f21 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -68,6 +68,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) mRot = event->rotation(); mButton = event->button(); mButtons = event->buttons(); + mModifiers = event->modifiers(); mTimestamp = event->timestamp(); if (isVisible()) update(); @@ -172,6 +173,7 @@ void TabletWidget::paintEvent(QPaintEvent *) eventInfo << QString("Button: %1 (0x%2)").arg(buttonToString(mButton)).arg(mButton, 0, 16); eventInfo << QString("Buttons currently pressed: %1 (0x%2)").arg(buttonsToString(mButtons)).arg(mButtons, 0, 16); + eventInfo << QString("Keyboard modifiers: %1 (0x%2)").arg(modifiersToString(mModifiers)).arg(mModifiers, 0, 16); eventInfo << QString("Pressure: %1").arg(QString::number(mPress)); eventInfo << QString("Tangential pressure: %1").arg(QString::number(mTangential)); eventInfo << QString("Rotation: %1").arg(QString::number(mRot)); @@ -205,6 +207,24 @@ QString TabletWidget::buttonsToString(Qt::MouseButtons bs) return ret.join(QLatin1Char('|')); } +QString TabletWidget::modifiersToString(Qt::KeyboardModifiers m) +{ + QStringList ret; + if (m & Qt::ShiftModifier) + ret << QLatin1String("Shift"); + if (m & Qt::ControlModifier) + ret << QLatin1String("Control"); + if (m & Qt::AltModifier) + ret << QLatin1String("Alt"); + if (m & Qt::MetaModifier) + ret << QLatin1String("Meta"); + if (m & Qt::KeypadModifier) + ret << QLatin1String("Keypad"); + if (m & Qt::GroupSwitchModifier) + ret << QLatin1String("GroupSwitch"); + return ret.join(QLatin1Char('|')); +} + void TabletWidget::tabletEvent(QTabletEvent *event) { event->accept(); diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index 2b014a213a..0d27c2eea0 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -43,6 +43,7 @@ protected: void paintEvent(QPaintEvent *event); const char *buttonToString(Qt::MouseButton b); QString buttonsToString(Qt::MouseButtons bs); + QString modifiersToString(Qt::KeyboardModifiers m); private: void resetAttributes() { mType = mDev = mPointerType = mXT = mYT = mZ = 0; @@ -57,6 +58,7 @@ private: int mDev, mPointerType, mXT, mYT, mZ; Qt::MouseButton mButton; Qt::MouseButtons mButtons; + Qt::KeyboardModifiers mModifiers; qreal mPress, mTangential, mRot; qint64 mUnique; bool mMouseToo; -- cgit v1.2.3 From 35c8a21fe49a06dca6287be82ec4608d35ea794c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 13 Mar 2017 14:05:50 +0100 Subject: QTabletEvent manual test: add quit shortcut Change-Id: I73012ec2d02856e5bbbc27d269f89b3918dd7c2d Reviewed-by: Andy Shaw --- tests/manual/qtabletevent/device_information/tabletwidget.cpp | 3 ++- tests/manual/qtabletevent/device_information/tabletwidget.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index 3a0b1e0f21..14d059abc1 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -33,7 +33,7 @@ #include #include -TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCount(0) +TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCount(0), mQuitShortcut(QKeySequence::Quit, this) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, Qt::white); @@ -41,6 +41,7 @@ TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCoun setPalette(newPalette); qApp->installEventFilter(this); resetAttributes(); + connect(&mQuitShortcut, SIGNAL(activated()), qApp, SLOT(quit())); } bool TabletWidget::eventFilter(QObject *, QEvent *ev) diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index 0d27c2eea0..404be1289f 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -31,6 +31,7 @@ #include #include +#include // a widget showing the information of the last tablet event class TabletWidget : public QWidget @@ -64,6 +65,7 @@ private: bool mMouseToo; ulong mTimestamp; int mWheelEventCount; + QShortcut mQuitShortcut; }; #endif // TABLETWIDGET_H -- cgit v1.2.3 From 7ac100ddd1d5e8d2f5d111f793f41ed6c98179ca Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 10 Jun 2016 10:19:31 +0200 Subject: tst_QObject: Test if the new connect style works with multiple inheritance Change-Id: I638630ef84a3aee98688dac000efd3dfa7472175 Reviewed-by: Thiago Macieira --- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 5a5c4d3a40..db6bdf0809 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -5712,6 +5712,27 @@ public slots: virtual void slot2() { ++virtual_base_count; } }; +struct NormalBase +{ + QByteArray lastCalled; + virtual ~NormalBase() {} + virtual void virtualBaseSlot() { lastCalled = "virtualBaseSlot"; } + void normalBaseSlot() { lastCalled = "normalBaseSlot"; } +}; + +class ObjectWithMultiInheritance : public VirtualSlotsObject, public NormalBase +{ + Q_OBJECT +}; + +// Normally, the class that inherit QObject always must go first, because of the way qobject_cast +// work, and moc checks for that. But if we don't use Q_OBJECT, this should work +class ObjectWithMultiInheritance2 : public NormalBase, public VirtualSlotsObject +{ + // no QObject as QObject always must go first + // Q_OBJECT +}; + // VMI = Virtual or Multiple Inheritance // (in this case, both) void tst_QObject::connectSlotsVMIClass() @@ -5794,6 +5815,93 @@ void tst_QObject::connectSlotsVMIClass() QCOMPARE(obj.virtual_base_count, 1); QCOMPARE(obj.regular_call_count, 0); } + + // test connecting a slot that is virtual within the second base + { + ObjectWithMultiInheritance obj; + void (ObjectWithMultiInheritance::*slot)() = &ObjectWithMultiInheritance::virtualBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("virtualBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot that is not virtual within the second base + { + ObjectWithMultiInheritance obj; + void (ObjectWithMultiInheritance::*slot)() = &ObjectWithMultiInheritance::normalBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("normalBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot within the first non-QObject base + { + ObjectWithMultiInheritance2 obj; + void (ObjectWithMultiInheritance2::*slot)() = &ObjectWithMultiInheritance2::normalBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("normalBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot within the second QObject base + { + ObjectWithMultiInheritance2 obj; + void (ObjectWithMultiInheritance2::*slot)() = &ObjectWithMultiInheritance2::slot1; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 1); + QCOMPARE(obj.lastCalled, QByteArray()); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 1); + QCOMPARE(obj.lastCalled, QByteArray()); + } } #ifndef QT_BUILD_INTERNAL -- cgit v1.2.3 From 5e18f4ce0b16e9ff3101493d603bbc51b93dd2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 14 Mar 2017 15:50:35 +0100 Subject: Skip tst_MacNativeEvents::testChildDialogInFrontOfModalParent() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closing the dialog at the end of the test ends the modal session via QCocoaEventDispatcherPrivate::endModalSession(), but the actual ending of the session is deferred to cleanupModalSessions(), and that is never called. The result is that QCocoaWindow::setVisible of the window in testKeyPressOnToplevel and following tests ends up calling [m_nsWindow orderFront:nil]; instead of [m_nsWindow makeKeyAndOrderFront:nil];, leaving the window inactive and the tests failing. Task-number: QTBUG-58474 Change-Id: If66b2e201f658b627c2ec50a562938f59a5037ed Reviewed-by: Tor Arne Vestbø --- tests/auto/other/macnativeevents/tst_macnativeevents.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp index 1624b3065b..5edff7aabe 100644 --- a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp +++ b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp @@ -280,6 +280,8 @@ void tst_MacNativeEvents::testMouseEnter() void tst_MacNativeEvents::testChildDialogInFrontOfModalParent() { + QSKIP("Modal dialog causes later tests to fail, see QTBUG-58474"); + // Test that a child dialog of a modal parent dialog is // in front of the parent, and active: QDialog parent; -- cgit v1.2.3 From fb061e586d9a9b1122a4db5f3d4c12d3c55435a1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 14 Mar 2017 11:22:44 -0700 Subject: uic & rcc: use the public API to set the hash seed Instead of relying on a private symbol exported from QtCore. Task-number: QTBUG-47566 Change-Id: I4a7dc1fe14154695b968fffd14abd2b21a18203b Reviewed-by: David Faure --- src/tools/rcc/main.cpp | 10 ++++++---- src/tools/uic/main.cpp | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 4e37fc7887..fba47b74c3 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -312,16 +313,17 @@ int runRcc(int argc, char *argv[]) return 0; } -Q_CORE_EXPORT extern QBasicAtomicInt qt_qhash_seed; // from qhash.cpp - QT_END_NAMESPACE int main(int argc, char *argv[]) { // rcc uses a QHash to store files in the resource system. // we must force a certain hash order when testing or tst_rcc will fail, see QTBUG-25078 - if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_RCC_TEST") && !qt_qhash_seed.testAndSetRelaxed(-1, 0))) - qFatal("Cannot force QHash seed for testing as requested"); + if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_RCC_TEST"))) { + qSetGlobalQHashSeed(0); + if (qGlobalQHashSeed() != 0) + qFatal("Cannot force QHash seed for testing as requested"); + } return QT_PREPEND_NAMESPACE(runRcc)(argc, argv); } diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index fca604690e..3599470403 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -39,11 +40,10 @@ #include QT_BEGIN_NAMESPACE -extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed; int runUic(int argc, char *argv[]) { - qt_qhash_seed.testAndSetRelaxed(-1, 0); // set the hash seed to 0 if it wasn't set yet + qSetGlobalQHashSeed(0); // set the hash seed to 0 QCoreApplication app(argc, argv); QCoreApplication::setApplicationVersion(QString::fromLatin1(QT_VERSION_STR)); -- cgit v1.2.3 From 3e3defb5c37cca715a441895d7df0f06f0c2cd89 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 22 Oct 2015 12:06:59 +0200 Subject: Secure Transport - add a missing cipher Secure Transport supports more ciphers then we can convert into QSslCipher. This results in our tests failing, since after the successful SSL handshake sessionCipher is 'unknown'. This patch adds missing AES256-GCM-SHA384 and also, to make new cipher addition easier in future, sorts cipher suites as it's done in CipherSuite.h (ST framework's header) - grouped by RFC they were introduced in + sorted within their group. As a bonus (thanks to Eddy for spotting this problem) - some copy & paste (?) typos were fixed (mismatched names). Task-number: QTBUG-59480 Change-Id: I61e984da8b37f1c0787305a26fc289e2e7c2b4ad Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslsocket_mac.cpp | 137 +++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 58 deletions(-) diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 752640bd46..3e56eac803 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -476,6 +476,7 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui { QSslCipher ciph; switch (cipher) { + // Sorted as in CipherSuite.h (and groupped by their RFC) case SSL_RSA_WITH_NULL_MD5: ciph.d->name = QLatin1String("NULL-MD5"); ciph.d->protocol = QSsl::SslV3; @@ -493,38 +494,21 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui ciph.d->protocol = QSsl::SslV3; break; - case TLS_RSA_WITH_3DES_EDE_CBC_SHA: - ciph.d->name = QLatin1String("DES-CBC3-SHA"); - break; + // TLS addenda using AES, per RFC 3268 case TLS_RSA_WITH_AES_128_CBC_SHA: ciph.d->name = QLatin1String("AES128-SHA"); break; - case TLS_RSA_WITH_AES_128_CBC_SHA256: - ciph.d->name = QLatin1String("AES128-SHA256"); - break; - case TLS_RSA_WITH_AES_256_CBC_SHA: - ciph.d->name = QLatin1String("AES256-SHA"); - break; - case TLS_RSA_WITH_AES_256_CBC_SHA256: - ciph.d->name = QLatin1String("AES256-SHA256"); - break; - - case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA: - ciph.d->name = QLatin1String("DHE-RSA-DES-CBC3-SHA"); - break; case TLS_DHE_RSA_WITH_AES_128_CBC_SHA: ciph.d->name = QLatin1String("DHE-RSA-AES128-SHA"); break; - case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256: - ciph.d->name = QLatin1String("DHE-RSA-AES128-SHA256"); + case TLS_RSA_WITH_AES_256_CBC_SHA: + ciph.d->name = QLatin1String("AES256-SHA"); break; case TLS_DHE_RSA_WITH_AES_256_CBC_SHA: ciph.d->name = QLatin1String("DHE-RSA-AES256-SHA"); break; - case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256: - ciph.d->name = QLatin1String("DHE-RSA-AES256-SHA256"); - break; + // ECDSA addenda, RFC 4492 case TLS_ECDH_ECDSA_WITH_NULL_SHA: ciph.d->name = QLatin1String("ECDH-ECDSA-NULL-SHA"); break; @@ -537,21 +521,29 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA: ciph.d->name = QLatin1String("ECDH-ECDSA-AES128-SHA"); break; - case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256: - ciph.d->name = QLatin1String("ECDH-ECDSA-AES128-SHA256"); - break; case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA: ciph.d->name = QLatin1String("ECDH-ECDSA-AES256-SHA"); break; - case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384: - ciph.d->name = QLatin1String("ECDH-ECDSA-AES256-SHA384"); + case TLS_ECDHE_ECDSA_WITH_NULL_SHA: + ciph.d->name = QLatin1String("ECDHE-ECDSA-NULL-SHA"); + break; + case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA: + ciph.d->name = QLatin1String("ECDHE-ECDSA-RC4-SHA"); + break; + case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA: + ciph.d->name = QLatin1String("ECDHE-ECDSA-DES-CBC3-SHA"); + break; + case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: + ciph.d->name = QLatin1String("ECDHE-ECDSA-AES128-SHA"); + break; + case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: + ciph.d->name = QLatin1String("ECDHE-ECDSA-AES256-SHA"); break; - case TLS_ECDH_RSA_WITH_NULL_SHA: ciph.d->name = QLatin1String("ECDH-RSA-NULL-SHA"); break; case TLS_ECDH_RSA_WITH_RC4_128_SHA: - ciph.d->name = QLatin1String("ECDH-RSA-AES256-SHA"); + ciph.d->name = QLatin1String("ECDH-RSA-RC4-SHA"); break; case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA: ciph.d->name = QLatin1String("ECDH-RSA-DES-CBC3-SHA"); @@ -559,62 +551,91 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA: ciph.d->name = QLatin1String("ECDH-RSA-AES128-SHA"); break; - case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256: - ciph.d->name = QLatin1String("ECDH-RSA-AES128-SHA256"); - break; case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA: ciph.d->name = QLatin1String("ECDH-RSA-AES256-SHA"); break; - case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384: - ciph.d->name = QLatin1String("ECDH-RSA-AES256-SHA384"); + case TLS_ECDHE_RSA_WITH_NULL_SHA: + ciph.d->name = QLatin1String("ECDHE-RSA-NULL-SHA"); + break; + case TLS_ECDHE_RSA_WITH_RC4_128_SHA: + ciph.d->name = QLatin1String("ECDHE-RSA-RC4-SHA"); + break; + case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: + ciph.d->name = QLatin1String("ECDHE-RSA-DES-CBC3-SHA"); + break; + case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: + ciph.d->name = QLatin1String("ECDHE-RSA-AES128-SHA"); + break; + case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: + ciph.d->name = QLatin1String("ECDHE-RSA-AES256-SHA"); break; - case TLS_ECDHE_ECDSA_WITH_NULL_SHA: - ciph.d->name = QLatin1String("ECDHE-ECDSA-NULL-SHA"); + // TLS 1.2 addenda, RFC 5246 + case TLS_RSA_WITH_3DES_EDE_CBC_SHA: + ciph.d->name = QLatin1String("DES-CBC3-SHA"); break; - case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA: - ciph.d->name = QLatin1String("ECDHE-ECDSA-RC4-SHA"); + case TLS_RSA_WITH_AES_128_CBC_SHA256: + ciph.d->name = QLatin1String("AES128-SHA256"); break; - case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA: - ciph.d->name = QLatin1String("ECDHE-ECDSA-DES-CBC3-SHA"); + case TLS_RSA_WITH_AES_256_CBC_SHA256: + ciph.d->name = QLatin1String("AES256-SHA256"); break; - case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: - ciph.d->name = QLatin1String("ECDHE-ECDSA-AES128-SHA"); + case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA: + ciph.d->name = QLatin1String("DHE-RSA-DES-CBC3-SHA"); break; - case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: - ciph.d->name = QLatin1String("ECDHE-ECDSA-AES128-SHA256"); + case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256: + ciph.d->name = QLatin1String("DHE-RSA-AES128-SHA256"); break; - case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: - ciph.d->name = QLatin1String("ECDHE-ECDSA-AES256-SHA"); + case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256: + ciph.d->name = QLatin1String("DHE-RSA-AES256-SHA256"); break; - case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384: - ciph.d->name = QLatin1String("ECDHE-ECDSA-AES256-SHA384"); + + // Addendum from RFC 4279, TLS PSK + // all missing atm. + + // RFC 4785 - Pre-Shared Key (PSK) Ciphersuites with NULL Encryption + // all missing atm. + + // Addenda from rfc 5288 AES Galois Counter Mode (CGM) Cipher Suites for TLS + case TLS_RSA_WITH_AES_256_GCM_SHA384: + ciph.d->name = QLatin1String("AES256-GCM-SHA384"); break; - case TLS_ECDHE_RSA_WITH_NULL_SHA: - ciph.d->name = QLatin1String("ECDHE-RSA-NULL-SHA"); + // RFC 5487 - PSK with SHA-256/384 and AES GCM + // all missing atm. + + // Addenda from rfc 5289 Elliptic Curve Cipher Suites with HMAC SHA-256/384 + case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: + ciph.d->name = QLatin1String("ECDHE-ECDSA-AES128-SHA256"); break; - case TLS_ECDHE_RSA_WITH_RC4_128_SHA: - ciph.d->name = QLatin1String("ECDHE-RSA-AES256-SHA"); + case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384: + ciph.d->name = QLatin1String("ECDHE-ECDSA-AES256-SHA384"); break; - case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: - ciph.d->name = QLatin1String("ECDHE-RSA-DES-CBC3-SHA"); + case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256: + ciph.d->name = QLatin1String("ECDH-ECDSA-AES128-SHA256"); break; - case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: - ciph.d->name = QLatin1String("ECDHE-RSA-AES128-SHA"); + case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384: + ciph.d->name = QLatin1String("ECDH-ECDSA-AES256-SHA384"); break; case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: ciph.d->name = QLatin1String("ECDHE-RSA-AES128-SHA256"); break; - case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: - ciph.d->name = QLatin1String("ECDHE-RSA-AES256-SHA"); - break; case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384: ciph.d->name = QLatin1String("ECDHE-RSA-AES256-SHA384"); break; + case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256: + ciph.d->name = QLatin1String("ECDH-RSA-AES128-SHA256"); + break; + case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384: + ciph.d->name = QLatin1String("ECDH-RSA-AES256-SHA384"); + break; + + // Addenda from rfc 5289 Elliptic Curve Cipher Suites + // with SHA-256/384 and AES Galois Counter Mode (GCM) case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: ciph.d->name = QLatin1String("ECDHE-RSA-AES256-GCM-SHA384"); break; + default: return ciph; } -- cgit v1.2.3 From 3f0ceb91f806737586b2acc39c1efa960a26cf00 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 16 Mar 2017 12:54:48 +0100 Subject: Add lancelot test to exercise tiled non-ARGB32PM bilinear filtering No test were hitting the code path for tiled non-ARGB32PM bilinear filtered scaling. In part because we were only using brushes in pixmap mode which are always converted to RGB32 or ARGB32PM. Change-Id: Ib466567f31ce6ee894acdf484d44b3af62dad6fc Reviewed-by: Eirik Aavitsland --- tests/auto/other/lancelot/paintcommands.cpp | 12 ++++++------ tests/auto/other/lancelot/scripts/brushes.qps | 9 +++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 971b9b5fe7..c28812e120 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -263,7 +263,7 @@ void PaintCommands::staticInit() "path_setFillRule pathName Winding"); DECL_PAINTCOMMAND("setBrush", command_setBrush, "^setBrush\\s+(#?[\\w.:\\/]*)\\s*(\\w*)?$", - "setBrush \nsetBrush noBrush\nsetBrush ", + "setBrush \nsetBrush noBrush\nsetBrush ", "setBrush white SolidPattern"); DECL_PAINTCOMMAND("setBrushOrigin", command_setBrushOrigin, "^setBrushOrigin\\s*(-?\\w*)\\s+(-?\\w*)$", @@ -1752,13 +1752,13 @@ void PaintCommands::command_setBrush(QRegExp re) { QStringList caps = re.capturedTexts(); - QPixmap pm = image_load(caps.at(1)); - if (!pm.isNull()) { // Assume pixmap + QImage img = image_load(caps.at(1)); + if (!img.isNull()) { // Assume image brush if (m_verboseMode) - printf(" -(lance) setBrush(pixmap=%s, width=%d, height=%d)\n", - qPrintable(caps.at(1)), pm.width(), pm.height()); + printf(" -(lance) setBrush(image=%s, width=%d, height=%d)\n", + qPrintable(caps.at(1)), img.width(), img.height()); - m_painter->setBrush(QBrush(pm)); + m_painter->setBrush(QBrush(img)); } else if (caps.at(1).toLower() == "nobrush") { m_painter->setBrush(Qt::NoBrush); if (m_verboseMode) diff --git a/tests/auto/other/lancelot/scripts/brushes.qps b/tests/auto/other/lancelot/scripts/brushes.qps index 82cbff48b9..43a7843601 100644 --- a/tests/auto/other/lancelot/scripts/brushes.qps +++ b/tests/auto/other/lancelot/scripts/brushes.qps @@ -77,3 +77,12 @@ drawRect 0 250 50 50 setBrushOrigin 50 250 drawRect 50 250 50 50 + +setBrush dome_indexed.png +setPen nopen +brushScale 0.7 0.7 +drawRect 20 320 600 200 + +setBrush dome_argb32.png +brushScale 1.5 1.5 +drawRect 20 540 600 200 -- cgit v1.2.3 From 3e0355014edda23d94605c77dd8c1582b91f9c18 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 13 Mar 2017 14:47:56 -0700 Subject: warn of blacklisted GLX OpenGL renderers and vendors Notify users when multithreaded OpenGL is disabled due to the renderer or vendor blacklist. Change-Id: I16a80568afe87b227575102ca839f18050613e90 Reviewed-by: Ulf Hermann --- .../xcb/gl_integrations/xcb_glx/qglxintegration.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 4e0c73450e..caa4b7361a 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -56,6 +56,8 @@ #include #include +#include "qxcbglintegration.h" + #if !defined(QT_STATIC) && QT_CONFIG(dlopen) #include #endif @@ -691,6 +693,10 @@ void QGLXContext::queryDummyContext() if (const char *renderer = (const char *) glGetString(GL_RENDERER)) { for (int i = 0; qglx_threadedgl_blacklist_renderer[i]; ++i) { if (strstr(renderer, qglx_threadedgl_blacklist_renderer[i]) != 0) { + qCInfo(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: " + "blacklisted renderer \"" + << qglx_threadedgl_blacklist_renderer[i] + << "\""; m_supportsThreading = false; break; } @@ -700,6 +706,11 @@ void QGLXContext::queryDummyContext() if (glxvendor) { for (int i = 0; qglx_threadedgl_blacklist_vendor[i]; ++i) { if (strstr(glxvendor, qglx_threadedgl_blacklist_vendor[i]) != 0) { + qCInfo(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: " + "blacklisted vendor \"" + << qglx_threadedgl_blacklist_vendor[i] + << "\""; + m_supportsThreading = false; break; } @@ -709,6 +720,11 @@ void QGLXContext::queryDummyContext() context.doneCurrent(); if (oldContext && oldSurface) oldContext->makeCurrent(oldSurface); + + if (!m_supportsThreading) { + qCInfo(lcQpaGl) << "Force-enable multithreaded OpenGL by setting " + "environment variable QT_OPENGL_NO_SANITY_CHECK"; + } } bool QGLXContext::supportsThreading() -- cgit v1.2.3 From 99adabdb7ecdded792961392cec6b68e625bf6e2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 15 Mar 2017 09:51:42 -0700 Subject: QNSView: Harden logic around platform window access Some users have reported crashes in -[QNSView mouseEnteredImpl:] which we believe are due to null m_platformWindow. The stack traces are like the one below or similar: 0 libqcocoa_dylib QNSView mouseEnteredImpl_ 0x1F 1 appkit NSTrackingArea _dispatchMouseEntered_ 0xA2 2 appkit NSApplication sendEvent_ 0xF4D 3 libqcocoa_dylib QNSApplication sendEvent_ 0x4E 4 libqcocoa_dylib QCocoaEventDispatcher processEvents 0x184 5 qtcore QEventLoop exec 0x19C 6 qtwidgets QDialog exec 0x20B Moreover, since 2f505b79a49bdf5ba8d084e13ab339bcf956c849, that member is a QPointer, so we should do more systematic checks. Change-Id: Iced447515a4ae07a62734e587f5b08d46d313071 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qnsview.mm | 78 ++++++++++++++++++++++ .../platforms/cocoa/qnsviewaccessibility.mm | 3 + 2 files changed, 81 insertions(+) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index fbf4f99f2e..40efa092b3 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -238,6 +238,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)viewDidMoveToSuperview { + if (m_platformWindow.isNull()) + return; + if (!(m_platformWindow->m_viewIsToBeEmbedded)) return; @@ -258,6 +261,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (QWindow *)topLevelWindow { + if (m_platformWindow.isNull()) + return nullptr; + QWindow *focusWindow = m_platformWindow->window(); // For widgets we need to do a bit of trickery as the window @@ -273,6 +279,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)updateGeometry { + if (m_platformWindow.isNull()) + return; + QRect geometry; if (self.window.parentWindow) { @@ -619,6 +628,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)handleMouseEvent:(NSEvent *)theEvent { + if (m_platformWindow.isNull()) + return; + // Tablet events may come in via the mouse event handlers, // check if this is a valid tablet event first. if ([self handleTabletEvent: theEvent]) @@ -633,6 +645,8 @@ static bool _q_dontOverrideCtrlLMB = false; else m_platformWindow->m_forwardWindow.clear(); } + if (targetView->m_platformWindow.isNull()) + return; // Popups implicitly grap mouse events; forward to the active popup if there is one if (QCocoaWindow *popup = QCocoaIntegration::instance()->activePopupWindow()) { @@ -657,6 +671,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent { + if (m_platformWindow.isNull()) + return; + // get m_buttons in sync // Don't send frme strut events if we are in the middle of a mouse drag. if (m_buttons != Qt::NoButton) @@ -936,6 +953,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseMovedImpl:(NSEvent *)theEvent { + if (m_platformWindow.isNull()) + return; + if ([self isTransparentForUserInput]) return; @@ -967,6 +987,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseEnteredImpl:(NSEvent *)theEvent { Q_UNUSED(theEvent) + if (m_platformWindow.isNull()) + return; + m_platformWindow->m_windowUnderMouse = true; if ([self isTransparentForUserInput]) @@ -986,6 +1009,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseExitedImpl:(NSEvent *)theEvent { Q_UNUSED(theEvent); + if (m_platformWindow.isNull()) + return; + m_platformWindow->m_windowUnderMouse = false; if ([self isTransparentForUserInput]) @@ -1012,6 +1038,9 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) - (bool)handleTabletEvent: (NSEvent *)theEvent { + if (m_platformWindow.isNull()) + return false; + NSEventType eventType = [theEvent type]; if (eventType != NSTabletPoint && [theEvent subtype] != NSTabletPointEventSubtype) return false; // Not a tablet event. @@ -1170,6 +1199,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (bool)shouldSendSingleTouch { + if (m_platformWindow.isNull()) + return true; + // QtWidgets expects single-point touch events, QtDeclarative does not. // Until there is an API we solve this by looking at the window class type. return m_platformWindow->window()->inherits("QWidgetWindow"); @@ -1177,6 +1209,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesBeganWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points; @@ -1185,6 +1220,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesMovedWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points; @@ -1193,6 +1231,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesEndedWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points; @@ -1201,6 +1242,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)touchesCancelledWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points; @@ -1228,6 +1272,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) } - (void)magnifyWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + if ([self handleGestureAsBeginEnd:event]) return; @@ -1242,6 +1289,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)smartMagnifyWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + static bool zoomIn = true; qCDebug(lcQpaGestures) << "smartMagnifyWithEvent" << zoomIn; const NSTimeInterval timestamp = [event timestamp]; @@ -1255,6 +1305,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)rotateWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + if ([self handleGestureAsBeginEnd:event]) return; @@ -1268,6 +1321,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)swipeWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; @@ -1290,6 +1346,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)beginGestureWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; @@ -1301,6 +1360,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)endGestureWithEvent:(NSEvent *)event { + if (m_platformWindow.isNull()) + return; + qCDebug(lcQpaGestures) << "endGestureWithEvent"; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; @@ -1314,6 +1376,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) #ifndef QT_NO_WHEELEVENT - (void)scrollWheel:(NSEvent *)theEvent { + if (m_platformWindow.isNull()) + return; + if ([self isTransparentForUserInput]) return [super scrollWheel:theEvent]; @@ -1984,6 +2049,9 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin // Sends drag update to Qt, return the action - (NSDragOperation)handleDrag:(id )sender { + if (m_platformWindow.isNull()) + return NSDragOperationNone; + NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; QPoint qt_windowPoint(windowPoint.x, windowPoint.y); Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]); @@ -2011,6 +2079,9 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (void)draggingExited:(id )sender { + if (m_platformWindow.isNull()) + return; + QWindow *target = findEventTargetWindow(m_platformWindow->window()); if (!target) return; @@ -2025,6 +2096,9 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin // called on drop, send the drop to Qt and return if it was accepted. - (BOOL)performDragOperation:(id )sender { + if (m_platformWindow.isNull()) + return false; + QWindow *target = findEventTargetWindow(m_platformWindow->window()); if (!target) return false; @@ -2055,6 +2129,10 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin { Q_UNUSED(session); Q_UNUSED(operation); + + if (m_platformWindow.isNull()) + return; + QWindow *target = findEventTargetWindow(m_platformWindow->window()); if (!target) return; diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index 73e1f41dd5..645a93edf7 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -53,6 +53,9 @@ @implementation QNSView (QNSViewAccessibility) - (id)childAccessibleElement { + if (m_platformWindow.isNull()) + return nil; + if (!m_platformWindow->window()->accessibleRoot()) return nil; -- cgit v1.2.3 From 346cd79192ef71afa572812e17f1d422594651a0 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Thu, 10 Nov 2016 00:52:57 +0100 Subject: Make QFile::open fail when using an invalid file name Fixes the bug in QFile which allowed opening a file with reserved characters in its name. If the name is a long file path, CreateFile opens a file with a truncated name instead of failing, so we have to catch reserved characters ourselves. [ChangeLog][Windows] Fixed a bug that caused QFile to create files with truncated names if the file name was invalid. Now, QFile::open correctly fails to create such files. Task-number: QTBUG-57023 Change-Id: I01d5a7132054cecdfa839d0b8de06460039248a3 Reviewed-by: Edward Welbourne --- src/corelib/io/qfsfileengine_win.cpp | 14 ++++++++++++++ tests/auto/corelib/io/qfile/tst_qfile.cpp | 1 + 2 files changed, 15 insertions(+) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index ab651ead79..7d16e59195 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -108,6 +108,20 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) { Q_Q(QFSFileEngine); + // Check if the file name is valid: + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions + const QString fileName = fileEntry.fileName(); + for (QString::const_iterator it = fileName.constBegin(), end = fileName.constEnd(); + it != end; ++it) { + const QChar c = *it; + if (c == QLatin1Char('<') || c == QLatin1Char('>') || c == QLatin1Char(':') || + c == QLatin1Char('\"') || c == QLatin1Char('/') || c == QLatin1Char('\\') || + c == QLatin1Char('|') || c == QLatin1Char('?') || c == QLatin1Char('*')) { + q->setError(QFile::OpenError, QStringLiteral("Invalid file name")); + return false; + } + } + // All files are opened in share mode (both read and write). DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index a6da6d8e69..a23ebc8d72 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -1141,6 +1141,7 @@ void tst_QFile::invalidFile_data() #else #if !defined(Q_OS_WINRT) QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid"); + QTest::newRow( "date" ) << QString( "testLog-03:20.803Z.txt" ); #endif QTest::newRow( "colon3" ) << QString( ":failinvalid" ); QTest::newRow( "forwardslash" ) << QString( "fail/invalid" ); -- cgit v1.2.3 From 93a4bf5c8b38d02dd7489e5c0ffecf6fd3b97d34 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 17 Mar 2017 21:21:08 +0100 Subject: Blacklist also tst_QSemaphore::tryAcquireWithTimeout(2s) It has started failing recently on the CI, too. Task-number: QTBUG-58745 Change-Id: I4c8834917e6455d00c300549ed448b06da75d5bc Reviewed-by: Rafael Roquetto --- tests/auto/corelib/thread/qsemaphore/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST index 22e30d0fd6..06ae815f29 100644 --- a/tests/auto/corelib/thread/qsemaphore/BLACKLIST +++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST @@ -1,2 +1,4 @@ [tryAcquireWithTimeout:0.2s] windows +[tryAcquireWithTimeout:2s] +windows -- cgit v1.2.3 From 7eeb88a5cdcb9684e5cc123731d78e299135cd69 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 15 Mar 2017 10:56:17 +0100 Subject: When changing screen, only update the font if dpi has changed Generally, this might avoid unnecessary work in a quite common case. But if high dpi scaling is set, the dpi (in logical pixels) does not change. However this event is sent before QGuiApplicationPrivate::processWindowScreenChangedEvent has had time to change the geometry, and might cause a problem in QMenu Amends f3a4b4258f2d207b5a8e73d62822a3afe1bf8a72. Task-number: QTBUG-59484 Change-Id: Ie4ceedcb0754613cf239ae86b225c4139b70d0cc Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 17f87ef87c..b166cfe271 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9213,7 +9213,8 @@ bool QWidget::event(QEvent *event) const QWindow *win = te->window; d->setWinId((win && win->handle()) ? win->handle()->winId() : 0); } - d->updateFont(d->data.fnt); + if (d->data.fnt.d->dpi != logicalDpiY()) + d->updateFont(d->data.fnt); #ifndef QT_NO_OPENGL d->renderToTextureReallyDirty = 1; #endif -- cgit v1.2.3 From 6cd8a90d29f563ca4b61524c84d4846dae736fdd Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 14 Mar 2017 13:26:55 +0100 Subject: Include missing errno.h Fixes linux-clang-libc++ builds. Change-Id: Id75c35d858123193e7d29b0bbb113d2c109a7560 Reviewed-by: Andy Nichols --- .../platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 3723142f0b..87fb3146c7 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -49,6 +49,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) -- cgit v1.2.3 From 949bce97d04f350ee2918b7d0280d2b89e11d4bc Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Fri, 17 Mar 2017 21:05:54 +0300 Subject: QString: de-deplicate code of leftRef, rightRef, midRef Re-use methods of QStringRef. Change-Id: I5ff719c08c54246e9cafd4f9aa0823ff6df8433b Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 50893536af..48f3d64c4a 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9621,9 +9621,7 @@ QStringRef QStringRef::left(int n) const */ QStringRef QString::leftRef(int n) const { - if (uint(n) >= uint(d->size)) - n = d->size; - return QStringRef(this, 0, n); + return QStringRef(this).left(n); } /*! @@ -9660,9 +9658,7 @@ QStringRef QStringRef::right(int n) const */ QStringRef QString::rightRef(int n) const { - if (uint(n) >= uint(d->size)) - n = d->size; - return QStringRef(this, d->size - n, n); + return QStringRef(this).right(n); } /*! @@ -9721,19 +9717,7 @@ QStringRef QStringRef::mid(int pos, int n) const */ QStringRef QString::midRef(int position, int n) const { - using namespace QtPrivate; - switch (QContainerImplHelper::mid(d->size, &position, &n)) { - case QContainerImplHelper::Null: - return QStringRef(); - case QContainerImplHelper::Empty: - return QStringRef(this, 0, 0); - case QContainerImplHelper::Full: - return QStringRef(this, 0, d->size); - case QContainerImplHelper::Subset: - return QStringRef(this, position, n); - } - Q_UNREACHABLE(); - return QStringRef(); + return QStringRef(this).mid(position, n); } /*! -- cgit v1.2.3 From 38a55c781303a59be28ea96d7c6bba2a8e885b21 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 7 Mar 2017 16:47:29 -0800 Subject: QCocoaWindow: fix geometry issue when only minimumSize is set When only minimumSize was set and it matched to the size NSView was created with, viewDidChangeFrame() was not called for the window and it's internal geometry value was still (0, 0) what led to unpleasant side effects such as QML content was not displayed until something caused an update. Task-number: QTBUG-58963 Change-Id: Ib12d36d405969971e7ff62b79b50c3d78928a649 Reviewed-by: Timur Pocheptsov Reviewed-by: Qt CI Bot --- src/plugins/platforms/cocoa/qcocoawindow.mm | 7 +++++++ src/plugins/platforms/cocoa/qnsview.h | 1 + src/plugins/platforms/cocoa/qnsview.mm | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 75c13d6bbc..cfe829905c 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1636,6 +1636,13 @@ void QCocoaWindow::recreateWindowIfNeeded() [m_nsWindow setContentView:m_view]; [m_view release]; [m_view setPostsFrameChangedNotifications:YES]; + // QTBUG-58963 + // viewDidChangeFrame() should be called for each window automatically at this point because it is + // registered with Q_NOTIFICATION_HANDLER(NSViewFrameDidChangeNotification); + // The corner case when it's not called and we need to make a manual geometry update is when window's + // size is not specified explicitly but minimumSize is set and matches to the size NSView was created with. + if (QSizeF::fromCGSize(m_view.frame.size) == [QNSView defaultViewSize]) + viewDidChangeFrame(); } } diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 75a508370f..a05bd66890 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -88,6 +88,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); QSet m_acceptedKeyDowns; } ++ (QSizeF)defaultViewSize; - (id)init; - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow; #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 40efa092b3..967271be9c 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -140,7 +140,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (id) init { - self = [super initWithFrame : NSMakeRect(0,0, 300,300)]; + self = [super initWithFrame : NSMakeRect(0, 0, [[self class] defaultViewSize].width(), [[self class] defaultViewSize].height())]; if (self) { m_backingStore = 0; m_maskImage = 0; @@ -189,6 +189,11 @@ static bool _q_dontOverrideCtrlLMB = false; [super dealloc]; } ++ (QSizeF)defaultViewSize +{ + return QSizeF(300.0, 300.0); +} + - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow { self = [self init]; -- cgit v1.2.3 From 9ef14bcc3a71a95d9338d360b429cd8a4061ad3d Mon Sep 17 00:00:00 2001 From: Serge Lysenko Date: Wed, 21 Sep 2016 21:52:52 +0300 Subject: Fix Windows DnD: Wrong qApp mouse buttons state after external DnD An QApplication::mouseButtons() value could stay outdated after external DnD operations, e.g. dragging an object outside Qt application or vice versa. Also user can cancel DnD with Escape key. Task-number: QTBUG-55885 Task-number: QTBUG-59539 Change-Id: Ia6deb4ae5ccfe77e6d6c2464de40cd06fc71f9b8 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsdrag.cpp | 59 ++++++++++++++++---------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 550415e889..58175b39fa 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -412,34 +412,39 @@ QWindowsOleDropSource::Release(void) QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { - HRESULT hr = S_OK; - do { - if (fEscapePressed || QWindowsDrag::isCanceled()) { - hr = ResultFromScode(DRAGDROP_S_CANCEL); - break; - } + Qt::MouseButtons buttons = toQtMouseButtons(grfKeyState); - const Qt::MouseButtons buttons = toQtMouseButtons(grfKeyState); - if (m_currentButtons == Qt::NoButton) { - m_currentButtons = buttons; + SCODE result = S_OK; + if (fEscapePressed || QWindowsDrag::isCanceled()) { + result = DRAGDROP_S_CANCEL; + buttons = Qt::NoButton; } else { - // Button changed: Complete Drop operation. - if (!(m_currentButtons & buttons)) { - hr = ResultFromScode(DRAGDROP_S_DROP); - break; + if (buttons && !m_currentButtons) { + m_currentButtons = buttons; + } else if (!(m_currentButtons & buttons)) { // Button changed: Complete Drop operation. + result = DRAGDROP_S_DROP; } } - QGuiApplication::processEvents(); + switch (result) { + case DRAGDROP_S_DROP: + case DRAGDROP_S_CANCEL: + QGuiApplicationPrivate::modifier_buttons = toQtKeyboardModifiers(grfKeyState); + QGuiApplicationPrivate::mouse_buttons = buttons; + m_currentButtons = Qt::NoButton; + break; - } while (false); + default: + QGuiApplication::processEvents(); + break; + } - if (QWindowsContext::verbose > 1 || hr != S_OK) { + if (QWindowsContext::verbose > 1 || result != S_OK) { qCDebug(lcQpaMime) << __FUNCTION__ << "fEscapePressed=" << fEscapePressed << "grfKeyState=" << grfKeyState << "buttons" << m_currentButtons - << "returns 0x" << hex <source()) { + QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; + QGuiApplicationPrivate::mouse_buttons = Qt::NoButton; + m_lastKeyState = 0; + } QWindowsDrag::instance()->releaseDropDataObject(); return NOERROR; @@ -628,11 +639,9 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, << "keys=" << grfKeyState << "pt=" << pt.x << ',' << pt.y; m_lastPoint = QWindowsGeometryHint::mapFromGlobal(m_window, QPoint(pt.x,pt.y)); - // grfKeyState does not all ways contain button state in the drop so if - // it doesn't then use the last known button state; - if ((grfKeyState & KEY_STATE_BUTTON_MASK) == 0) - grfKeyState |= m_lastKeyState & KEY_STATE_BUTTON_MASK; - m_lastKeyState = grfKeyState; + // grfKeyState does not all ways contain button state in the drop + QGuiApplicationPrivate::mouse_buttons = toQtMouseButtons(m_lastKeyState); + QGuiApplicationPrivate::modifier_buttons = toQtKeyboardModifiers(grfKeyState); QWindowsDrag *windowsDrag = QWindowsDrag::instance(); @@ -640,6 +649,10 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(), m_lastPoint, translateToQDragDropActions(*pdwEffect)); + + QGuiApplicationPrivate::mouse_buttons = toQtMouseButtons(grfKeyState); + m_lastKeyState = grfKeyState; + if (response.isAccepted()) { const Qt::DropAction action = response.acceptedAction(); if (action == Qt::MoveAction || action == Qt::TargetMoveAction) { -- cgit v1.2.3 From c1a2f97a3b3a8c058b1760b57e5c83bf7815b84a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 17 Mar 2017 15:55:00 +0100 Subject: Set default fbo redirect correctly for QOpenGLWidget viewports Task-number: QTBUG-59318 Change-Id: Icf2ea4e5ebdeec31750edc8b34a9b9f6bfb64744 Reviewed-by: Andy Nichols --- src/widgets/kernel/qopenglwidget.cpp | 14 ++++++++++++++ .../widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 147e0774e7..23948892f0 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -537,6 +537,7 @@ public: w(widget) { } void beginPaint() Q_DECL_OVERRIDE; + void endPaint() Q_DECL_OVERRIDE; QOpenGLWidget *w; }; @@ -631,6 +632,16 @@ void QOpenGLWidgetPaintDevicePrivate::beginPaint() } } +void QOpenGLWidgetPaintDevicePrivate::endPaint() +{ + QOpenGLWidgetPrivate *wd = static_cast(QWidgetPrivate::get(w)); + if (!wd->initialized) + return; + + if (!wd->inPaintGL) + QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = 0; +} + void QOpenGLWidgetPaintDevice::ensureActiveTarget() { QOpenGLWidgetPaintDevicePrivate *d = static_cast(d_ptr.data()); @@ -643,6 +654,9 @@ void QOpenGLWidgetPaintDevice::ensureActiveTarget() else wd->fbo->bind(); + if (!wd->inPaintGL) + QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = wd->fbo->handle(); + // When used as a viewport, drawing is done via opening a QPainter on the widget // without going through paintEvent(). We will have to make sure a glFlush() is done // before the texture is accessed also in this case. diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index e3e26d612f..f13291d0a9 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -282,6 +282,13 @@ protected: void CountingGraphicsView::drawForeground(QPainter *, const QRectF &) { ++m_count; + + // QTBUG-59318: verify that the context's internal default fbo redirection + // is active also when using the QOpenGLWidget as a viewport. + GLint currentFbo = -1; + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFbo); + GLuint defFbo = QOpenGLContext::currentContext()->defaultFramebufferObject(); + QCOMPARE(GLuint(currentFbo), defFbo); } void tst_QOpenGLWidget::asViewport() -- cgit v1.2.3