diff options
154 files changed, 1208 insertions, 1143 deletions
diff --git a/.gitignore b/.gitignore index f98f90d292..f133a2124e 100644 --- a/.gitignore +++ b/.gitignore @@ -245,6 +245,7 @@ tags *.gcda *.gcno *.lib +!Info.plist.lib *.o *.obj *.orig diff --git a/config_help.txt b/config_help.txt index f06584a480..6b1401c618 100644 --- a/config_help.txt +++ b/config_help.txt @@ -82,7 +82,7 @@ Build options: -debug-and-release ... Build two versions of Qt, with and without debugging turned on [yes] (Apple and Windows only) -optimize-debug ...... Enable debug-friendly optimizations in debug builds - [auto] (Not supported with MSVC) + [auto] (Not supported with MSVC or Clang toolchains) -optimize-size ....... Optimize release builds for size instead of speed [no] -optimized-tools ..... Build optimized host tools even in debug build [no] -force-debug-info .... Create symbol files for release builds [no] diff --git a/configure.json b/configure.json index 26e1572f32..c73369e6f6 100644 --- a/configure.json +++ b/configure.json @@ -704,7 +704,7 @@ }, "optimize_debug": { "label": "Optimize debug build", - "condition": "!config.msvc && (features.debug || features.debug_and_release) && tests.optimize_debug", + "condition": "!config.msvc && !config.clang && (features.debug || features.debug_and_release) && tests.optimize_debug", "output": [ "privateConfig" ] }, "optimize_size": { @@ -1352,7 +1352,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 { "type": "feature", "args": "optimize_debug", - "condition": "!config.msvc && (features.debug || features.debug_and_release)" + "condition": "!config.msvc && !config.clang && (features.debug || features.debug_and_release)" }, { "type": "feature", diff --git a/doc/src/images/appchooser-example.png b/doc/src/images/appchooser-example.png Binary files differdeleted file mode 100644 index 885476e8b9..0000000000 --- a/doc/src/images/appchooser-example.png +++ /dev/null diff --git a/doc/src/images/customsortfiltermodel-example.png b/doc/src/images/customsortfiltermodel-example.png Binary files differindex d7ee8bd7e7..7c0750eb57 100644 --- a/doc/src/images/customsortfiltermodel-example.png +++ b/doc/src/images/customsortfiltermodel-example.png diff --git a/doc/src/images/lightingeffect-example.png b/doc/src/images/lightingeffect-example.png Binary files differdeleted file mode 100644 index d9dc990481..0000000000 --- a/doc/src/images/lightingeffect-example.png +++ /dev/null diff --git a/doc/src/images/validators.png b/doc/src/images/validators.png Binary files differnew file mode 100644 index 0000000000..1940c6da3f --- /dev/null +++ b/doc/src/images/validators.png diff --git a/examples/widgets/animation/animation.pro b/examples/widgets/animation/animation.pro index a13f8bb65a..19b79caf15 100644 --- a/examples/widgets/animation/animation.pro +++ b/examples/widgets/animation/animation.pro @@ -2,7 +2,6 @@ TEMPLATE = \ subdirs SUBDIRS += \ animatedtiles \ - appchooser \ easing \ moveblocks \ states \ diff --git a/examples/widgets/animation/appchooser/accessories-dictionary.png b/examples/widgets/animation/appchooser/accessories-dictionary.png Binary files differdeleted file mode 100644 index e9bd55d918..0000000000 --- a/examples/widgets/animation/appchooser/accessories-dictionary.png +++ /dev/null diff --git a/examples/widgets/animation/appchooser/akregator.png b/examples/widgets/animation/appchooser/akregator.png Binary files differdeleted file mode 100644 index a086f45ab6..0000000000 --- a/examples/widgets/animation/appchooser/akregator.png +++ /dev/null diff --git a/examples/widgets/animation/appchooser/appchooser.pro b/examples/widgets/animation/appchooser/appchooser.pro deleted file mode 100644 index 674e623b2d..0000000000 --- a/examples/widgets/animation/appchooser/appchooser.pro +++ /dev/null @@ -1,8 +0,0 @@ -QT += widgets - -SOURCES = main.cpp -RESOURCES = appchooser.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/animation/appchooser -INSTALLS += target diff --git a/examples/widgets/animation/appchooser/appchooser.qrc b/examples/widgets/animation/appchooser/appchooser.qrc deleted file mode 100644 index 28a3e1c4c1..0000000000 --- a/examples/widgets/animation/appchooser/appchooser.qrc +++ /dev/null @@ -1,8 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>accessories-dictionary.png</file> - <file>akregator.png</file> - <file>digikam.png</file> - <file>k3b.png</file> -</qresource> -</RCC> diff --git a/examples/widgets/animation/appchooser/digikam.png b/examples/widgets/animation/appchooser/digikam.png Binary files differdeleted file mode 100644 index 9de9fb2f80..0000000000 --- a/examples/widgets/animation/appchooser/digikam.png +++ /dev/null diff --git a/examples/widgets/animation/appchooser/k3b.png b/examples/widgets/animation/appchooser/k3b.png Binary files differdeleted file mode 100644 index bbcafcfba1..0000000000 --- a/examples/widgets/animation/appchooser/k3b.png +++ /dev/null diff --git a/examples/widgets/animation/appchooser/main.cpp b/examples/widgets/animation/appchooser/main.cpp deleted file mode 100644 index 71c869f6a2..0000000000 --- a/examples/widgets/animation/appchooser/main.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore> -#include <QtWidgets> - - -class Pixmap : public QGraphicsWidget -{ - Q_OBJECT - -public: - Pixmap(const QPixmap &pix, QGraphicsItem *parent = 0) - : QGraphicsWidget(parent), orig(pix), p(pix) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override - { - painter->drawPixmap(QPointF(), p); - } - - void mousePressEvent(QGraphicsSceneMouseEvent *) override - { - emit clicked(); - } - - void setGeometry(const QRectF &rect) override - { - QGraphicsWidget::setGeometry(rect); - - if (rect.size().width() > orig.size().width()) - p = orig.scaled(rect.size().toSize()); - else - p = orig; - } - -Q_SIGNALS: - void clicked(); - -private: - QPixmap orig; - QPixmap p; -}; - -class GraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - GraphicsView(QGraphicsScene *scene, QWidget *parent = 0) : QGraphicsView(scene, parent) - { - } - - void resizeEvent(QResizeEvent *) override - { - fitInView(sceneRect(), Qt::KeepAspectRatio); - } -}; - - -void createStates(const QObjectList &objects, - const QRect &selectedRect, QState *parent) -{ - for (int i = 0; i < objects.size(); ++i) { - QState *state = new QState(parent); - state->assignProperty(objects.at(i), "geometry", selectedRect); - parent->addTransition(objects.at(i), SIGNAL(clicked()), state); - } -} - -void createAnimations(const QObjectList &objects, QStateMachine *machine) -{ - for (int i=0; i<objects.size(); ++i) - machine->addDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry")); -} - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(appchooser); - - QApplication app(argc, argv); - - Pixmap *p1 = new Pixmap(QPixmap(":/digikam.png")); - Pixmap *p2 = new Pixmap(QPixmap(":/akregator.png")); - Pixmap *p3 = new Pixmap(QPixmap(":/accessories-dictionary.png")); - Pixmap *p4 = new Pixmap(QPixmap(":/k3b.png")); - - p1->setObjectName("p1"); - p2->setObjectName("p2"); - p3->setObjectName("p3"); - p4->setObjectName("p4"); - - p1->setGeometry(QRectF( 0.0, 0.0, 64.0, 64.0)); - p2->setGeometry(QRectF(236.0, 0.0, 64.0, 64.0)); - p3->setGeometry(QRectF(236.0, 236.0, 64.0, 64.0)); - p4->setGeometry(QRectF( 0.0, 236.0, 64.0, 64.0)); - - QGraphicsScene scene(0, 0, 300, 300); - scene.setBackgroundBrush(Qt::white); - scene.addItem(p1); - scene.addItem(p2); - scene.addItem(p3); - scene.addItem(p4); - - GraphicsView window(&scene); - window.setFrameStyle(0); - window.setAlignment(Qt::AlignLeft | Qt::AlignTop); - window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - QStateMachine machine; - machine.setGlobalRestorePolicy(QState::RestoreProperties); - - QState *group = new QState(&machine); - group->setObjectName("group"); - - QRect selectedRect(86, 86, 128, 128); - - QState *idleState = new QState(group); - group->setInitialState(idleState); - - QObjectList objects; - objects << p1 << p2 << p3 << p4; - createStates(objects, selectedRect, group); - createAnimations(objects, &machine); - - machine.setInitialState(group); - machine.start(); - - window.resize(300, 300); - window.show(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/widgets/doc/images/addressbook-editdialog.png b/examples/widgets/doc/images/addressbook-editdialog.png Binary files differindex fd41ee63f7..7434aa44ef 100644 --- a/examples/widgets/doc/images/addressbook-editdialog.png +++ b/examples/widgets/doc/images/addressbook-editdialog.png diff --git a/examples/widgets/doc/images/addressbook-example.png b/examples/widgets/doc/images/addressbook-example.png Binary files differindex b743c166da..eebe97a718 100644 --- a/examples/widgets/doc/images/addressbook-example.png +++ b/examples/widgets/doc/images/addressbook-example.png diff --git a/examples/widgets/doc/images/addressbook-newaddresstab.png b/examples/widgets/doc/images/addressbook-newaddresstab.png Binary files differindex ff215a4b20..6b60ee08e9 100644 --- a/examples/widgets/doc/images/addressbook-newaddresstab.png +++ b/examples/widgets/doc/images/addressbook-newaddresstab.png diff --git a/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png b/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png Binary files differindex 543670e05c..e4bed44edf 100644 --- a/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png +++ b/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png diff --git a/examples/widgets/doc/src/appchooser.qdoc b/examples/widgets/doc/src/appchooser.qdoc deleted file mode 100644 index e74860214a..0000000000 --- a/examples/widgets/doc/src/appchooser.qdoc +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example animation/appchooser - \title Application Chooser Example - - \brief The Application Chooser example shows how to use the Qt state - machine and the animation framework to select between - applications. - - \image appchooser-example.png - -*/ diff --git a/examples/widgets/doc/src/customsortfiltermodel.qdoc b/examples/widgets/doc/src/customsortfiltermodel.qdoc index 0eb6560e10..6eab846e89 100644 --- a/examples/widgets/doc/src/customsortfiltermodel.qdoc +++ b/examples/widgets/doc/src/customsortfiltermodel.qdoc @@ -75,7 +75,7 @@ QSortFilterProxyModel's default implementations of functions are written so that they call the equivalent functions in the relevant source model. This simple proxying mechanism may need to be - overridden for source models with more complex behavior; in this + overridden for source models with more complex behavior. In this example we derive from the QSortFilterProxyModel class to ensure that our filter can recognize a valid range of dates, and to control the sorting behavior. @@ -170,7 +170,7 @@ We implement two private slots, \c textFilterChanged() and \c dateFilterChanged(), to respond to the user changing the filter - pattern, case sensitivity or any of the dates. In addition, we + pattern, case sensitivity, or any of the dates. In addition, we implement a public \c setSourceModel() convenience function to set up the model/ view relation. @@ -197,7 +197,7 @@ \snippet itemviews/customsortfiltermodel/window.cpp 1 The QTreeView class provides a default model/view implementation - of a tree view; our view implements a tree representation of items + of a tree view. Our view implements a tree representation of items in the application's source model. \snippet itemviews/customsortfiltermodel/window.cpp 2 diff --git a/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc b/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc index 866dac442b..fd0427fdc0 100644 --- a/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc +++ b/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc @@ -35,4 +35,50 @@ QGraphicsAnchorLayout class. \image graphicssimpleanchorlayout-example.png + + The example starts by creating a QGraphicsScene (\c scene), 3 widgets + (\c a, \c b, and \c c), and a QGraphicsAnchorlayout (\c layout). + + \quotefromfile graphicsview/simpleanchorlayout/main.cpp + \skipto QGraphicsScene + \printuntil QGraphicsAnchorLayout + + First it anchors the top left corner of item \c a to the top left + corner of \c layout. This can be done in two steps: + + \skipto layout->addAnchor(a + \printto adding + + Or in one step: + + \skipuntil [adding a corner anchor] + \printline layout->addCornerAnchors(a, Qt::T + + Then the right anchor of \c a is anchored to the left anchor of + \c b, and the top of item \c b is anchored to the bottom of \c a. + + \skipuntil [adding anchors] + \printto adding anchors + + Place a third widget \c c under widget \c b: + + \skipuntil third widget + \printline AnchorBottom + + Items \c b and \c c are anchored to each other horizontally: + + \skipto Qt::Horizontal + \printline Qt::Horizontal + + Item c is anchored to the bottom right point of \c layout + + \skipuntil corner of the layout + \printline Qt::BottomRightCorner + + Finally, QGraphicsWidget \c w is displayed in QGraphicsView \c view. + + \skipto QGraphicsWidget + \printuntil app.exec() + + \sa {Anchor Layout Example} */ diff --git a/examples/widgets/doc/src/lighting.qdoc b/examples/widgets/doc/src/lighting.qdoc deleted file mode 100644 index 994172cf5d..0000000000 --- a/examples/widgets/doc/src/lighting.qdoc +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example effects/lighting - \title Lighting Effect Example - \ingroup examples-graphicsview-graphicseffects - \brief Demonstrates how to apply effects on items in the view - - \image lightingeffect-example.png -*/ diff --git a/examples/widgets/doc/src/stardelegate.qdoc b/examples/widgets/doc/src/stardelegate.qdoc index dcc7080456..44d17662ca 100644 --- a/examples/widgets/doc/src/stardelegate.qdoc +++ b/examples/widgets/doc/src/stardelegate.qdoc @@ -37,7 +37,7 @@ When displaying data in a QListView, QTableView, or QTreeView, the individual items are drawn by a \l{Delegate Classes}{delegate}. Also, when the user starts - editing an item (e.g., by double-clicking the item), the delegate + editing an item (for example, by double-clicking the item), the delegate provides an editor widget that is placed on top of the item while editing takes place. @@ -96,9 +96,9 @@ QItemDelegate paint it for us. This ensures that the \c StarDelegate can handle the most common data types. - In the case where the item is a \c StarRating, we draw the - background if the item is selected, and we draw the item using \c - StarRating::paint(), which we will review later. + If the item is a \c StarRating, we draw the background if the + item is selected, and we draw the item using \c StarRating::paint(), + which we will review later. \c{StartRating}s can be stored in a QVariant thanks to the Q_DECLARE_METATYPE() macro appearing in \c starrating.h. More on @@ -133,8 +133,8 @@ We simply call \c setStarRating() on the editor. The \l{QAbstractItemDelegate::}{setModelData()} function is - called when editing is finished, to commit data from the editor - to the model: + called to commit data from the editor to the model when editing + is finished: \snippet itemviews/stardelegate/stardelegate.cpp 4 @@ -210,7 +210,7 @@ current rating, and \c myMaxStarCount stores the highest possible rating (typically 5). - The Q_DECLARE_METATYPE() macro makes the type \c StarRating known + The \c Q_DECLARE_METATYPE() macro makes the type \c StarRating known to QVariant, making it possible to store \c StarRating values in QVariant. @@ -283,7 +283,7 @@ \list \li It is possible to open editors programmatically by calling QAbstractItemView::edit(), instead of relying on edit - triggers. This could be use to support other edit triggers + triggers. This could be used to support other edit triggers than those offered by the QAbstractItemView::EditTrigger enum. For example, in the Star Delegate example, hovering over an item with the mouse might make sense as a way to pop up an diff --git a/examples/widgets/doc/src/stylesheet.qdoc b/examples/widgets/doc/src/stylesheet.qdoc index 0016836f0d..a86b697059 100644 --- a/examples/widgets/doc/src/stylesheet.qdoc +++ b/examples/widgets/doc/src/stylesheet.qdoc @@ -33,5 +33,56 @@ \borderedimage stylesheet-pagefold.png \caption Screen Shot of the Pagefold style sheet + + The Style Sheet example shows how widgets can be styled using Qt Style Sheets. + You can open the style editor by selecting \uicontrol File > \uicontrol Edit Style Sheet, + to select an existing style sheet or design your own style and load it. + + The Style Sheet example consists of 2 classes: + \list + \li \c MainWindow + \li \c StyleSheetEditor + \endlist + + + \section1 MainWindow Class + + \c MainWindow inherits QWidget, and is the application's main window defined in + \c mainwindow.ui. The style of \c MainWindow can be modified with \l StyleSheetEditor. + + + \section1 StyleSheetEditor Class + + \c StyleSheetEditor enables you to open an editor where you can load an existing style sheet. + It is also possible to define a new stylesheet and load it. Its layout is defined in + \c stylesheeteditor.ui. + + \quotefromfile widgets/stylesheet/stylesheeteditor.cpp + \skipto on_styleCombo_activated + \printline on_styleCombo_activated + + Sets the specified \a styleName and grays the \c applyButton. + + \skipto on_styleSheetCombo_activated + \printline on_styleSheetCombo_activated + + Loads the stylesheet from \c styleSheetName. + + \skipto on_styleTextEdit_textChanged() + \printline on_styleTextEdit_textChanged() + + Enables the \c applyButton when the text in the buffer has changed. + + \skipto on_applyButton_clicked() + \printline on_applyButton_clicked() + + Sets the stylesheet properties in \l qApp and disables the \c applyButton. + + \skipto loadStyleSheet(const QString &sheetName) + \printline loadStyleSheet(const QString &sheetName) + + Loads the specified \a sheetName, and sets its properties in + \l qApp. + */ diff --git a/examples/widgets/doc/src/validators.qdoc b/examples/widgets/doc/src/validators.qdoc index f3f4dc5e63..bbb2e5f7b6 100644 --- a/examples/widgets/doc/src/validators.qdoc +++ b/examples/widgets/doc/src/validators.qdoc @@ -31,4 +31,6 @@ \ingroup examples-widgets \brief The Validators example shows the signal emission behavior of input validators. + + \borderedimage validators.png */ diff --git a/examples/widgets/effects/effects.pro b/examples/widgets/effects/effects.pro index 795e0508ac..05911979b9 100644 --- a/examples/widgets/effects/effects.pro +++ b/examples/widgets/effects/effects.pro @@ -2,5 +2,4 @@ TEMPLATE = \ subdirs SUBDIRS = \ blurpicker \ - lighting \ fademessage diff --git a/examples/widgets/effects/lighting/lighting.cpp b/examples/widgets/effects/lighting/lighting.cpp deleted file mode 100644 index 1ba7dd9ce7..0000000000 --- a/examples/widgets/effects/lighting/lighting.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "lighting.h" -#include <QtWidgets> -#include <QtCore/qmath.h> - -Lighting::Lighting(QWidget *parent): QGraphicsView(parent), angle(0.0) -{ - setScene(&m_scene); - - setupScene(); - - QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), SLOT(animate())); - timer->setInterval(30); - timer->start(); - - setRenderHint(QPainter::Antialiasing, true); - setFrameStyle(QFrame::NoFrame); -} - -void Lighting::setupScene() -{ - m_scene.setSceneRect(-300, -200, 600, 460); - - QLinearGradient linearGrad(QPointF(-100, -100), QPointF(100, 100)); - linearGrad.setColorAt(0, QColor(255, 255, 255)); - linearGrad.setColorAt(1, QColor(192, 192, 255)); - setBackgroundBrush(linearGrad); - - QRadialGradient radialGrad(30, 30, 30); - radialGrad.setColorAt(0, Qt::yellow); - radialGrad.setColorAt(0.2, Qt::yellow); - radialGrad.setColorAt(1, Qt::transparent); - QPixmap pixmap(60, 60); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - painter.setPen(Qt::NoPen); - painter.setBrush(radialGrad); - painter.drawEllipse(0, 0, 60, 60); - painter.end(); - - m_lightSource = m_scene.addPixmap(pixmap); - m_lightSource->setZValue(2); - - for (int i = -2; i < 3; ++i) - for (int j = -2; j < 3; ++j) { - QAbstractGraphicsShapeItem *item; - if ((i + j) & 1) - item = new QGraphicsEllipseItem(0, 0, 50, 50); - else - item = new QGraphicsRectItem(0, 0, 50, 50); - - item->setPen(QPen(Qt::black, 1)); - item->setBrush(QBrush(Qt::white)); - QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; - effect->setBlurRadius(8); - item->setGraphicsEffect(effect); - item->setZValue(1); - item->setPos(i * 80, j * 80); - m_scene.addItem(item); - m_items << item; - } - - -} - -void Lighting::animate() -{ - angle += qDegreesToRadians(qreal(6)); - qreal xs = 200 * qSin(angle) - 40 + 25; - qreal ys = 200 * qCos(angle) - 40 + 25; - m_lightSource->setPos(xs, ys); - - for (int i = 0; i < m_items.size(); ++i) { - QGraphicsItem *item = m_items.at(i); - Q_ASSERT(item); - QGraphicsDropShadowEffect *effect = static_cast<QGraphicsDropShadowEffect *>(item->graphicsEffect()); - Q_ASSERT(effect); - - QPointF delta(item->x() - xs, item->y() - ys); - effect->setOffset(delta.toPoint() / 30); - - qreal dx = delta.x(); - qreal dy = delta.y(); - qreal dd = qSqrt(dx * dx + dy * dy); - QColor color = effect->color(); - color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7)); - effect->setColor(color); - } - - m_scene.update(); -} - -void Lighting::resizeEvent(QResizeEvent * /* event */) -{ -} diff --git a/examples/widgets/effects/lighting/lighting.h b/examples/widgets/effects/lighting/lighting.h deleted file mode 100644 index 615824d46f..0000000000 --- a/examples/widgets/effects/lighting/lighting.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIGHTING_H -#define LIGHTING_H - -#include <QGraphicsEffect> -#include <QGraphicsView> - -class Lighting: public QGraphicsView -{ - Q_OBJECT - -public: - Lighting(QWidget *parent = 0); - -private slots: - void animate(); - -private: - void setupScene(); - -protected: - void resizeEvent(QResizeEvent *event) override; - -private: - qreal angle; - QGraphicsScene m_scene; - QGraphicsItem *m_lightSource; - QList<QGraphicsItem*> m_items; -}; - -#endif // LIGHTING_H diff --git a/examples/widgets/effects/lighting/lighting.pro b/examples/widgets/effects/lighting/lighting.pro deleted file mode 100644 index 0a3b397de5..0000000000 --- a/examples/widgets/effects/lighting/lighting.pro +++ /dev/null @@ -1,8 +0,0 @@ -QT += widgets - -SOURCES += main.cpp lighting.cpp -HEADERS += lighting.h - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/effects/lighting -INSTALLS += target diff --git a/examples/widgets/effects/lighting/main.cpp b/examples/widgets/effects/lighting/main.cpp deleted file mode 100644 index 22e55c0985..0000000000 --- a/examples/widgets/effects/lighting/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "lighting.h" -#include <QApplication> - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - Lighting lighting; - lighting.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Lighting and Shadows")); - - lighting.resize(640, 480); - lighting.show(); - - return app.exec(); -} diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp index e47bc9d251..20f6eb3c6d 100644 --- a/examples/widgets/painting/affine/xform.cpp +++ b/examples/widgets/painting/affine/xform.cpp @@ -77,8 +77,8 @@ XFormView::XFormView(QWidget *parent) pts->setBoundingRect(QRectF(0, 0, 500, 500)); ctrlPoints << QPointF(250, 250) << QPointF(350, 250); pts->setPoints(ctrlPoints); - connect(pts, SIGNAL(pointsChanged(QPolygonF)), - this, SLOT(updateCtrlPoints(QPolygonF))); + connect(pts, &HoverPoints::pointsChanged, + this,&XFormView::updateCtrlPoints); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } @@ -876,29 +876,29 @@ XFormWidget::XFormWidget(QWidget *parent) #endif mainGroupLayout->addWidget(whatsThisButton); - connect(rotateSlider, SIGNAL(valueChanged(int)), view, SLOT(changeRotation(int))); - connect(shearSlider, SIGNAL(valueChanged(int)), view, SLOT(changeShear(int))); - connect(scaleSlider, SIGNAL(valueChanged(int)), view, SLOT(changeScale(int))); - - connect(vectorType, SIGNAL(clicked()), view, SLOT(setVectorType())); - connect(pixmapType, SIGNAL(clicked()), view, SLOT(setPixmapType())); - connect(textType, SIGNAL(clicked()), view, SLOT(setTextType())); - connect(textType, SIGNAL(toggled(bool)), textEditor, SLOT(setEnabled(bool))); - connect(textEditor, SIGNAL(textChanged(QString)), view, SLOT(setText(QString))); - - connect(view, SIGNAL(rotationChanged(int)), rotateSlider, SLOT(setValue(int))); - connect(view, SIGNAL(scaleChanged(int)), scaleSlider, SLOT(setValue(int))); - connect(view, SIGNAL(shearChanged(int)), shearSlider, SLOT(setValue(int))); - - connect(resetButton, SIGNAL(clicked()), view, SLOT(reset())); - connect(animateButton, SIGNAL(clicked(bool)), view, SLOT(setAnimation(bool))); - connect(whatsThisButton, SIGNAL(clicked(bool)), view, SLOT(setDescriptionEnabled(bool))); - connect(whatsThisButton, SIGNAL(clicked(bool)), view->hoverPoints(), SLOT(setDisabled(bool))); - connect(view, SIGNAL(descriptionEnabledChanged(bool)), view->hoverPoints(), SLOT(setDisabled(bool))); - connect(view, SIGNAL(descriptionEnabledChanged(bool)), whatsThisButton, SLOT(setChecked(bool))); - connect(showSourceButton, SIGNAL(clicked()), view, SLOT(showSource())); + connect(rotateSlider, &QSlider::valueChanged, view, &XFormView::changeRotation); + connect(shearSlider, &QSlider::valueChanged, view, &XFormView::changeShear); + connect(scaleSlider, &QSlider::valueChanged, view, &XFormView::changeScale); + + connect(vectorType, &QRadioButton::clicked, view, &XFormView::setVectorType); + connect(pixmapType, &QRadioButton::clicked, view, &XFormView::setPixmapType); + connect(textType, &QRadioButton::clicked, view, &XFormView::setTextType); + connect(textType, &QRadioButton::toggled, textEditor, &XFormView::setEnabled); + connect(textEditor, &QLineEdit::textChanged, view, &XFormView::setText); + + connect(view, &XFormView::rotationChanged, rotateSlider, &QSlider::setValue); + connect(view, &XFormView::scaleChanged, scaleSlider, &QAbstractSlider::setValue); + connect(view, &XFormView::shearChanged, shearSlider, &QAbstractSlider::setValue); + + connect(resetButton, &QPushButton::clicked, view, &XFormView::reset); + connect(animateButton, &QPushButton::clicked, view, &XFormView::setAnimation); + connect(whatsThisButton, &QPushButton::clicked, view, &ArthurFrame::setDescriptionEnabled); + connect(whatsThisButton, &QPushButton::clicked, view->hoverPoints(), &HoverPoints::setDisabled); + connect(view, &XFormView::descriptionEnabledChanged, view->hoverPoints(), &HoverPoints::setDisabled); + connect(view, &XFormView::descriptionEnabledChanged, whatsThisButton, &QPushButton::setChecked); + connect(showSourceButton, &QPushButton::clicked, view, &XFormView::showSource); #ifdef QT_OPENGL_SUPPORT - connect(enableOpenGLButton, SIGNAL(clicked(bool)), view, SLOT(enableOpenGL(bool))); + connect(enableOpenGLButton, &QPushButton::clicked, view, &XFormView::enableOpenGL); #endif view->loadSourceFile(":res/affine/xform.cpp"); view->loadDescription(":res/affine/xform.html"); diff --git a/examples/widgets/widgets/tablet/mainwindow.cpp b/examples/widgets/widgets/tablet/mainwindow.cpp index 0d63ac316b..feae16dd83 100644 --- a/examples/widgets/widgets/tablet/mainwindow.cpp +++ b/examples/widgets/widgets/tablet/mainwindow.cpp @@ -60,6 +60,7 @@ MainWindow::MainWindow(TabletCanvas *canvas) createMenus(); setWindowTitle(tr("Tablet Example")); setCentralWidget(m_canvas); + QCoreApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents); } //! [0] @@ -97,6 +98,11 @@ void MainWindow::setSaturationValuator(QAction *action) } //! [4] +void MainWindow::setEventCompression(bool compress) +{ + QCoreApplication::setAttribute(Qt::AA_CompressTabletEvents, compress); +} + //! [5] void MainWindow::save() { @@ -220,6 +226,10 @@ void MainWindow::createMenus() connect(colorSaturationGroup, &QActionGroup::triggered, this, &MainWindow::setSaturationValuator); + QAction *compressAction = tabletMenu->addAction(tr("Co&mpress events")); + compressAction->setCheckable(true); + connect(compressAction, &QAction::toggled, this, &MainWindow::setEventCompression); + QMenu *helpMenu = menuBar()->addMenu("&Help"); helpMenu->addAction(tr("A&bout"), this, &MainWindow::about); helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt); diff --git a/examples/widgets/widgets/tablet/mainwindow.h b/examples/widgets/widgets/tablet/mainwindow.h index 68af1f1687..4b99324f04 100644 --- a/examples/widgets/widgets/tablet/mainwindow.h +++ b/examples/widgets/widgets/tablet/mainwindow.h @@ -71,6 +71,7 @@ private slots: void setAlphaValuator(QAction *action); void setLineWidthValuator(QAction *action); void setSaturationValuator(QAction *action); + void setEventCompression(bool compress); void save(); void load(); void about(); diff --git a/mkspecs/common/msvc-desktop.conf b/mkspecs/common/msvc-desktop.conf index f7f7e54d26..20f594c601 100644 --- a/mkspecs/common/msvc-desktop.conf +++ b/mkspecs/common/msvc-desktop.conf @@ -1,10 +1,14 @@ # -# qmake configuration for Microsoft Visual Studio C/C++ Compiler -# This mkspec is used by the win32-msvc and win32-clang-msvc specs +# This file is used as a basis for the following compilers: # - +# - Microsoft C/C++ Optimizing Compiler (all desktop versions) +# - Intel C++ Compiler on Windows +# - Clang-cl +# +# Baseline: +# +# - Visual Studio 2005 (8.0), VC++ 14.0 # -# Baseline: Visual Studio 2005 (8.0), VC++ 14.0 # Version-specific settings go in msvc-version.conf (loaded by default_pre) # diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf index 884286ea30..36ec1c5c78 100644 --- a/mkspecs/win32-g++/qmake.conf +++ b/mkspecs/win32-g++/qmake.conf @@ -1,7 +1,7 @@ # # qmake configuration for win32-g++ # -# Written for MinGW / gcc 4.6 or higher +# Written for MinGW-w64 / gcc 5.3 or higher # # Cross compile example for i686-w64-mingw32-g++: # configure -xplatform win32-g++ -device-option CROSS_COMPILE=i686-w64-mingw32- diff --git a/mkspecs/win32-icc/qmake.conf b/mkspecs/win32-icc/qmake.conf index 863fd77ea9..8c14a6609e 100644 --- a/mkspecs/win32-icc/qmake.conf +++ b/mkspecs/win32-icc/qmake.conf @@ -1,16 +1,17 @@ # # qmake configuration for win32-icc # -# Written for Intel C++ +# Written for Intel C++ Compiler on Windows / icl 16.0 or higher # -# Use the Visual Studio configuration +# Use the Microsoft (R) C/C++ Optimizing Compiler configuration, +# since ICC on Windows pretends to be MSVC include(../common/msvc-desktop.conf) -# Now override with the Intel compiler settings +# modifications to msvc-desktop.conf -QMAKE_COMPILER += intel_icl # icl pretends to be msvc +QMAKE_COMPILER += intel_icl QMAKE_CC = icl QMAKE_CFLAGS = -nologo -Zm200 /Qprec /Qwd1744,1738,809,3373 diff --git a/mkspecs/win32-msvc/qmake.conf b/mkspecs/win32-msvc/qmake.conf index 1d8b8f0e97..5c38330add 100644 --- a/mkspecs/win32-msvc/qmake.conf +++ b/mkspecs/win32-msvc/qmake.conf @@ -1,7 +1,7 @@ # # qmake configuration for win32-msvc # -# Written for Microsoft Visual C++ (all desktop versions) +# Written for Microsoft C/C++ Optimizing Compiler (all desktop versions) # include(../common/msvc-desktop.conf) diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp index 0173311bc6..5118bdbe9c 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp @@ -2645,7 +2645,7 @@ bool Renderer11::getShareHandleSupport() const if (deviceType == d3d11::ANGLE_D3D11_DEVICE_TYPE_WARP) { -#if !defined(ANGLE_ENABLE_WINDOWS_STORE) && !defined(__GNUC__) +#ifndef ANGLE_ENABLE_WINDOWS_STORE if (!IsWindows8OrGreater()) { // WARP on Windows 7 doesn't support shared handles diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index f15c7f3a97..1cf3bca5f7 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -500,15 +500,16 @@ public class QtNative } } - static public void sendGenericMotionEvent(MotionEvent event, int id) + static public boolean sendGenericMotionEvent(MotionEvent event, int id) { if (event.getActionMasked() != MotionEvent.ACTION_SCROLL || (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != InputDevice.SOURCE_CLASS_POINTER) { - return; + return false; } mouseWheel(id, (int) event.getX(), (int) event.getY(), event.getAxisValue(MotionEvent.AXIS_HSCROLL), event.getAxisValue(MotionEvent.AXIS_VSCROLL)); + return true; } public static Context getContext() { diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java b/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java index e994002dd3..08b5a80f7e 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java @@ -116,7 +116,6 @@ public class QtSurface extends SurfaceView implements SurfaceHolder.Callback @Override public boolean onGenericMotionEvent(MotionEvent event) { - QtNative.sendGenericMotionEvent(event, getId()); - return true; + return QtNative.sendGenericMotionEvent(event, getId()); } } diff --git a/src/angle/patches/0002-ANGLE-Fix-compilation-with-MinGW.patch b/src/angle/patches/0002-ANGLE-Fix-compilation-with-MinGW.patch index dc091b0497..f42ff2141b 100644 --- a/src/angle/patches/0002-ANGLE-Fix-compilation-with-MinGW.patch +++ b/src/angle/patches/0002-ANGLE-Fix-compilation-with-MinGW.patch @@ -405,15 +405,6 @@ index ea84783..62badcc 100644 if (mD3d11Module) { -@@ -2618,7 +2642,7 @@ bool Renderer11::getShareHandleSupport() const - - if (deviceType == d3d11::ANGLE_D3D11_DEVICE_TYPE_WARP) - { --#ifndef ANGLE_ENABLE_WINDOWS_STORE -+#if !defined(ANGLE_ENABLE_WINDOWS_STORE) && !defined(__GNUC__) - if (!IsWindows8OrGreater()) - { - // WARP on Windows 7 doesn't support shared handles diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h index 62e9816..b4e7761 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.h diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 489bc75511..8b65db95cb 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -137,6 +137,9 @@ function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target DEPENDS ${infile} ${moc_depends} ${_moc_working_dir} VERBATIM) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON) endfunction() @@ -155,7 +158,6 @@ function(QT5_GENERATE_MOC infile outfile ) set(moc_target ${ARGV3}) endif() qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "") - set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file endfunction() @@ -246,6 +248,7 @@ function(QT5_ADD_BINARY_RESOURCES target ) get_filename_component(infile ${it} ABSOLUTE) _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON) set(infiles ${infiles} ${infile}) set(out_depends ${out_depends} ${_out_depends}) set(rc_depends ${rc_depends} ${_rc_depends}) @@ -255,7 +258,6 @@ function(QT5_ADD_BINARY_RESOURCES target ) COMMAND ${Qt5Core_RCC_EXECUTABLE} ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles} DEPENDS ${rc_depends} ${out_depends} VERBATIM) - add_custom_target(${target} ALL DEPENDS ${rcc_destination}) endfunction() @@ -283,12 +285,15 @@ function(QT5_ADD_RESOURCES outfiles ) set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp) _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON) add_custom_command(OUTPUT ${outfile} COMMAND ${Qt5Core_RCC_EXECUTABLE} ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile} MAIN_DEPENDENCY ${infile} DEPENDS ${_rc_depends} "${out_depends}" VERBATIM) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON) list(APPEND ${outfiles} ${outfile}) endforeach() set(${outfiles} ${${outfiles}} PARENT_SCOPE) diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index 3d09e3618e..63918afbcd 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -810,6 +810,18 @@ void Widget::splitCaseSensitiveFunction() QStringList list2 = str.split(',', QString::SkipEmptyParts); // list2: [ "a", "b", "c" ] //! [62] + + //! [62-empty] + QString str = "abc"; + auto parts = str.split(""); + // parts: {"", "a", "b", "c", ""} + //! [62-empty] + + //! [62-slashes] + QString str = "/a/b/c/"; + auto parts = str.split('/'); + // parts: {"", "a", "b", "c", ""} + //! [62-slashes] } void Widget::sprintfFunction() diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index feeb488acd..72b0a689ff 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -150,7 +150,7 @@ public: Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const Q_DECL_NOTHROW { return (i & Int(f)) == Int(f) && (Int(f) != 0 || i == Int(f) ); } Q_DECL_RELAXED_CONSTEXPR inline QFlags &setFlag(Enum f, bool on = true) Q_DECL_NOTHROW { - return on ? (*this |= f) : (*this &= ~f); + return on ? (*this |= f) : (*this &= ~Int(f)); } private: diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index a36852fc22..72e28edf63 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -44,7 +44,16 @@ #include <QtCore/qmetatype.h> #include <string.h> -#if defined __F16C__ +#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__AVX2__) && !defined(__F16C__) +// All processors that support AVX2 do support F16C too. That doesn't mean +// we're allowed to use the intrinsics directly, so we'll do it only for +// the Intel and Microsoft's compilers. +# if defined(Q_CC_INTEL) || defined(Q_CC_MSVC) +# define __F16C__ 1 +# endif +#endif + +#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) #include <immintrin.h> #endif @@ -116,7 +125,7 @@ QT_WARNING_DISABLE_CLANG("-Wc99-extensions") QT_WARNING_DISABLE_GCC("-Wold-style-cast") inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW { -#if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__)) +#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) __m128 packsingle = _mm_set_ss(f); __m128i packhalf = _mm_cvtps_ph(packsingle, 0); b16 = _mm_extract_epi16(packhalf, 0); @@ -134,7 +143,7 @@ QT_WARNING_POP inline qfloat16::operator float() const Q_DECL_NOTHROW { -#if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__)) +#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) __m128i packhalf = _mm_cvtsi32_si128(b16); __m128 packsingle = _mm_cvtph_ps(packhalf); return _mm_cvtss_f32(packsingle); diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 6769190335..5cb3e75791 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -656,6 +656,11 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel */ /*! + \enum QRandomGenerator::System + \internal +*/ + +/*! \fn QRandomGenerator::QRandomGenerator(quint32 seedValue) Initializes this QRandomGenerator object with the value \a seedValue as @@ -694,7 +699,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel */ /*! - \fn QRandomGenerator::QRandomGenerator(const quint32 *begin, const quin32 *end) + \fn QRandomGenerator::QRandomGenerator(const quint32 *begin, const quint32 *end) \overload Initializes this QRandomGenerator object with the values found in the range @@ -762,7 +767,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel A typedef to the type that operator()() returns. That is, quint32. - \sa operator()() + \sa {QRandomGenerator::operator()}{operator()()} */ /*! @@ -774,6 +779,22 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel */ /*! + \fn quint32 QRandomGenerator::generate() + + Generates a 32-bit random quantity and returns it. + + \sa {QRandomGenerator::operator()}{operator()()}, generate64() + */ + +/*! + \fn quint64 QRandomGenerator::generate64() + + Generates a 64-bit random quantity and returns it. + + \sa {QRandomGenerator::operator()}{operator()()}, generate() + */ + +/*! \fn result_type QRandomGenerator::min() Returns the minimum value that QRandomGenerator may ever generate. That is, 0. @@ -800,7 +821,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \fn void QRandomGenerator::seed(std::seed_seq &seed) \overload - Reseeds this object using the seed sequence \a sseq as the seed. + Reseeds this object using the seed sequence \a seed as the seed. */ /*! @@ -913,9 +934,9 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel */ /*! - \fn qreal QRandomGenerator::bounded(qreal highest) + \fn double QRandomGenerator::bounded(double highest) - Generates one random qreal in the range between 0 (inclusive) and \a + Generates one random double in the range between 0 (inclusive) and \a highest (exclusive). This function is equivalent to and is implemented as: \code @@ -1098,7 +1119,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel A typedef to the type that operator()() returns. That is, quint64. - \sa operator()() + \sa {QRandomGenerator64::operator()}{operator()()} */ /*! diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 77d154c6b4..e590e259e7 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -108,6 +108,16 @@ struct statx { mode_t stx_mode; }; QT_BEGIN_NAMESPACE +enum { +#ifdef Q_OS_ANDROID + // On Android, the link(2) system call has been observed to always fail + // with EACCES, regardless of whether there are permission problems or not. + SupportsHardlinking = false +#else + SupportsHardlinking = true +#endif +}; + #define emptyFileEntryWarning() emptyFileEntryWarning_(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC) static void emptyFileEntryWarning_(const char *file, int line, const char *function) { @@ -1287,7 +1297,7 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy } #endif - if (::link(srcPath, tgtPath) == 0) { + if (SupportsHardlinking && ::link(srcPath, tgtPath) == 0) { if (::unlink(srcPath) == 0) return true; @@ -1301,6 +1311,11 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy error = QSystemError(savedErrno, QSystemError::StandardLibraryError); return false; + } else if (!SupportsHardlinking) { + // man 2 link on Linux has: + // EPERM The filesystem containing oldpath and newpath does not + // support the creation of hard links. + errno = EPERM; } switch (errno) { diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 0a3e83206b..7d46898911 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1879,7 +1879,7 @@ QByteArray QIODevice::peek(qint64 maxSize) } /*! - \since 5.11 + \since 5.10 Skips up to \a maxSize bytes from the device. Returns the number of bytes actually skipped, or -1 on error. diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 0e7eaeea76..1bf61017f6 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -255,6 +255,7 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) QLoggingRegistry::QLoggingRegistry() : categoryFilter(defaultCategoryFilter) { + initalizeRules(); // Init on first use } static bool qtLoggingDebug() @@ -283,7 +284,7 @@ static QVector<QLoggingRule> loadRulesFromFile(const QString &filePath) Initializes the rules database by loading $QT_LOGGING_CONF, $QT_LOGGING_RULES, and .config/QtProject/qtlogging.ini. */ -void QLoggingRegistry::init() +void QLoggingRegistry::initalizeRules() { QVector<QLoggingRule> er, qr, cr; // get rules from environment diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index a68b993cca..a3857d3588 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -113,7 +113,7 @@ class Q_AUTOTEST_EXPORT QLoggingRegistry public: QLoggingRegistry(); - void init(); + void initalizeRules(); void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel); void unregisterCategory(QLoggingCategory *category); diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index d0cbc82c56..bbc66120b5 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1451,7 +1451,7 @@ void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile) Files that we can't read (because of permissions or because they don't exist) are treated as empty files. */ - if (file.isReadable() && fileInfo.size() != 0) { + if (file.isReadable() && file.size() != 0) { bool ok = false; #ifdef Q_OS_MAC if (format == QSettings::NativeFormat) { diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index 41fd31df8b..eeb02419c3 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -201,6 +201,10 @@ QString QStandardPaths::writableLocation(StandardLocation type) return result; } +#ifndef QT_BOOTSTRAPPED +extern QString qAppFileName(); +#endif + QStringList QStandardPaths::standardLocations(StandardLocation type) { QStringList dirs; @@ -217,8 +221,13 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) dirs.append(programData); } #ifndef QT_BOOTSTRAPPED - dirs.append(QCoreApplication::applicationDirPath()); - const QString dataDir = QCoreApplication::applicationDirPath() + QLatin1String("/data"); + // Note: QCoreApplication::applicationDirPath(), while static, requires + // an application instance. But we might need to resolve the standard + // locations earlier than that, so we fall back to qAppFileName(). + QString applicationDirPath = qApp ? QCoreApplication::applicationDirPath() + : QFileInfo(qAppFileName()).path(); + dirs.append(applicationDirPath); + const QString dataDir = applicationDirPath + QLatin1String("/data"); dirs.append(dataDir); if (!isGenericConfigLocation(type)) { diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 609e52d9d2..350be50082 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -802,8 +802,6 @@ void QCoreApplicationPrivate::init() if (!coreappdata()->applicationVersionSet) coreappdata()->applicationVersion = appVersion(); - QLoggingRegistry::instance()->init(); - #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 diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp index a4d3f67c27..9368e53b3f 100644 --- a/src/corelib/plugin/qlibrary_win.cpp +++ b/src/corelib/plugin/qlibrary_win.cpp @@ -116,7 +116,7 @@ bool QLibraryPrivate::load_sys() #endif if (!pHnd) { errorString = QLibrary::tr("Cannot load library %1: %2").arg( - QDir::toNativeSeparators(fileName)).arg(qt_error_string()); + QDir::toNativeSeparators(fileName), qt_error_string()); } else { // Query the actual name of the library that was loaded errorString.clear(); @@ -152,7 +152,7 @@ bool QLibraryPrivate::unload_sys() { if (!FreeLibrary(pHnd)) { errorString = QLibrary::tr("Cannot unload library %1: %2").arg( - QDir::toNativeSeparators(fileName)).arg(qt_error_string()); + QDir::toNativeSeparators(fileName), qt_error_string()); return false; } errorString.clear(); @@ -164,8 +164,7 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) FARPROC address = GetProcAddress(pHnd, symbol); if (!address) { errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg( - QString::fromLatin1(symbol)).arg( - QDir::toNativeSeparators(fileName)).arg(qt_error_string()); + QString::fromLatin1(symbol), QDir::toNativeSeparators(fileName), qt_error_string()); } else { errorString.clear(); } diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index f6fc672486..050f37dcd2 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2227,7 +2227,7 @@ static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus) #endif // Q_OS_WIN } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(datetimeparser) && QT_CONFIG(timezone) /* \internal Implemented here to share qt_tzname() @@ -2245,7 +2245,7 @@ int QDateTimeParser::startsWithLocalTimeZone(const QStringRef name) } return 0; } -#endif // QT_BOOTSTRAPPED +#endif // datetimeparser && timezone // Calls the platform variant of mktime for the given date, time and daylightStatus, // and updates the date, time, daylightStatus and abbreviation with the returned values diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 4b3777407c..1a56418aaf 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -195,9 +195,11 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const return false; // Preserve zone: - v = (tspec == Qt::TimeZone - ? QDateTime(newDate, newTime, v.timeZone()) - : QDateTime(newDate, newTime, tspec, offset)); + v = +#if QT_CONFIG(timezone) + tspec == Qt::TimeZone ? QDateTime(newDate, newTime, v.timeZone()) : +#endif + QDateTime(newDate, newTime, tspec, offset); return true; } @@ -213,7 +215,9 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const { const SectionNode &sn = sectionNode(s); switch (sn.type) { +#if QT_CONFIG(timezone) case TimeZoneSection: return QTimeZone::MaxUtcOffsetSecs; +#endif case Hour24Section: case Hour12Section: return 23; // this is special-cased in // parseSection. We want it to be @@ -248,7 +252,9 @@ int QDateTimeParser::absoluteMin(int s) const { const SectionNode &sn = sectionNode(s); switch (sn.type) { +#if QT_CONFIG(timezone) case TimeZoneSection: return QTimeZone::MinUtcOffsetSecs; +#endif case Hour24Section: case Hour12Section: case MinuteSection: @@ -766,9 +772,11 @@ QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex, text->replace(offset, used, sectiontext.constData(), used); break; } case TimeZoneSection: +#if QT_CONFIG(timezone) result = findTimeZone(sectionTextRef, currentValue, absoluteMax(sectionIndex), absoluteMin(sectionIndex)); +#endif break; case MonthSection: case DayOfWeekSectionShort: @@ -1090,17 +1098,21 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, int dayofweek = defaultDate.dayOfWeek(); Qt::TimeSpec tspec = defaultValue.timeSpec(); int zoneOffset = 0; // In seconds; local - UTC +#if QT_CONFIG(timezone) QTimeZone timeZone; +#endif switch (tspec) { case Qt::OffsetFromUTC: // timeZone is ignored zoneOffset = defaultValue.offsetFromUtc(); break; +#if QT_CONFIG(timezone) case Qt::TimeZone: timeZone = defaultValue.timeZone(); if (timeZone.isValid()) zoneOffset = timeZone.offsetFromUtc(defaultValue); // else: is there anything we can do about this ? break; +#endif default: // zoneOffset and timeZone are ignored break; } @@ -1125,9 +1137,11 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, { const QDate date = actualDate(isSet, year, year2digits, month, day, dayofweek); const QTime time = actualTime(isSet, hour, hour12, ampm, minute, second, msec); - sect = parseSection(tspec == Qt::TimeZone - ? QDateTime(date, time, timeZone) - : QDateTime(date, time, tspec, zoneOffset), + sect = parseSection( +#if QT_CONFIG(timezone) + tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) : +#endif + QDateTime(date, time, tspec, zoneOffset), index, pos, input); } @@ -1152,7 +1166,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, case TimeZoneSection: current = &zoneOffset; if (sect.used > 0) { - // Synchronize with what findTimeZone() found: +#if QT_CONFIG(timezone) // Synchronize with what findTimeZone() found: QStringRef zoneName = input->midRef(pos, sect.used); Q_ASSERT(!zoneName.isEmpty()); // sect.used > 0 const QByteArray latinZone(zoneName == QLatin1String("Z") @@ -1163,6 +1177,9 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, ? Qt::TimeZone : Qt::OffsetFromUTC) : (Q_ASSERT(startsWithLocalTimeZone(zoneName)), Qt::LocalTime); +#else + tspec = Qt::LocalTime; +#endif } break; case Hour24Section: current = &hour; break; @@ -1320,9 +1337,11 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, const QDate date(year, month, day); const QTime time(hour, minute, second, msec); - return StateNode(tspec == Qt::TimeZone - ? QDateTime(date, time, timeZone) - : QDateTime(date, time, tspec, zoneOffset), + return StateNode( +#if QT_CONFIG(timezone) + tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) : +#endif + QDateTime(date, time, tspec, zoneOffset), state, padding, conflicts); } @@ -1570,6 +1589,7 @@ QDateTimeParser::ParsedSection QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, int maxVal, int minVal) const { +#if QT_CONFIG(timezone) int index = startsWithLocalTimeZone(str); int offset; @@ -1612,6 +1632,7 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, if (index > 0 && maxVal >= offset && offset >= minVal) return ParsedSection(Acceptable, offset, index); +#endif // timezone return ParsedSection(); } diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index 75497f5c5a..c3ae08da71 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -223,7 +223,10 @@ private: QString *dayName = 0, int *used = 0) const; ParsedSection findTimeZone(QStringRef str, const QDateTime &when, int maxVal, int minVal) const; - static int startsWithLocalTimeZone(const QStringRef name); // implemented in qdatetime.cpp +#if QT_CONFIG(timezone) + // Implemented in qdatetime.cpp: + static int startsWithLocalTimeZone(const QStringRef name); +#endif enum AmPmFinder { Neither = -1, diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 166cbe8dee..a072ea411c 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3805,17 +3805,18 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci /*! \since 5.10 - Converts a size in bytes to a human-readable localized string, expressed in - a unit for which the numeric portion is at least 1 but as low as - possible. For example if \a bytes is 16384, \a precision is 2, and \a format - is \c DataSizeIecFormat (the default), this function returns "16.00 KiB"; - for 1330409069609 bytes it returns "1.21 GiB"; and so on. If \a format is \c - DataSizeIecFormat or \c DataSizeTraditionalFormat, the given number of bytes - is divided by a power of 1024, with result less than 1024; for \c - DataSizeSIFormat, it is divided by a power of 1000, with result less than - 1000. DataSizeIecFormat uses the new IEC standard quantifiers Ki, Mi and so - on, whereas DataSizeSIFormat uses and DataSizeTraditionalFormat abuses the - older SI quantifiers k, M, etc. + Converts a size in bytes to a human-readable localized string, comprising a + number and a quantified unit. The quantifier is chosen such that the number + is at least one, and as small as possible. For example if \a bytes is + 16384, \a precision is 2, and \a format is \l DataSizeIecFormat (the + default), this function returns "16.00 KiB"; for 1330409069609 bytes it + returns "1.21 GiB"; and so on. If \a format is \l DataSizeIecFormat or + \l DataSizeTraditionalFormat, the given number of bytes is divided by a + power of 1024, with result less than 1024; for \l DataSizeSIFormat, it is + divided by a power of 1000, with result less than 1000. + \c DataSizeIecFormat uses the new IEC standard quantifiers Ki, Mi and so on, + whereas \c DataSizeSIFormat uses the older SI quantifiers k, M, etc., and + \c DataSizeTraditionalFormat abuses them. */ QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format) { diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index bba0a85319..4e59686d97 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -769,8 +769,6 @@ static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSens Case-sensitive comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). - - \snippet qstring/main.cpp qCompareStrings-QSV-QSV */ int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW { @@ -4837,7 +4835,7 @@ static QByteArray qt_convert_to_local_8bit(QStringView string); locale, the returned byte array is undefined. Those characters may be suppressed or replaced by another. - \sa fromLocal8Bit(), toLatin1(), toUtf8(), QTextCodec, qConvertToLocal8Bit() + \sa fromLocal8Bit(), toLatin1(), toUtf8(), QTextCodec */ QByteArray QString::toLocal8Bit_helper(const QChar *data, int size) @@ -4871,8 +4869,7 @@ static QByteArray qt_convert_to_local_8bit(QStringView string) The behavior is undefined if \a string contains characters not supported by the locale's 8-bit encoding. - \sa QString::toLocal8Bit(), QStringView::toLocal8Bit(), QtPrivate::vonvertToLatin1(), - QtPrivate::convertToUtf8(), QtPrivate::convertToUcs4() + \sa QString::toLocal8Bit(), QStringView::toLocal8Bit() */ QByteArray QtPrivate::convertToLocal8Bit(QStringView string) { @@ -4915,8 +4912,7 @@ static QByteArray qt_convert_to_utf8(QStringView str) UTF-8 is a Unicode codec and can represent all characters in a Unicode string like QStringView. - \sa QString::toUtf8(), QStringView::toUtf8(), QtPrivate::convertToLatin1(), - QtPrivate::convertToLocal8Bit(), QtPrivate::convertToUcs4() + \sa QString::toUtf8(), QStringView::toUtf8() */ QByteArray QtPrivate::convertToUtf8(QStringView string) { @@ -5279,8 +5275,8 @@ namespace { } /*! - \fn QStringView qTrimmed(QStringView s) - \fn QLatin1String qTrimmed(QLatin1String s) + \fn QStringView QtPrivate::trimmed(QStringView s) + \fn QLatin1String QtPrivate::trimmed(QLatin1String s) \internal \relates QStringView \since 5.10 @@ -7250,6 +7246,16 @@ static ResultList splitString(const StringSource &source, const QChar *sep, \snippet qstring/main.cpp 62 + If \a sep is empty, split() returns an empty string, followed + by each of the string's characters, followed by another empty string: + + \snippet qstring/main.cpp 62-empty + + To understand this behavior, recall that the empty string matches + everywhere, so the above is qualitatively the same as: + + \snippet qstring/main.cpp 62-slashes + \sa QStringList::join(), section() */ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const @@ -7259,15 +7265,10 @@ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseS /*! Splits the string into substring references wherever \a sep occurs, and - returns the list of those strings. If \a sep does not match - anywhere in the string, splitRef() returns a single-element vector - containing this string reference. - - \a cs specifies whether \a sep should be matched case - sensitively or case insensitively. + returns the list of those strings. - If \a behavior is QString::SkipEmptyParts, empty entries don't - appear in the result. By default, empty entries are kept. + See QString::split() for how \a sep, \a behavior and \a cs interact to form + the result. \note All references are valid as long this string is alive. Destroying this string will cause all references be dangling pointers. @@ -7298,15 +7299,10 @@ QVector<QStringRef> QString::splitRef(QChar sep, SplitBehavior behavior, Qt::Cas /*! Splits the string into substrings references wherever \a sep occurs, and - returns the list of those strings. If \a sep does not match - anywhere in the string, split() returns a single-element vector - containing this string reference. - - \a cs specifies whether \a sep should be matched case - sensitively or case insensitively. + returns the list of those strings. - If \a behavior is QString::SkipEmptyParts, empty entries don't - appear in the result. By default, empty entries are kept. + See QString::split() for how \a sep, \a behavior and \a cs interact to form + the result. \note All references are valid as long this string is alive. Destroying this string will cause all references be dangling pointers. @@ -8996,7 +8992,7 @@ QString &QString::setRawData(const QChar *unicode, int size) If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive; otherwise the search is case-insensitive. - \sa endsWith(), qStartsWith() + \sa endsWith() */ /*! @@ -9016,7 +9012,7 @@ QString &QString::setRawData(const QChar *unicode, int size) If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive; otherwise the search is case-insensitive. - \sa startsWith(), qEndsWith() + \sa startsWith() */ /*! diff --git a/src/corelib/tools/qstringview.cpp b/src/corelib/tools/qstringview.cpp index bb22239b66..6321427a2d 100644 --- a/src/corelib/tools/qstringview.cpp +++ b/src/corelib/tools/qstringview.cpp @@ -672,8 +672,6 @@ QT_BEGIN_NAMESPACE Whitespace means any character for which QChar::isSpace() returns \c true. This includes the ASCII characters '\\t', '\\n', '\\v', '\\f', '\\r', and ' '. - - \sa qTrimmed() */ /*! @@ -689,7 +687,7 @@ QT_BEGIN_NAMESPACE If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive; otherwise the search is case-insensitive. - \sa endsWith(), qStartsWith() + \sa endsWith() */ /*! @@ -705,7 +703,7 @@ QT_BEGIN_NAMESPACE If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive; otherwise the search is case-insensitive. - \sa startsWith(), qEndsWith() + \sa startsWith() */ /*! @@ -730,7 +728,7 @@ QT_BEGIN_NAMESPACE The behavior is undefined if the string contains characters not supported by the locale's 8-bit encoding. - \sa toLatin1(), toUtf8(), QTextCodec, qConvertToLocal8Bit() + \sa toLatin1(), toUtf8(), QTextCodec */ /*! diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h index 903d7ccb24..ef442e5b65 100644 --- a/src/corelib/tools/qstringview.h +++ b/src/corelib/tools/qstringview.h @@ -152,6 +152,7 @@ private: qsizetype result = 0; while (*str++) ++result; + return result; } #endif return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str)); diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index bcc1285472..6a5df6272a 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -1050,7 +1050,18 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const if (ianaId == "/etc/localtime") ianaId.clear(); - // On Debian Etch and later /etc/localtime is real file with name held in /etc/timezone + // On most distros /etc/localtime is a symlink to a real file so extract name from the path + if (ianaId.isEmpty()) { + const QString path = QFile::symLinkTarget(QStringLiteral("/etc/localtime")); + if (!path.isEmpty()) { + // /etc/localtime is a symlink to the current TZ file, so extract from path + int index = path.indexOf(QLatin1String("/zoneinfo/")); + if (index != -1) + ianaId = path.mid(index + 10).toUtf8(); + } + } + + // On Debian Etch up to Jessie, /etc/localtime is a regular file while the actual name is in /etc/timezone if (ianaId.isEmpty()) { QFile tzif(QStringLiteral("/etc/timezone")); if (tzif.open(QIODevice::ReadOnly)) { @@ -1061,16 +1072,6 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const } } - // On other distros /etc/localtime is symlink to real file so can extract name from the path - if (ianaId.isEmpty()) { - const QString path = QFile::symLinkTarget(QStringLiteral("/etc/localtime")); - if (!path.isEmpty()) { - // /etc/localtime is a symlink to the current TZ file, so extract from path - int index = path.indexOf(QLatin1String("/zoneinfo/")) + 10; - ianaId = path.mid(index).toUtf8(); - } - } - // On some Red Hat distros /etc/localtime is real file with name held in /etc/sysconfig/clock // in a line like ZONE="Europe/Oslo" or TIMEZONE="Europe/Oslo" if (ianaId.isEmpty()) { diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 4daf894887..3a3d416775 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -164,9 +164,10 @@ public: const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t); if (cit == ce) return 0; - // next operation detaches, so ce, cit may become invalidated: + // next operation detaches, so ce, cit, t may become invalidated: + const T tCopy = t; const int firstFoundIdx = std::distance(this->cbegin(), cit); - const iterator e = end(), it = std::remove(begin() + firstFoundIdx, e, t); + const iterator e = end(), it = std::remove(begin() + firstFoundIdx, e, tCopy); const int result = std::distance(it, e); erase(it, e); return result; diff --git a/src/gui/configure.json b/src/gui/configure.json index 0a591e110c..2c1fe6c86e 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1193,6 +1193,7 @@ "label": "XCB", "section": "Platform plugins", "autoDetect": "!config.darwin", + "enable": "input.xcb == 'system' || input.xcb == 'qt'", "condition": "libs.xcb", "output": [ "privateFeature" ] }, diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index cddb5fe632..8112b8e8fd 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -215,7 +215,7 @@ public: const uchar *constBits() const; #if QT_DEPRECATED_SINCE(5, 10) - QT_DEPRECATED int byteCount() const; + QT_DEPRECATED_X("Use sizeInBytes") int byteCount() const; #endif qsizetype sizeInBytes() const; diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp index b123afb4db..2209c3de4d 100644 --- a/src/gui/image/qplatformpixmap.cpp +++ b/src/gui/image/qplatformpixmap.cpp @@ -58,6 +58,9 @@ QT_BEGIN_NAMESPACE */ QPlatformPixmap *QPlatformPixmap::create(int w, int h, PixelType type) { + if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration())) + qFatal("QPlatformPixmap: QGuiApplication required"); + QPlatformPixmap *data = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(static_cast<QPlatformPixmap::PixelType>(type)); data->resize(w, h); return data; diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index f9580291bc..2cecb444c3 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -265,12 +265,12 @@ void QWindowSystemInterface::handleWindowScreenChanged(QWindow *window, QScreen QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate) +QT_DEFINE_QPA_EVENT_HANDLER(void, handleApplicationStateChanged, Qt::ApplicationState newState, bool forcePropagate) { Q_ASSERT(QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)); QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e = new QWindowSystemInterfacePrivate::ApplicationStateChangedEvent(newState, forcePropagate); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } QWindowSystemInterfacePrivate::GeometryChangeEvent::GeometryChangeEvent(QWindow *window, const QRect &newGeometry) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 1ded12d88d..b1ca6238cb 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -180,6 +180,7 @@ public: static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState = -1); static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false); #ifndef QT_NO_DRAGANDDROP diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index af13b96c32..e7ca00b3a9 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -177,8 +177,8 @@ void drawTriangle(qint32 *bits, int width, int height, const QPoint *center, const int y2 = clip == Clip ? qBound(0, v2->y() >> 8, height) : v2->y() >> 8; const int yC = clip == Clip ? qBound(0, center->y() >> 8, height) : center->y() >> 8; - const int v1Frac = clip == Clip ? (y1 << 8) + 0xff - v1->y() : ~v2->y() & 0xff; - const int v2Frac = clip == Clip ? (y2 << 8) + 0xff - v2->y() : ~v1->y() & 0xff; + const int v1Frac = clip == Clip ? (y1 << 8) + 0xff - v1->y() : ~v1->y() & 0xff; + const int v2Frac = clip == Clip ? (y2 << 8) + 0xff - v2->y() : ~v2->y() & 0xff; const int centerFrac = clip == Clip ? (yC << 8) + 0xff - center->y() : ~center->y() & 0xff; int dx1 = 0, x1 = 0, dx2 = 0, x2 = 0; diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index e6a15ccfc4..8fdcc91efc 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -1231,20 +1231,20 @@ void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(const QHostInfo &info) if (dequeueRequest(channels[0].socket)) { emitReplyError(channels[0].socket, channels[0].reply, QNetworkReply::HostNotFoundError); networkLayerState = QHttpNetworkConnectionPrivate::Unknown; - } -#ifndef QT_NO_SSL - else if (connectionType == QHttpNetworkConnection::ConnectionTypeSPDY) { + } else if (connectionType == QHttpNetworkConnection::ConnectionTypeSPDY + || connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2) { for (const HttpMessagePair &spdyPair : qAsConst(channels[0].spdyRequestsToSend)) { // emit error for all replies QHttpNetworkReply *currentReply = spdyPair.second; Q_ASSERT(currentReply); emitReplyError(channels[0].socket, currentReply, QNetworkReply::HostNotFoundError); } - } -#endif // QT_NO_SSL - else { - // Should not happen - qWarning("QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not de-queue request"); + } else { + // Should not happen: we start a host lookup before sending a request, + // so it's natural to have requests either in SPDY/HTTP/2 queue, + // or in low/high priority queues. + qWarning("QHttpNetworkConnectionPrivate::_q_hostLookupFinished" + " could not de-queue request, failed to report HostNotFoundError"); networkLayerState = QHttpNetworkConnectionPrivate::Unknown; } } diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index edf9dee78e..67b765d9e6 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1027,8 +1027,7 @@ QNetworkConfiguration QNetworkAccessManager::configuration() const if (session) { return session->configuration(); } else { - QNetworkConfigurationManager manager; - return manager.defaultConfiguration(); + return d->networkConfigurationManager.defaultConfiguration(); } } @@ -1052,12 +1051,11 @@ QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const Q_D(const QNetworkAccessManager); QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession()); - QNetworkConfigurationManager manager; if (networkSession) { - return manager.configurationFromIdentifier( + return d->networkConfigurationManager.configurationFromIdentifier( networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString()); } else { - return manager.defaultConfiguration(); + return d->networkConfigurationManager.defaultConfiguration(); } } @@ -1384,17 +1382,16 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera } if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) { - QNetworkConfigurationManager manager; if (!d->networkConfiguration.identifier().isEmpty()) { if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined) - && d->networkConfiguration != manager.defaultConfiguration()) - d->createSession(manager.defaultConfiguration()); + && d->networkConfiguration != d->networkConfigurationManager.defaultConfiguration()) + d->createSession(d->networkConfigurationManager.defaultConfiguration()); else d->createSession(d->networkConfiguration); } else { - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) - d->createSession(manager.defaultConfiguration()); + if (d->networkSessionRequired) + d->createSession(d->networkConfigurationManager.defaultConfiguration()); else d->initializeSession = false; } @@ -1926,8 +1923,8 @@ void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) online = (networkConfiguration.state() & QNetworkConfiguration::Active); } else { if (online != isOnline) { - _q_networkSessionClosed(); - createSession(q->configuration()); + _q_networkSessionClosed(); + createSession(q->configuration()); online = isOnline; } } @@ -1951,13 +1948,13 @@ void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfigu const QString id = configuration.identifier(); if (configuration.state().testFlag(QNetworkConfiguration::Active)) { if (!onlineConfigurations.contains(id)) { - QSharedPointer<QNetworkSession> session(getNetworkSession()); if (session) { if (online && session->configuration().identifier() != networkConfigurationManager.defaultConfiguration().identifier()) { onlineConfigurations.insert(id); + // CHECK: If it's having Active flag - why would it be disconnected ??? //this one disconnected but another one is online, // close and create new session _q_networkSessionClosed(); @@ -1968,6 +1965,7 @@ void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfigu } else if (onlineConfigurations.contains(id)) { //this one is disconnecting + // CHECK: If it disconnected while we create a session over a down configuration ??? onlineConfigurations.remove(id); if (!onlineConfigurations.isEmpty()) { _q_networkSessionClosed(); diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 7284b124c5..ec88851589 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -1694,6 +1694,8 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port, } #endif + // Sync up with error string, which open() shall clear. + d->socketError = UnknownSocketError; if (openMode & QIODevice::Unbuffered) d->isBuffered = false; else if (!d_func()->isBuffered) @@ -1929,6 +1931,8 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState return false; } + // Sync up with error string, which open() shall clear. + d->socketError = UnknownSocketError; if (d->threadData->hasEventDispatcher()) d->socketEngine->setReceiver(d); diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h index 5411133ea9..3873b50864 100644 --- a/src/network/socket/qabstractsocket_p.h +++ b/src/network/socket/qabstractsocket_p.h @@ -153,6 +153,7 @@ public: QAbstractSocket::SocketType socketType; QAbstractSocket::SocketState state; + // Must be kept in sync with QIODevicePrivate::errorString. QAbstractSocket::SocketError socketError; QAbstractSocket::NetworkLayerProtocol preferredNetworkLayerProtocol; diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp index 8cb3449343..ced923ced1 100644 --- a/src/network/socket/qlocalserver_win.cpp +++ b/src/network/socket/qlocalserver_win.cpp @@ -225,7 +225,7 @@ bool QLocalServerPrivate::addListener() void QLocalServerPrivate::setError(const QString &function) { int windowsError = GetLastError(); - errorString = QString::fromLatin1("%1: %2").arg(function).arg(qt_error_string(windowsError)); + errorString = QString::fromLatin1("%1: %2").arg(function, qt_error_string(windowsError)); error = QAbstractSocket::UnknownSocketError; } diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index bd368ac42f..747fdeb967 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -1213,10 +1213,8 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxL msg.dwBufferCount = 1; msg.name = reinterpret_cast<LPSOCKADDR>(&aa); msg.namelen = sizeof(aa); - if (options & (QAbstractSocketEngine::WantDatagramHopLimit | QAbstractSocketEngine::WantDatagramDestination)) { - msg.Control.buf = cbuf; - msg.Control.len = sizeof(cbuf); - } + msg.Control.buf = cbuf; + msg.Control.len = sizeof(cbuf); DWORD flags = 0; DWORD bytesRead = 0; diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index be0fac4b55..2105145263 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -112,9 +112,11 @@ static bool isDBusTrayAvailable() { #ifndef QT_NO_DBUS static bool checkDBusGlobalMenuAvailable() { - QDBusConnection connection = QDBusConnection::sessionBus(); - QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar"); - return connection.interface()->isServiceRegistered(registrarService); + const QDBusConnection connection = QDBusConnection::sessionBus(); + static const QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar"); + if (const auto iface = connection.interface()) + return iface->isServiceRegistered(registrarService); + return false; } static bool isDBusGlobalMenuAvailable() diff --git a/src/plugins/platforms/android/androidjniclipboard.cpp b/src/plugins/platforms/android/androidjniclipboard.cpp index 833996403c..d169035339 100644 --- a/src/plugins/platforms/android/androidjniclipboard.cpp +++ b/src/plugins/platforms/android/androidjniclipboard.cpp @@ -47,7 +47,6 @@ namespace QtAndroidClipboard { QAndroidPlatformClipboard *m_manager = nullptr; - static char const *const QtNativeClassName = "org/qtproject/qt5/android/QtNative"; static JNINativeMethod methods[] = { {"onClipboardDataChanged", "()V", (void *)onClipboardDataChanged} }; diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index a54284dbae..1345295ef5 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -253,6 +253,18 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate); return nil; } +// Cocoa will query the menu item's target for the worksWhenModal selector. +// So we need to implement this to allow the items to be handled correctly +// when a modal dialog is visible. +- (BOOL)worksWhenModal +{ + if (!QGuiApplication::modalWindow()) + return YES; + if (auto *mb = qobject_cast<QCocoaMenuBar *>(m_menu->menuParent())) + return QGuiApplication::modalWindow()->handle() == mb->cocoaWindow() ? YES : NO; + return YES; +} + @end QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.h b/src/plugins/platforms/cocoa/qcocoamenubar.h index a4ee531e91..a259147247 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.h +++ b/src/plugins/platforms/cocoa/qcocoamenubar.h @@ -71,6 +71,7 @@ public: QList<QCocoaMenuItem*> merged() const; NSMenuItem *itemForRole(QPlatformMenuItem::MenuRole r); + QCocoaWindow *cocoaWindow() const; void syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate); diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index a4cd465dae..cf9553bcf7 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -452,5 +452,10 @@ NSMenuItem *QCocoaMenuBar::itemForRole(QPlatformMenuItem::MenuRole r) return Q_NULLPTR; } +QCocoaWindow *QCocoaMenuBar::cocoaWindow() const +{ + return m_window.data(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 28ffcf8718..c888551729 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -353,6 +353,12 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") m_platformWindow->handleExposeEvent(QRectF::fromCGRect(self.bounds).toRect()); } +- (void)viewDidChangeBackingProperties +{ + if (self.layer) + self.layer.contentsScale = self.window.backingScaleFactor; +} + - (BOOL)isFlipped { return YES; diff --git a/src/plugins/platforms/ios/qiosapplicationstate.mm b/src/plugins/platforms/ios/qiosapplicationstate.mm index 7b923e4692..7c8e1f9927 100644 --- a/src/plugins/platforms/ios/qiosapplicationstate.mm +++ b/src/plugins/platforms/ios/qiosapplicationstate.mm @@ -39,6 +39,8 @@ #include "qiosapplicationstate.h" +#include "qiosglobal.h" + #include <qpa/qwindowsysteminterface.h> #include <QtCore/qcoreapplication.h> @@ -72,8 +74,8 @@ static Qt::ApplicationState qtApplicationState(UIApplicationState uiApplicationS static void handleApplicationStateChanged(UIApplicationState uiApplicationState) { Qt::ApplicationState state = qtApplicationState(uiApplicationState); + qCDebug(lcQpaApplication) << "moved to" << state; QWindowSystemInterface::handleApplicationStateChanged(state); - QWindowSystemInterface::flushWindowSystemEvents(); } QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 2d5286e971..6a6cbb4324 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -165,8 +165,6 @@ bool QIOSContext::makeCurrent(QPlatformSurface *surface) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, framebufferObject.depthRenderbuffer); } - - connect(static_cast<QIOSWindow *>(surface), SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed(QObject*))); } else { glBindFramebuffer(GL_FRAMEBUFFER, framebufferObject.handle); } @@ -249,8 +247,13 @@ QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatfo // should probably use QOpenGLMultiGroupSharedResource to track the shared default-FBOs. if (m_sharedContext) return m_sharedContext->backingFramebufferObjectFor(surface); - else - return m_framebufferObjects[surface]; + + if (!m_framebufferObjects.contains(surface)) { + // We're about to create a new FBO, make sure it's cleaned up as well + connect(static_cast<QIOSWindow *>(surface), SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed(QObject*))); + } + + return m_framebufferObjects[surface]; } GLuint QIOSContext::defaultFramebufferObject(QPlatformSurface *surface) const diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index cf7680529a..de2c30cdfb 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -294,7 +294,7 @@ static bool rootLevelRunLoopIntegration() { [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(applicationDidFinishLaunching) + selector:@selector(applicationDidFinishLaunching:) name:UIApplicationDidFinishLaunchingNotification object:nil]; @@ -320,8 +320,10 @@ static bool rootLevelRunLoopIntegration() # error "Unknown processor family" #endif -+ (void)applicationDidFinishLaunching ++ (void)applicationDidFinishLaunching:(NSNotification *)notification { + qCDebug(lcQpaApplication) << "Application launched with options" << notification.userInfo; + if (!isQtApplication()) return; @@ -329,7 +331,7 @@ static bool rootLevelRunLoopIntegration() // We schedule the main-redirection for the next run-loop pass, so that we // can return from this function and let UIApplicationMain finish its job. // This results in running Qt's application eventloop as a nested runloop. - qEventDispatcherDebug() << "Scheduling main() on next run-loop pass"; + qCDebug(lcQpaApplication) << "Scheduling main() on next run-loop pass"; CFRunLoopTimerRef userMainTimer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), 0, 0, 0, ^(CFRunLoopTimerRef) { user_main_trampoline(); }); CFRunLoopAddTimer(CFRunLoopGetMain(), userMainTimer, kCFRunLoopCommonModes); @@ -339,7 +341,7 @@ static bool rootLevelRunLoopIntegration() switch (setjmp(processEventEnterJumpPoint)) { case kJumpPointSetSuccessfully: - qEventDispatcherDebug() << "Running main() on separate stack"; qIndent(); + qCDebug(lcQpaApplication) << "Running main() on separate stack"; qIndent(); // Redirect the stack pointer to the start of the reserved stack. This ensures // that when we longjmp out of the event dispatcher and continue execution, the @@ -358,7 +360,7 @@ static bool rootLevelRunLoopIntegration() case kJumpedFromEventDispatcherProcessEvents: // We've returned from the longjmp in the event dispatcher, // and the stack has been restored to its old self. - qUnIndent(); qEventDispatcherDebug() << "Returned from processEvents"; + qUnIndent(); qCDebug(lcQpaApplication) << "Returned from processEvents"; if (Q_UNLIKELY(debugStackUsage)) userMainStack.printUsage(); @@ -422,6 +424,8 @@ QIOSEventDispatcher::QIOSEventDispatcher(QObject *parent) , m_processEventLevel(0) , m_runLoopExitObserver(this, &QIOSEventDispatcher::handleRunLoopExit, kCFRunLoopExit) { + // We want all delivery of events from the system to be handled synchronously + QWindowSystemInterface::setSynchronousWindowSystemEvents(true); } bool __attribute__((returns_twice)) QIOSEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index f74e3004cc..8b39aded06 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -47,7 +47,9 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcQpaApplication); Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods); +Q_DECLARE_LOGGING_CATEGORY(lcQpaWindow); #if !defined(QT_NO_DEBUG) #define qImDebug \ diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index 1482ffc7af..f27b2242df 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -44,7 +44,9 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application"); Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods"); +Q_LOGGING_CATEGORY(lcQpaWindow, "qt.qpa.window"); bool isQtApplication() { diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h index 54c1a1dcb7..6f3f18af48 100644 --- a/src/plugins/platforms/ios/qiosintegration.h +++ b/src/plugins/platforms/ios/qiosintegration.h @@ -58,8 +58,6 @@ class QIOSServices; class QIOSIntegration : public QPlatformNativeInterface, public QPlatformIntegration { Q_OBJECT - Q_PROPERTY(bool debugWindowManagement READ debugWindowManagement WRITE setDebugWindowManagement); - public: QIOSIntegration(); ~QIOSIntegration(); @@ -104,9 +102,6 @@ public: void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) Q_DECL_OVERRIDE; - void setDebugWindowManagement(bool); - bool debugWindowManagement() const; - QFactoryLoader *optionalPlugins() { return m_optionalPlugins; } private: @@ -123,8 +118,6 @@ private: #ifndef Q_OS_TVOS QIOSTextInputOverlay m_textInputOverlay; #endif - - bool m_debugWindowManagement; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 5f114d4762..94a30eb931 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -85,7 +85,6 @@ QIOSIntegration::QIOSIntegration() , m_platformServices(new QIOSServices) , m_accessibility(0) , m_optionalPlugins(new QFactoryLoader(QIosOptionalPluginInterface_iid, QLatin1String("/platforms/darwin"))) - , m_debugWindowManagement(false) { if (Q_UNLIKELY(![UIApplication sharedApplication])) { qFatal("Error: You are creating QApplication before calling UIApplicationMain.\n" \ @@ -94,10 +93,6 @@ QIOSIntegration::QIOSIntegration() "'applicationDidFinishLaunching' inside your UIApplication delegate.\n"); } - // The backingstore needs a global share context in order to support composition in - // QPlatformBackingStore. - qApp->setAttribute(Qt::AA_ShareOpenGLContexts, true); - // Set current directory to app bundle folder QDir::setCurrent(QString::fromUtf8([[[NSBundle mainBundle] bundlePath] UTF8String])); @@ -322,16 +317,6 @@ void *QIOSIntegration::nativeResourceForWindow(const QByteArray &resource, QWind return 0; } -void QIOSIntegration::setDebugWindowManagement(bool enabled) -{ - m_debugWindowManagement = enabled; -} - -bool QIOSIntegration::debugWindowManagement() const -{ - return m_debugWindowManagement; -} - // --------------------------------------------------------- #include "moc_qiosintegration.cpp" diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index e8854a4c4b..7c88cddd54 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -180,12 +180,12 @@ QT_BEGIN_NAMESPACE /*! Returns the model identifier of the device. - - When running under the simulator, the identifier will not - match the simulated device, but will be x86_64 or i386. */ static QString deviceModelIdentifier() { +#if TARGET_OS_SIMULATOR + return QString::fromLocal8Bit(qgetenv("SIMULATOR_MODEL_IDENTIFIER")); +#else static const char key[] = "hw.machine"; size_t size; @@ -195,6 +195,7 @@ static QString deviceModelIdentifier() sysctlbyname(key, &value, &size, NULL, 0); return QString::fromLatin1(value); +#endif } QIOSScreen::QIOSScreen(UIScreen *screen) @@ -203,25 +204,30 @@ QIOSScreen::QIOSScreen(UIScreen *screen) , m_uiWindow(0) , m_orientationListener(0) { - if (screen == [UIScreen mainScreen]) { - QString deviceIdentifier = deviceModelIdentifier(); + QString deviceIdentifier = deviceModelIdentifier(); + if (screen == [UIScreen mainScreen] && !deviceIdentifier.startsWith("AppleTV")) { // Based on https://en.wikipedia.org/wiki/List_of_iOS_devices#Display // iPhone (1st gen), 3G, 3GS, and iPod Touch (1st–3rd gen) are 18-bit devices - if (deviceIdentifier.contains(QRegularExpression("^(iPhone1,[12]|iPhone2,1|iPod[1-3],1)$"))) - m_depth = 18; - else - m_depth = 24; + static QRegularExpression lowBitDepthDevices("^(iPhone1,[12]|iPhone2,1|iPod[1-3],1)$"); + m_depth = deviceIdentifier.contains(lowBitDepthDevices) ? 18 : 24; + + static QRegularExpression iPhoneXModels("^iPhone(10,[36])$"); + static QRegularExpression iPhonePlusModels("^iPhone(7,1|8,2|9,[24]|10,[25])$"); + static QRegularExpression iPadMiniModels("^iPad(2,[567]|4,[4-9]|5,[12])$"); - if (deviceIdentifier.contains(QRegularExpression("^iPhone(7,1|8,2|9,2|9,4)$"))) { - // iPhone Plus models + if (deviceIdentifier.contains(iPhoneXModels)) { + m_physicalDpi = 458; + } else if (deviceIdentifier.contains(iPhonePlusModels)) { m_physicalDpi = 401; - } else if (deviceIdentifier.contains(QRegularExpression("^iPad(1,1|2,[1-4]|3,[1-6]|4,[1-3]|5,[3-4]|6,[7-8])$"))) { - // All iPads except the iPad Mini series - m_physicalDpi = 132 * devicePixelRatio(); + } else if (deviceIdentifier.startsWith("iPad")) { + if (deviceIdentifier.contains(iPadMiniModels)) + m_physicalDpi = 163 * devicePixelRatio(); + else + m_physicalDpi = 132 * devicePixelRatio(); } else { - // All non-Plus iPhones, and iPad Minis + // All normal iPhones, and iPods m_physicalDpi = 163 * devicePixelRatio(); } } else { diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 7d48a012dd..b029c49a67 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -377,7 +377,6 @@ QScopedValueRollback<BOOL> rollback(m_inSendEventToFocusObject, true); QWindowSystemInterface::handleKeyEvent(qApp->focusWindow(), QEvent::KeyPress, key, modifiers); QWindowSystemInterface::handleKeyEvent(qApp->focusWindow(), QEvent::KeyRelease, key, modifiers); - QWindowSystemInterface::flushWindowSystemEvents(); } #ifndef QT_NO_SHORTCUT diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index a4c151ed8b..a7f1254064 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -77,8 +77,7 @@ if (!(self = [super init])) return nil; - QIOSIntegration *iosIntegration = QIOSIntegration::instance(); - if (iosIntegration && iosIntegration->debugWindowManagement()) { + if (qEnvironmentVariableIntValue("QT_IOS_DEBUG_WINDOW_MANAGEMENT")) { static UIImage *gridPattern = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 4e6d48423d..bcec9899f7 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -239,15 +239,28 @@ void QIOSWindow::setWindowState(Qt::WindowStates state) if (window()->isTopLevel() && window()->isVisible() && window()->isActive()) [m_view.qtViewController updateProperties]; - if (state & Qt::WindowMinimized) + if (state & Qt::WindowMinimized) { applyGeometry(QRect()); - else if (state & Qt::WindowFullScreen) - applyGeometry(screen()->geometry()); - else if (state & Qt::WindowMaximized) - applyGeometry(window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint ? - screen()->geometry() : screen()->availableGeometry()); - else + } else if (state & (Qt::WindowFullScreen | Qt::WindowMaximized)) { + // When an application is in split-view mode, the UIScreen still has the + // same geometry, but the UIWindow is resized to the area reserved for the + // application. We use this to constrain the geometry used when applying the + // fullscreen or maximized window states. Note that we do not do this + // in applyGeometry(), as we don't want to artificially limit window + // placement "outside" of the screen bounds if that's what the user wants. + + QRect uiWindowBounds = QRectF::fromCGRect(m_view.window.bounds).toRect(); + QRect fullscreenGeometry = screen()->geometry().intersected(uiWindowBounds); + QRect maximizedGeometry = window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint ? + fullscreenGeometry : screen()->availableGeometry().intersected(uiWindowBounds); + + if (state & Qt::WindowFullScreen) + applyGeometry(fullscreenGeometry); + else + applyGeometry(maximizedGeometry); + } else { applyGeometry(m_normalGeometry); + } } void QIOSWindow::setParent(const QPlatformWindow *parentWindow) diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 1507ff37f7..a2ecc8c3cd 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -86,7 +86,7 @@ self.multipleTouchEnabled = YES; #endif - if (QIOSIntegration::instance()->debugWindowManagement()) { + if (qEnvironmentVariableIntValue("QT_IOS_DEBUG_WINDOW_MANAGEMENT")) { static CGFloat hue = 0.0; CGFloat lastHue = hue; for (CGFloat diff = 0; diff < 0.1 || diff > 0.9; diff = fabs(hue - lastHue)) @@ -95,7 +95,6 @@ #define colorWithBrightness(br) \ [UIColor colorWithHue:hue saturation:0.5 brightness:br alpha:1.0].CGColor - self.layer.backgroundColor = colorWithBrightness(0.5); self.layer.borderColor = colorWithBrightness(1.0); self.layer.borderWidth = 1.0; } @@ -161,7 +160,8 @@ QWindow *window = m_qioswindow->window(); QRect lastReportedGeometry = qt_window_private(window)->geometry; QRect currentGeometry = QRectF::fromCGRect(self.frame).toRect(); - QWindowSystemInterface::handleGeometryChange<QWindowSystemInterface::SynchronousDelivery>(window, currentGeometry); + qCDebug(lcQpaWindow) << m_qioswindow->window() << "new geometry is" << currentGeometry; + QWindowSystemInterface::handleGeometryChange(window, currentGeometry); if (currentGeometry.size() != lastReportedGeometry.size()) { // Trigger expose event on resize @@ -193,7 +193,8 @@ region = QRect(QPoint(), bounds); } - QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), region); + qCDebug(lcQpaWindow) << m_qioswindow->window() << region << "isExposed" << m_qioswindow->isExposed(); + QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), region); } // ------------------------------------------------------------------------- @@ -224,7 +225,7 @@ } if (qGuiApp->focusWindow() != m_qioswindow->window()) - QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window()); + QWindowSystemInterface::handleWindowActivated(m_qioswindow->window()); else qImDebug() << m_qioswindow->window() << "already active, not sending window activation"; @@ -262,7 +263,7 @@ UIResponder *newResponder = FirstResponderCandidate::currentCandidate(); if ([self responderShouldTriggerWindowDeactivation:newResponder]) - QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(0); + QWindowSystemInterface::handleWindowActivated(0); return YES; } @@ -353,7 +354,7 @@ - (void)sendTouchEventWithTimestamp:(ulong)timeStamp { QIOSIntegration *iosIntegration = QIOSIntegration::instance(); - QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); + QWindowSystemInterface::handleTouchEvent(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event @@ -432,7 +433,7 @@ NSTimeInterval timestamp = event ? event.timestamp : [[NSProcessInfo processInfo] systemUptime]; QIOSIntegration *iosIntegration = static_cast<QIOSIntegration *>(QGuiApplicationPrivate::platformIntegration()); - QWindowSystemInterface::handleTouchCancelEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice()); + QWindowSystemInterface::handleTouchCancelEvent(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice()); } - (int)mapPressTypeToKey:(UIPress*)press @@ -460,7 +461,7 @@ int key = [self mapPressTypeToKey:press]; if (key == Qt::Key_unknown) continue; - if (QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), type, key, Qt::NoModifier)) + if (QWindowSystemInterface::handleKeyEvent(m_qioswindow->window(), type, key, Qt::NoModifier)) handled = true; } diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index b892f1610d..34e6041687 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -52,6 +52,7 @@ #include <QtGui/QImageWriter> #include <shlobj.h> +#include <algorithm> QT_BEGIN_NAMESPACE @@ -1264,15 +1265,16 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData QVector<FORMATETC> QBuiltInMimes::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector<FORMATETC> formatetcs; - if (!outFormats.keys(mimeType).isEmpty() && mimeData->formats().contains(mimeType)) - formatetcs += setCf(outFormats.key(mimeType)); + const auto mit = std::find(outFormats.cbegin(), outFormats.cend(), mimeType); + if (mit != outFormats.cend() && mimeData->formats().contains(mimeType)) + formatetcs += setCf(mit.key()); return formatetcs; } bool QBuiltInMimes::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return (!inFormats.keys(mimeType).isEmpty()) - && canGetData(inFormats.key(mimeType), pDataObj); + const auto mit = std::find(inFormats.cbegin(), inFormats.cend(), mimeType); + return mit != inFormats.cend() && canGetData(mit.key(), pDataObj); } QVariant QBuiltInMimes::convertToMime(const QString &mimeType, IDataObject *pDataObj, QVariant::Type preferredType) const @@ -1315,7 +1317,7 @@ public: QString mimeForFormat(const FORMATETC &formatetc) const override; private: - QMap<int, QString> formats; + mutable QMap<int, QString> formats; static QStringList ianaTypes; static QStringList excludeList; }; @@ -1380,15 +1382,13 @@ bool QLastResortMimes::convertFromMime(const FORMATETC &formatetc, const QMimeDa QVector<FORMATETC> QLastResortMimes::formatsForMime(const QString &mimeType, const QMimeData * /*mimeData*/) const { QVector<FORMATETC> formatetcs; - if (!formats.keys(mimeType).isEmpty()) { - formatetcs += setCf(formats.key(mimeType)); - } else if (!excludeList.contains(mimeType, Qt::CaseInsensitive)){ - // register any other available formats - int cf = QWindowsMime::registerMimeType(mimeType); - QLastResortMimes *that = const_cast<QLastResortMimes *>(this); - that->formats.insert(cf, mimeType); - formatetcs += setCf(cf); - } + auto mit = std::find(formats.begin(), formats.end(), mimeType); + // register any other available formats + if (mit == formats.end() && !excludeList.contains(mimeType, Qt::CaseInsensitive)) + mit = formats.insert(QWindowsMime::registerMimeType(mimeType), mimeType); + if (mit != formats.end()) + formatetcs += setCf(mit.key()); + if (!formatetcs.isEmpty()) qCDebug(lcQpaMime) << __FUNCTION__ << mimeType << formatetcs; return formatetcs; @@ -1426,14 +1426,11 @@ bool QLastResortMimes::canConvertToMime(const QString &mimeType, IDataObject *pD QString clipFormat = customMimeType(mimeType); const UINT cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16())); return canGetData(int(cf), pDataObj); - } else if (formats.keys(mimeType).isEmpty()) { - // if it is not in there then register it and see if we can get it - int cf = QWindowsMime::registerMimeType(mimeType); - return canGetData(cf, pDataObj); - } else { - return canGetData(formats.key(mimeType), pDataObj); } - return false; + // if it is not in there then register it and see if we can get it + const auto mit = std::find(formats.cbegin(), formats.cend(), mimeType); + const int cf = mit != formats.cend() ? mit.key() : QWindowsMime::registerMimeType(mimeType); + return canGetData(cf, pDataObj); } QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *pDataObj, QVariant::Type preferredType) const @@ -1447,11 +1444,10 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p QString clipFormat = customMimeType(mimeType, &lindex); const UINT cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16())); data = getData(int(cf), pDataObj, lindex); - } else if (formats.keys(mimeType).isEmpty()) { - int cf = QWindowsMime::registerMimeType(mimeType); - data = getData(cf, pDataObj); } else { - data = getData(formats.key(mimeType), pDataObj); + const auto mit = std::find(formats.cbegin(), formats.cend(), mimeType); + const int cf = mit != formats.cend() ? mit.key() : QWindowsMime::registerMimeType(mimeType); + data = getData(cf, pDataObj); } if (!data.isEmpty()) val = data; // it should be enough to return the data and let QMimeData do the rest. diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index f90f189146..ce6dd7c035 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -100,6 +100,7 @@ void QXcbConnection::xi2SelectStateEvents() XIEventMask xiEventMask; bitMask = XI_HierarchyChangedMask; bitMask |= XI_DeviceChangedMask; + bitMask |= XI_PropertyEventMask; xiEventMask.deviceid = XIAllDevices; xiEventMask.mask_len = sizeof(bitMask); xiEventMask.mask = xiBitMask; @@ -121,7 +122,6 @@ void QXcbConnection::xi2SelectDeviceEvents(xcb_window_t window) // core enter/leave events will be ignored in this case. bitMask |= XI_EnterMask; bitMask |= XI_LeaveMask; - bitMask |= XI_PropertyEventMask; #ifdef XCB_USE_XINPUT22 if (isAtLeastXI22()) { bitMask |= XI_TouchBeginMask; @@ -378,24 +378,25 @@ void QXcbConnection::xi2SelectDeviceEventsCompatibility(xcb_window_t window) unsigned int mask = 0; unsigned char *bitMask = reinterpret_cast<unsigned char *>(&mask); - mask |= XI_PropertyEventMask; + Display *dpy = static_cast<Display *>(m_xlib_display); + #ifdef XCB_USE_XINPUT22 if (isAtLeastXI22()) { mask |= XI_TouchBeginMask; mask |= XI_TouchUpdateMask; mask |= XI_TouchEndMask; + + XIEventMask xiMask; + xiMask.mask_len = sizeof(mask); + xiMask.mask = bitMask; + xiMask.deviceid = XIAllMasterDevices; + Status result = XISelectEvents(dpy, window, &xiMask, 1); + if (result == Success) + QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); + else + qCDebug(lcQpaXInput, "failed to select events, window %x, result %d", window, result); } #endif - XIEventMask xiMask; - xiMask.mask_len = sizeof(mask); - xiMask.mask = bitMask; - xiMask.deviceid = XIAllMasterDevices; - Display *dpy = static_cast<Display *>(m_xlib_display); - Status result = XISelectEvents(dpy, window, &xiMask, 1); - if (result == Success) - QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); - else - qCDebug(lcQpaXInput, "failed to select events, window %x, result %d", window, result); mask = XI_ButtonPressMask; mask |= XI_ButtonReleaseMask; @@ -434,6 +435,11 @@ void QXcbConnection::xi2SelectDeviceEventsCompatibility(xcb_window_t window) XISelectEvents(dpy, window, xiEventMask.data(), i); } #endif + +#if !QT_CONFIG(tabletevent) && !defined(XCB_USE_XINPUT21) + Q_UNUSED(bitMask); + Q_UNUSED(dpy); +#endif } QXcbConnection::TouchDeviceData *QXcbConnection::touchDeviceForId(int id) diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index d4521de8e0..1e963268ef 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -165,6 +165,9 @@ void QXcbDrag::init() QXcbCursor::queryPointer(connection(), ¤t_virtual_desktop, 0); drag_types.clear(); + + dropped = false; + canceled = false; } bool QXcbDrag::eventFilter(QObject *o, QEvent *e) @@ -215,6 +218,10 @@ void QXcbDrag::startDrag() void QXcbDrag::endDrag() { QBasicDrag::endDrag(); + if (!dropped && !canceled && canDrop()) { + // Set executed drop action when dropping outside application. + setExecutedDropAction(accepted_drop_action); + } initiatorWindow.clear(); } @@ -989,6 +996,8 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e // reset target_time = XCB_CURRENT_TIME; + + dropped = true; } @@ -1087,6 +1096,8 @@ void QXcbDrag::cancel() // remove canceled object currentDrag()->deleteLater(); + + canceled = true; } // find an ancestor with XdndAware on it diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index f261cc1322..31f1c47d83 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -135,6 +135,10 @@ private: QRect source_sameanswer; bool waiting_for_status; + // helpers for setting executed drop action outside application + bool dropped; + bool canceled; + // top-level window we sent position to last. xcb_window_t current_target; // window to send events to (always valid if current_target) diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index ec0f9ba561..67c96b2d80 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -446,17 +446,24 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe m_cursor = new QXcbCursor(connection, this); - // Parse EDID - if (m_edid.parse(getEdid())) - qCDebug(lcQpaScreen, "EDID data for output \"%s\": identifier '%s', manufacturer '%s', model '%s', serial '%s', physical size: %.2fx%.2f", - name().toLatin1().constData(), - m_edid.identifier.toLatin1().constData(), - m_edid.manufacturer.toLatin1().constData(), - m_edid.model.toLatin1().constData(), - m_edid.serialNumber.toLatin1().constData(), - m_edid.physicalSize.width(), m_edid.physicalSize.height()); - else - qCDebug(lcQpaScreen) << "Failed to parse EDID data for output" << name(); // keep this debug, not warning + if (connection->hasXRandr()) { // Parse EDID + QByteArray edid = getEdid(); + if (m_edid.parse(edid)) { + qCDebug(lcQpaScreen, "EDID data for output \"%s\": identifier '%s', manufacturer '%s'," + "model '%s', serial '%s', physical size: %.2fx%.2f", + name().toLatin1().constData(), + m_edid.identifier.toLatin1().constData(), + m_edid.manufacturer.toLatin1().constData(), + m_edid.model.toLatin1().constData(), + m_edid.serialNumber.toLatin1().constData(), + m_edid.physicalSize.width(), m_edid.physicalSize.height()); + } else { + // This property is defined by the xrandr spec. Parsing failure indicates a valid error, + // but keep this as debug, for details see 4f515815efc318ddc909a0399b71b8a684962f38. + qCDebug(lcQpaScreen) << "Failed to parse EDID data for output" << name() << + "edid data: " << edid; + } + } } QXcbScreen::~QXcbScreen() @@ -899,9 +906,13 @@ QByteArray QXcbScreen::getOutputProperty(xcb_atom_t atom) const QByteArray QXcbScreen::getEdid() const { + QByteArray result; + if (!connection()->hasXRandr()) + return result; + // Try a bunch of atoms xcb_atom_t atom = connection()->internAtom("EDID"); - QByteArray result = getOutputProperty(atom); + result = getOutputProperty(atom); if (result.isEmpty()) { atom = connection()->internAtom("EDID_DATA"); result = getOutputProperty(atom); diff --git a/src/plugins/sqldrivers/db2/db2.pro b/src/plugins/sqldrivers/db2/db2.pro index eef65fac66..b99fe91fe3 100644 --- a/src/plugins/sqldrivers/db2/db2.pro +++ b/src/plugins/sqldrivers/db2/db2.pro @@ -7,5 +7,7 @@ QMAKE_USE += db2 OTHER_FILES += db2.json +equals(QT_ARCH, x86_64): DEFINES += ODBC64 + PLUGIN_CLASS_NAME = QDB2DriverPlugin include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/db2/qsql_db2.cpp b/src/plugins/sqldrivers/db2/qsql_db2.cpp index 1a9631f1eb..2bfd99cfa9 100644 --- a/src/plugins/sqldrivers/db2/qsql_db2.cpp +++ b/src/plugins/sqldrivers/db2/qsql_db2.cpp @@ -272,7 +272,7 @@ static QSqlField qMakeFieldInfo(const QDB2ResultPrivate* d, int i) { SQLSMALLINT colNameLen; SQLSMALLINT colType; - SQLUINTEGER colSize; + SQLULEN colSize; SQLSMALLINT colScale; SQLSMALLINT nullable; SQLRETURN r = SQL_ERROR; @@ -314,7 +314,7 @@ static int qGetIntData(SQLHANDLE hStmt, int column, bool& isNull) { SQLINTEGER intbuf; isNull = false; - SQLINTEGER lengthIndicator = 0; + SQLLEN lengthIndicator = 0; SQLRETURN r = SQLGetData(hStmt, column + 1, SQL_C_SLONG, @@ -332,7 +332,7 @@ static double qGetDoubleData(SQLHANDLE hStmt, int column, bool& isNull) { SQLDOUBLE dblbuf; isNull = false; - SQLINTEGER lengthIndicator = 0; + SQLLEN lengthIndicator = 0; SQLRETURN r = SQLGetData(hStmt, column+1, SQL_C_DOUBLE, @@ -351,7 +351,7 @@ static SQLBIGINT qGetBigIntData(SQLHANDLE hStmt, int column, bool& isNull) { SQLBIGINT lngbuf = Q_INT64_C(0); isNull = false; - SQLINTEGER lengthIndicator = 0; + SQLLEN lengthIndicator = 0; SQLRETURN r = SQLGetData(hStmt, column+1, SQL_C_SBIGINT, @@ -368,7 +368,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool& is { QString fieldVal; SQLRETURN r = SQL_ERROR; - SQLINTEGER lengthIndicator = 0; + SQLLEN lengthIndicator = 0; if (colSize <= 0) colSize = 255; @@ -404,12 +404,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool& is return fieldVal; } -static QByteArray qGetBinaryData(SQLHANDLE hStmt, int column, SQLINTEGER& lengthIndicator, bool& isNull) +static QByteArray qGetBinaryData(SQLHANDLE hStmt, int column, SQLLEN& lengthIndicator, bool& isNull) { QByteArray fieldVal; SQLSMALLINT colNameLen; SQLSMALLINT colType; - SQLUINTEGER colSize; + SQLULEN colSize; SQLSMALLINT colScale; SQLSMALLINT nullable; SQLRETURN r = SQL_ERROR; @@ -643,9 +643,9 @@ bool QDB2Result::exec() { Q_D(QDB2Result); QList<QByteArray> tmpStorage; // holds temporary ptrs - QVarLengthArray<SQLINTEGER, 32> indicators(boundValues().count()); + QVarLengthArray<SQLLEN, 32> indicators(boundValues().count()); - memset(indicators.data(), 0, indicators.size() * sizeof(SQLINTEGER)); + memset(indicators.data(), 0, indicators.size() * sizeof(SQLLEN)); setActive(false); setAt(QSql::BeforeFirstRow); SQLRETURN r; @@ -661,7 +661,7 @@ bool QDB2Result::exec() int i; for (i = 0; i < values.count(); ++i) { // bind parameters - only positional binding allowed - SQLINTEGER *ind = &indicators[i]; + SQLLEN *ind = &indicators[i]; if (values.at(i).isNull()) *ind = SQL_NULL_DATA; if (bindValueType(i) & QSql::Out) @@ -1006,7 +1006,7 @@ QVariant QDB2Result::data(int field) return QVariant(); } SQLRETURN r = 0; - SQLINTEGER lengthIndicator = 0; + SQLLEN lengthIndicator = 0; bool isNull = false; const QSqlField info = d->recInf.field(field); @@ -1119,7 +1119,7 @@ bool QDB2Result::isNull(int i) int QDB2Result::numRowsAffected() { Q_D(const QDB2Result); - SQLINTEGER affectedRowCount = 0; + SQLLEN affectedRowCount = 0; SQLRETURN r = SQLRowCount(d->hStmt, &affectedRowCount); if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) return affectedRowCount; @@ -1248,7 +1248,7 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas const QString opt(tmp.left(idx)); const QString val(tmp.mid(idx + 1).simplified()); - SQLUINTEGER v = 0; + SQLULEN v = 0; r = SQL_SUCCESS; if (opt == QLatin1String("SQL_ATTR_ACCESS_MODE")) { if (val == QLatin1String("SQL_MODE_READ_ONLY")) { @@ -1634,7 +1634,7 @@ bool QDB2Driver::rollbackTransaction() bool QDB2Driver::setAutoCommit(bool autoCommit) { Q_D(QDB2Driver); - SQLUINTEGER ac = autoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; + SQLULEN ac = autoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; SQLRETURN r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_AUTOCOMMIT, reinterpret_cast<SQLPOINTER>(ac), diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 0f4b7a80af..35b0f9a3e3 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -229,7 +229,7 @@ class QPSQLResultPrivate : public QSqlResultPrivate { Q_DECLARE_PUBLIC(QPSQLResult) public: - Q_DECLARE_SQLDRIVER_PRIVATE(QPSQLDriver); + Q_DECLARE_SQLDRIVER_PRIVATE(QPSQLDriver) QPSQLResultPrivate(QPSQLResult *q, const QPSQLDriver *drv) : QSqlResultPrivate(q, drv), result(0), diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index 0a47ccf68a..4c982c14f4 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -286,10 +286,10 @@ static inline HWND createTreeViewHelperWindow() void *hwnd = 0; void *wndProc = reinterpret_cast<void *>(DefWindowProc); if (QMetaObject::invokeMethod(ni, "createMessageWindow", Qt::DirectConnection, - Q_RETURN_ARG(void *, hwnd), + Q_RETURN_ARG(void*, hwnd), Q_ARG(QString, QStringLiteral("QTreeViewThemeHelperWindowClass")), Q_ARG(QString, QStringLiteral("QTreeViewThemeHelperWindow")), - Q_ARG(void *, wndProc)) && hwnd) { + Q_ARG(void*, wndProc)) && hwnd) { return reinterpret_cast<HWND>(hwnd); } } diff --git a/src/printsupport/dialogs/qabstractprintdialog.cpp b/src/printsupport/dialogs/qabstractprintdialog.cpp index f982da46d9..71b5500bab 100644 --- a/src/printsupport/dialogs/qabstractprintdialog.cpp +++ b/src/printsupport/dialogs/qabstractprintdialog.cpp @@ -471,7 +471,7 @@ void QPrintDialog::done(int result) if (d->receiverToDisconnectOnClose) { disconnect(this, SIGNAL(accepted(QPrinter*)), d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); - d->receiverToDisconnectOnClose = 0; + d->receiverToDisconnectOnClose = nullptr; } d->memberToDisconnectOnClose.clear(); } diff --git a/src/printsupport/dialogs/qabstractprintdialog.h b/src/printsupport/dialogs/qabstractprintdialog.h index eb4dc3eb99..3cc89890fc 100644 --- a/src/printsupport/dialogs/qabstractprintdialog.h +++ b/src/printsupport/dialogs/qabstractprintdialog.h @@ -81,7 +81,7 @@ public: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption) Q_FLAG(PrintDialogOptions) - explicit QAbstractPrintDialog(QPrinter *printer, QWidget *parent = Q_NULLPTR); + explicit QAbstractPrintDialog(QPrinter *printer, QWidget *parent = nullptr); ~QAbstractPrintDialog(); int exec() override = 0; @@ -108,7 +108,7 @@ public: QPrinter *printer() const; protected: - QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr, QPrinter *printer, QWidget *parent = Q_NULLPTR); + QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr, QPrinter *printer, QWidget *parent = nullptr); private: Q_DISABLE_COPY(QAbstractPrintDialog) diff --git a/src/printsupport/dialogs/qabstractprintdialog_p.h b/src/printsupport/dialogs/qabstractprintdialog_p.h index 2537fcbf80..a17a28f564 100644 --- a/src/printsupport/dialogs/qabstractprintdialog_p.h +++ b/src/printsupport/dialogs/qabstractprintdialog_p.h @@ -69,7 +69,7 @@ class QAbstractPrintDialogPrivate : public QDialogPrivate public: QAbstractPrintDialogPrivate() - : printer(0), pd(0), ownsPrinter(false) + : printer(nullptr), pd(nullptr), ownsPrinter(false) , options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange | QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize), minPage(0), maxPage(INT_MAX) diff --git a/src/printsupport/dialogs/qpagesetupdialog.h b/src/printsupport/dialogs/qpagesetupdialog.h index 3bd752a413..70517dc844 100644 --- a/src/printsupport/dialogs/qpagesetupdialog.h +++ b/src/printsupport/dialogs/qpagesetupdialog.h @@ -57,8 +57,8 @@ class Q_PRINTSUPPORT_EXPORT QPageSetupDialog : public QDialog Q_DECLARE_PRIVATE(QPageSetupDialog) public: - explicit QPageSetupDialog(QPrinter *printer, QWidget *parent = Q_NULLPTR); - explicit QPageSetupDialog(QWidget *parent = Q_NULLPTR); + explicit QPageSetupDialog(QPrinter *printer, QWidget *parent = nullptr); + explicit QPageSetupDialog(QWidget *parent = nullptr); ~QPageSetupDialog(); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) diff --git a/src/printsupport/dialogs/qpagesetupdialog_p.h b/src/printsupport/dialogs/qpagesetupdialog_p.h index 6a389b039a..a2b3f8363c 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_p.h +++ b/src/printsupport/dialogs/qpagesetupdialog_p.h @@ -71,7 +71,7 @@ class QPageSetupDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QPageSetupDialog) public: - QPageSetupDialogPrivate(QPrinter *printer); + explicit QPageSetupDialogPrivate(QPrinter *printer); void setPrinter(QPrinter *newPrinter); diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index b048ba8b29..ee7bc62491 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -230,8 +230,8 @@ void QUnixPageSetupDialogPrivate::init() QPageSetupWidget::QPageSetupWidget(QWidget *parent) : QWidget(parent), - m_pagePreview(0), - m_printer(0), + m_pagePreview(nullptr), + m_printer(nullptr), m_outputFormat(QPrinter::PdfFormat), m_units(QPageLayout::Point), m_blockSignals(false) @@ -260,21 +260,21 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent) initUnits(); initPagesPerSheet(); - connect(m_ui.unitCombo, SIGNAL(activated(int)), this, SLOT(unitChanged())); + connect(m_ui.unitCombo, QOverload<int>::of(&QComboBox::activated), this, &QPageSetupWidget::unitChanged); - connect(m_ui.pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pageSizeChanged())); - connect(m_ui.pageWidth, SIGNAL(valueChanged(double)), this, SLOT(pageSizeChanged())); - connect(m_ui.pageHeight, SIGNAL(valueChanged(double)), this, SLOT(pageSizeChanged())); + connect(m_ui.pageSizeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &QPageSetupWidget::pageSizeChanged); + connect(m_ui.pageWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::pageSizeChanged); + connect(m_ui.pageHeight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::pageSizeChanged); - connect(m_ui.leftMargin, SIGNAL(valueChanged(double)), this, SLOT(leftMarginChanged(double))); - connect(m_ui.topMargin, SIGNAL(valueChanged(double)), this, SLOT(topMarginChanged(double))); - connect(m_ui.rightMargin, SIGNAL(valueChanged(double)), this, SLOT(rightMarginChanged(double))); - connect(m_ui.bottomMargin, SIGNAL(valueChanged(double)), this, SLOT(bottomMarginChanged(double))); + connect(m_ui.leftMargin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::leftMarginChanged); + connect(m_ui.topMargin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::topMarginChanged); + connect(m_ui.rightMargin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::rightMarginChanged); + connect(m_ui.bottomMargin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::bottomMarginChanged); - connect(m_ui.portrait, SIGNAL(clicked()), this, SLOT(pageOrientationChanged())); - connect(m_ui.landscape, SIGNAL(clicked()), this, SLOT(pageOrientationChanged())); + connect(m_ui.portrait, &QRadioButton::clicked, this, &QPageSetupWidget::pageOrientationChanged); + connect(m_ui.landscape, &QRadioButton::clicked, this, &QPageSetupWidget::pageOrientationChanged); - connect(m_ui.pagesPerSheetCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pagesPerSheetChanged())); + connect(m_ui.pagesPerSheetCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &QPageSetupWidget::pagesPerSheetChanged); } // Init the Units combo box diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h index 658f103bea..4322b34690 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h +++ b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h @@ -69,8 +69,8 @@ class QPagePreview; class QPageSetupWidget : public QWidget { Q_OBJECT public: - explicit QPageSetupWidget(QWidget *parent = 0); - explicit QPageSetupWidget(QPrinter *printer, QWidget *parent = 0); + explicit QPageSetupWidget(QWidget *parent = nullptr); + explicit QPageSetupWidget(QPrinter *printer, QWidget *parent = nullptr); void setPrinter(QPrinter *printer); void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName); diff --git a/src/printsupport/dialogs/qprintdialog.h b/src/printsupport/dialogs/qprintdialog.h index 5b81440a3c..bbddc296e9 100644 --- a/src/printsupport/dialogs/qprintdialog.h +++ b/src/printsupport/dialogs/qprintdialog.h @@ -59,8 +59,8 @@ class Q_PRINTSUPPORT_EXPORT QPrintDialog : public QAbstractPrintDialog Q_PROPERTY(PrintDialogOptions options READ options WRITE setOptions) public: - explicit QPrintDialog(QPrinter *printer, QWidget *parent = Q_NULLPTR); - explicit QPrintDialog(QWidget *parent = Q_NULLPTR); + explicit QPrintDialog(QPrinter *printer, QWidget *parent = nullptr); + explicit QPrintDialog(QWidget *parent = nullptr); ~QPrintDialog(); int exec() Q_DECL_OVERRIDE; diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index a5f381d0a2..0b36dec003 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -251,8 +251,8 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent) lay->addWidget(content); lay->addWidget(m_buttons); - connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); - connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); + connect(m_buttons->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &QPrintPropertiesDialog::accept); + connect(m_buttons->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QPrintPropertiesDialog::reject); #if QT_CONFIG(cupsjobwidget) m_jobOptions = new QCupsJobWidget(); @@ -608,7 +608,7 @@ QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent) Constructs a print dialog with the given \a parent. */ QPrintDialog::QPrintDialog(QWidget *parent) - : QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent) + : QAbstractPrintDialog(*(new QPrintDialogPrivate), nullptr, parent) { Q_D(QPrintDialog); d->init(); @@ -656,7 +656,7 @@ void QPrintDialog::accept() /*! \internal */ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *prn) - : parent(p), propertiesDialog(0), printer(prn), optionsPane(0), + : parent(p), propertiesDialog(nullptr), printer(prn), optionsPane(0), filePrintersAdded(false), propertiesDialogShown(false) { q = 0; @@ -673,7 +673,9 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter * widget.printers->addItems(printers); - const int idx = printers.indexOf(defaultPrinter); + const QString selectedPrinter = prn && !prn->printerName().isEmpty() ? prn->printerName() : defaultPrinter; + const int idx = printers.indexOf(selectedPrinter); + if (idx >= 0) currentPrinterIndex = idx; } @@ -788,7 +790,7 @@ void QUnixPrintWidgetPrivate::_q_btnBrowseClicked() QString filename = widget.filename->text(); #if QT_CONFIG(filedialog) filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename, - QString(), 0, QFileDialog::DontConfirmOverwrite); + QString(), nullptr, QFileDialog::DontConfirmOverwrite); #else filename.clear(); #endif @@ -895,8 +897,7 @@ bool QUnixPrintWidgetPrivate::checkFields() void QUnixPrintWidgetPrivate::setupPrinterProperties() { - if (propertiesDialog) - delete propertiesDialog; + delete propertiesDialog; propertiesDialog = new QPrintPropertiesDialog(q); propertiesDialog->setResult(QDialog::Rejected); diff --git a/src/printsupport/dialogs/qprintpreviewdialog.cpp b/src/printsupport/dialogs/qprintpreviewdialog.cpp index 174cfe4dba..906cb19043 100644 --- a/src/printsupport/dialogs/qprintpreviewdialog.cpp +++ b/src/printsupport/dialogs/qprintpreviewdialog.cpp @@ -79,7 +79,7 @@ class QPrintPreviewMainWindow : public QMainWindow { public: QPrintPreviewMainWindow(QWidget *parent) : QMainWindow(parent) {} - QMenu *createPopupMenu() Q_DECL_OVERRIDE { return 0; } + QMenu *createPopupMenu() Q_DECL_OVERRIDE { return nullptr; } }; class ZoomFactorValidator : public QDoubleValidator @@ -119,7 +119,7 @@ public: : QLineEdit(parent) { setContextMenuPolicy(Qt::NoContextMenu); - connect(this, SIGNAL(returnPressed()), SLOT(handleReturnPressed())); + connect(this, &LineEdit::returnPressed, this, &LineEdit::handleReturnPressed); } protected: diff --git a/src/printsupport/dialogs/qprintpreviewdialog.h b/src/printsupport/dialogs/qprintpreviewdialog.h index 3b8f8a1171..bacafcb734 100644 --- a/src/printsupport/dialogs/qprintpreviewdialog.h +++ b/src/printsupport/dialogs/qprintpreviewdialog.h @@ -58,8 +58,8 @@ class Q_PRINTSUPPORT_EXPORT QPrintPreviewDialog : public QDialog Q_DECLARE_PRIVATE(QPrintPreviewDialog) public: - explicit QPrintPreviewDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags()); - explicit QPrintPreviewDialog(QPrinter *printer, QWidget *parent = Q_NULLPTR, + explicit QPrintPreviewDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); + explicit QPrintPreviewDialog(QPrinter *printer, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); ~QPrintPreviewDialog(); diff --git a/src/printsupport/kernel/qpaintengine_preview.cpp b/src/printsupport/kernel/qpaintengine_preview.cpp index 4c00333097..7179249677 100644 --- a/src/printsupport/kernel/qpaintengine_preview.cpp +++ b/src/printsupport/kernel/qpaintengine_preview.cpp @@ -69,8 +69,8 @@ QPreviewPaintEngine::QPreviewPaintEngine() : QPaintEngine(*(new QPreviewPaintEnginePrivate), PaintEngineFeatures(AllFeatures & ~ObjectBoundingModeGradients)) { Q_D(QPreviewPaintEngine); - d->proxy_print_engine = 0; - d->proxy_paint_engine = 0; + d->proxy_print_engine = nullptr; + d->proxy_paint_engine = nullptr; } QPreviewPaintEngine::~QPreviewPaintEngine() @@ -102,8 +102,8 @@ bool QPreviewPaintEngine::end() Q_D(QPreviewPaintEngine); delete d->painter; - d->painter = 0; - d->engine = 0; + d->painter = nullptr; + d->engine = nullptr; d->state = QPrinter::Idle; return true; } diff --git a/src/printsupport/kernel/qplatformprintersupport.cpp b/src/printsupport/kernel/qplatformprintersupport.cpp index 388dd5ff8e..e12a292aec 100644 --- a/src/printsupport/kernel/qplatformprintersupport.cpp +++ b/src/printsupport/kernel/qplatformprintersupport.cpp @@ -70,12 +70,12 @@ QPlatformPrinterSupport::~QPlatformPrinterSupport() QPrintEngine *QPlatformPrinterSupport::createNativePrintEngine(QPrinter::PrinterMode, const QString &) { - return 0; + return nullptr; } QPaintEngine *QPlatformPrinterSupport::createPaintEngine(QPrintEngine *, QPrinter::PrinterMode) { - return 0; + return nullptr; } QPrintDevice QPlatformPrinterSupport::createPrintDevice(QPlatformPrintDevice *device) diff --git a/src/printsupport/kernel/qplatformprintplugin.cpp b/src/printsupport/kernel/qplatformprintplugin.cpp index a80f369040..9a7656f7d6 100644 --- a/src/printsupport/kernel/qplatformprintplugin.cpp +++ b/src/printsupport/kernel/qplatformprintplugin.cpp @@ -60,12 +60,12 @@ QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin() { } -static QPlatformPrinterSupport *printerSupport = 0; +static QPlatformPrinterSupport *printerSupport = nullptr; static void cleanupPrinterSupport() { delete printerSupport; - printerSupport = 0; + printerSupport = nullptr; } /*! diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp index 080ff7ccf4..873e146eec 100644 --- a/src/printsupport/kernel/qprintengine_pdf.cpp +++ b/src/printsupport/kernel/qprintengine_pdf.cpp @@ -381,7 +381,7 @@ void QPdfPrintEnginePrivate::closePrintDevice() #endif fd = -1; delete outDevice; - outDevice = 0; + outDevice = nullptr; } } diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 3135836ce7..d439fcbbbc 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -132,7 +132,7 @@ void QPrinterPrivate::initEngines(QPrinter::OutputFormat format, const QPrinterI { // Default to PdfFormat outputFormat = QPrinter::PdfFormat; - QPlatformPrinterSupport *ps = 0; + QPlatformPrinterSupport *ps = nullptr; QString printerName; // Only set NativeFormat if we have a valid plugin and printer to use diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp index 00f2d64df2..39acac020c 100644 --- a/src/printsupport/widgets/qcupsjobwidget.cpp +++ b/src/printsupport/widgets/qcupsjobwidget.cpp @@ -104,7 +104,7 @@ void QCupsJobWidget::initJobHold() m_ui.jobHoldComboBox->addItem(tr("Weekend (Saturday to Sunday)"), QVariant::fromValue(QCUPSSupport::Weekend)); m_ui.jobHoldComboBox->addItem(tr("Specific Time"), QVariant::fromValue(QCUPSSupport::SpecificTime)); - connect(m_ui.jobHoldComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleJobHoldTime())); + connect(m_ui.jobHoldComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &QCupsJobWidget::toggleJobHoldTime); setJobHold(QCUPSSupport::NoHold, QTime()); toggleJobHoldTime(); diff --git a/src/printsupport/widgets/qcupsjobwidget_p.h b/src/printsupport/widgets/qcupsjobwidget_p.h index 7d3c15938f..d66a472509 100644 --- a/src/printsupport/widgets/qcupsjobwidget_p.h +++ b/src/printsupport/widgets/qcupsjobwidget_p.h @@ -71,7 +71,7 @@ class QCupsJobWidget : public QWidget Q_OBJECT public: - explicit QCupsJobWidget(QWidget *parent = 0); + explicit QCupsJobWidget(QWidget *parent = nullptr); ~QCupsJobWidget(); void setPrinter(QPrinter *printer); void setupPrinter(); diff --git a/src/printsupport/widgets/qprintpreviewwidget.cpp b/src/printsupport/widgets/qprintpreviewwidget.cpp index 9e44603bb8..dc07517397 100644 --- a/src/printsupport/widgets/qprintpreviewwidget.cpp +++ b/src/printsupport/widgets/qprintpreviewwidget.cpp @@ -145,7 +145,7 @@ class GraphicsView : public QGraphicsView { Q_OBJECT public: - GraphicsView(QWidget* parent = 0) + GraphicsView(QWidget* parent = nullptr) : QGraphicsView(parent) { #ifdef Q_OS_MAC @@ -179,7 +179,7 @@ class QPrintPreviewWidgetPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QPrintPreviewWidget) public: QPrintPreviewWidgetPrivate() - : scene(0), curPage(1), + : scene(nullptr), curPage(1), viewMode(QPrintPreviewWidget::SinglePageView), zoomMode(QPrintPreviewWidget::FitInView), zoomFactor(1), initialized(false), fitting(true) diff --git a/src/printsupport/widgets/qprintpreviewwidget.h b/src/printsupport/widgets/qprintpreviewwidget.h index 8735d06072..d45cc1a9fb 100644 --- a/src/printsupport/widgets/qprintpreviewwidget.h +++ b/src/printsupport/widgets/qprintpreviewwidget.h @@ -69,9 +69,9 @@ public: FitInView }; - explicit QPrintPreviewWidget(QPrinter *printer, QWidget *parent = Q_NULLPTR, + explicit QPrintPreviewWidget(QPrinter *printer, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); - explicit QPrintPreviewWidget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags()); + explicit QPrintPreviewWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); ~QPrintPreviewWidget(); qreal zoomFactor() const; diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index f9cc07daa1..b89d20976f 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -649,11 +649,10 @@ bool QSqlQuery::next() { if (!isSelect() || !isActive()) return false; - bool b = false; + switch (at()) { case QSql::BeforeFirstRow: - b = d->sqlResult->fetchFirst(); - return b; + return d->sqlResult->fetchFirst(); case QSql::AfterLastRow: return false; default: @@ -703,13 +702,11 @@ bool QSqlQuery::previous() return false; } - bool b = false; switch (at()) { case QSql::BeforeFirstRow: return false; case QSql::AfterLastRow: - b = d->sqlResult->fetchLast(); - return b; + return d->sqlResult->fetchLast(); default: if (!d->sqlResult->fetchPrevious()) { d->sqlResult->setAt(QSql::BeforeFirstRow); @@ -737,9 +734,7 @@ bool QSqlQuery::first() qWarning("QSqlQuery::seek: cannot seek backwards in a forward only query"); return false; } - bool b = false; - b = d->sqlResult->fetchFirst(); - return b; + return d->sqlResult->fetchFirst(); } /*! @@ -758,9 +753,7 @@ bool QSqlQuery::last() { if (!isSelect() || !isActive()) return false; - bool b = false; - b = d->sqlResult->fetchLast(); - return b; + return d->sqlResult->fetchLast(); } /*! diff --git a/src/widgets/Qt5WidgetsMacros.cmake b/src/widgets/Qt5WidgetsMacros.cmake index f5e7b7f050..737371a5ad 100644 --- a/src/widgets/Qt5WidgetsMacros.cmake +++ b/src/widgets/Qt5WidgetsMacros.cmake @@ -59,6 +59,9 @@ function(QT5_WRAP_UI outfiles ) COMMAND ${Qt5Widgets_UIC_EXECUTABLE} ARGS ${ui_options} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} VERBATIM) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTOUIC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON) list(APPEND ${outfiles} ${outfile}) endforeach() set(${outfiles} ${${outfiles}} PARENT_SCOPE) diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 666b192e9c..bedcd1b0c2 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -263,7 +263,7 @@ static bool getCaptionQFont(int dpi, QFont *result) QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface(); return ni && QMetaObject::invokeMethod(ni, "logFontToQFont", Qt::DirectConnection, Q_RETURN_ARG(QFont, *result), - Q_ARG(const void *, &logFont), + Q_ARG(const void*, &logFont), Q_ARG(int, dpi)); } diff --git a/src/widgets/doc/images/stardelegate.png b/src/widgets/doc/images/stardelegate.png Binary files differindex 24fa9fb0d7..66f55c5fc7 100644 --- a/src/widgets/doc/images/stardelegate.png +++ b/src/widgets/doc/images/stardelegate.png diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 463ed7e58c..c7966f624f 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2086,40 +2086,26 @@ void QHeaderViewPrivate::_q_layoutChanged() { Q_Q(QHeaderView); viewport->update(); - if (persistentHiddenSections.isEmpty() || modelIsEmpty()) { - if (modelSectionCount() != sectionCount()) - q->initializeSections(); - persistentHiddenSections.clear(); + + const auto hiddenSections = persistentHiddenSections; + persistentHiddenSections.clear(); + + clear(); + q->initializeSections(); + invalidateCachedSizeHint(); + + if (modelIsEmpty()) { return; } - QBitArray oldSectionHidden = sectionsHiddenToBitVector(); - oldSectionHidden.resize(sectionItems.size()); - bool sectionCountChanged = false; - - for (int i = 0; i < persistentHiddenSections.count(); ++i) { - QModelIndex index = persistentHiddenSections.at(i); + for (const auto &index : hiddenSections) { if (index.isValid()) { const int logical = (orientation == Qt::Horizontal ? index.column() : index.row()); q->setSectionHidden(logical, true); - oldSectionHidden.setBit(logical, false); - } else if (!sectionCountChanged && (modelSectionCount() != sectionCount())) { - sectionCountChanged = true; - break; } } - persistentHiddenSections.clear(); - - for (int i = 0; i < oldSectionHidden.count(); ++i) { - if (oldSectionHidden.testBit(i)) - q->setSectionHidden(i, false); - } - - // the number of sections changed; we need to reread the state of the model - if (sectionCountChanged) - q->initializeSections(); } /*! diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 2d5813198c..8ab811e9f7 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1397,6 +1397,9 @@ void QTableView::paintEvent(QPaintEvent *event) } else { dirtyArea.setRight(qMin(dirtyArea.right(), int(x))); } + // dirtyArea may be invalid when the horizontal header is not stretched + if (!dirtyArea.isValid()) + continue; // get the horizontal start and end visual sections int left = horizontalHeader->visualIndexAt(dirtyArea.left()); diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 61721143ef..d6d0fd4322 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -736,7 +736,10 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto void QTreeView::hideColumn(int column) { Q_D(QTreeView); + if (d->header->isSectionHidden(column)) + return; d->header->hideSection(column); + doItemsLayout(); } /*! @@ -747,7 +750,10 @@ void QTreeView::hideColumn(int column) void QTreeView::showColumn(int column) { Q_D(QTreeView); + if (!d->header->isSectionHidden(column)) + return; d->header->showSection(column); + doItemsLayout(); } /*! @@ -1008,11 +1014,16 @@ void QTreeView::keyboardSearch(const QString &search) if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root)) return; + // Do a relayout nows, so that we can utilize viewItems + d->executePostedLayout(); + if (d->viewItems.isEmpty()) + return; + QModelIndex start; if (currentIndex().isValid()) start = currentIndex(); else - start = d->model->index(0, 0, d->root); + start = d->viewItems.at(0).index; bool skipRow = false; bool keyboardTimeWasValid = d->keyboardInputTime.isValid(); @@ -1040,13 +1051,16 @@ void QTreeView::keyboardSearch(const QString &search) // skip if we are searching for the same key or a new search started if (skipRow) { - if (indexBelow(start).isValid()) + if (indexBelow(start).isValid()) { start = indexBelow(start); - else - start = d->model->index(0, start.column(), d->root); + } else { + const int origCol = start.column(); + start = d->viewItems.at(0).index; + if (origCol != start.column()) + start = start.sibling(start.row(), origCol); + } } - d->executePostedLayout(); int startIndex = d->viewIndex(start); if (startIndex <= -1) return; diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 074aa3ecec..e002b49d25 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -476,8 +476,10 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, break; if (option->state & State_Open) drawPrimitive(PE_IndicatorArrowDown, option, painter, widget); - else - drawPrimitive(PE_IndicatorArrowRight, option, painter, widget); + else { + const bool reverse = (option->direction == Qt::RightToLeft); + drawPrimitive(reverse ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight, option, painter, widget); + } break; } #if QT_CONFIG(tabbar) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index c5b912e35b..57d7fb1bc8 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -902,8 +902,7 @@ void QMenuPrivate::adjustMenuScreen(const QPoint &p) // The windowHandle must point to the screen where the menu will be shown. // The (item) size calculations depend on the menu screen, // so a wrong screen would often cause wrong sizes (on high DPI) - const QScreen *primaryScreen = QApplication::primaryScreen(); - const QScreen *currentScreen = q->windowHandle() ? q->windowHandle()->screen() : primaryScreen; + const QScreen *currentScreen = q->windowHandle() ? q->windowHandle()->screen() : nullptr; const int screenNumberForPoint = QApplication::desktop()->screenNumber(p); QScreen *actualScreen = QGuiApplication::screens().at(screenNumberForPoint); if (actualScreen && currentScreen != actualScreen) { diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 1c6d41ee2f..a00557c34e 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -1119,6 +1119,8 @@ static bool waitForPopup(QToolBar *tb, QWidget *popup) static void enableMacToolBar(QToolBar *toolbar, bool enable) { QPlatformNativeInterface *nativeInterface = QApplication::platformNativeInterface(); + if (!nativeInterface) + return; QPlatformNativeInterface::NativeResourceForIntegrationFunction function = nativeInterface->nativeResourceFunctionForIntegration("setContentBorderAreaEnabled"); if (!function) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 0e6da23c09..40c86132e9 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -157,7 +157,13 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT NO_WIDGETS) expect_pass(test_interface) endif() -if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) - expect_pass(test_interface_link_libraries) - expect_pass(test_moc_macro_target) +expect_pass(test_interface_link_libraries) +expect_pass(test_moc_macro_target) + +if (NOT CMAKE_VERSION VERSION_LESS 3.8) + # With earlier CMake versions, this test would simply run moc multiple times and lead to: + # /usr/bin/ld: error: CMakeFiles/mywidget.dir/mywidget_automoc.cpp.o: multiple definition of 'MyWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)' + # /usr/bin/ld: CMakeFiles/mywidget.dir/moc_mywidget.cpp.o: previous definition here + # Reason: SKIP_* properties were added in CMake 3.8 only + expect_pass(test_QTBUG-63422) endif() diff --git a/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt b/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt new file mode 100644 index 0000000000..a0b82caee4 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 2.8) +project(test_dependent_modules) + +find_package(Qt5Widgets REQUIRED) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# make sure CMP0071 warnings cause a test failure +set(CMAKE_SUPPRESS_DEVELOPER_ERRORS FALSE CACHE INTERNAL "" FORCE) + +qt5_wrap_cpp(moc_files mywidget.h) +qt5_wrap_ui(ui_files mywidget.ui) +qt5_add_resources(qrc_files res.qrc) + +add_executable(mywidget + # source files + mywidget.cpp + mywidget.h + mywidget.ui + res.qrc + + # generated files + ${moc_files} + ${ui_files} + ${qrc_files} +) +target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES}) diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp new file mode 100644 index 0000000000..7bc42537d5 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk <kevin.funk@kdab.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mywidget.h" +#include "ui_mywidget.h" + +MyWidget::MyWidget(QWidget *parent) + : QWidget(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + MyWidget myWidget; + return 0; +} diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.h b/tests/auto/cmake/test_QTBUG-63422/mywidget.h new file mode 100644 index 0000000000..d0c79c0538 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk <kevin.funk@kdab.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYWIDGET_H +#define MYWIDGET_H + +#include <QWidget> + +namespace Ui +{ +class MyWidget; +} + +class MyWidget : public QWidget +{ + Q_OBJECT +public: + MyWidget(QWidget *parent = nullptr); + +signals: + void someSignal(); + +private: + Ui::MyWidget *ui = nullptr; +}; + +#endif diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.ui b/tests/auto/cmake/test_QTBUG-63422/mywidget.ui new file mode 100644 index 0000000000..ac42ac4dc2 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.ui @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + <item> + <widget class="QTextEdit" name="textEdit"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/cmake/test_QTBUG-63422/res.qrc b/tests/auto/cmake/test_QTBUG-63422/res.qrc new file mode 100644 index 0000000000..4ca9cd5837 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/res.qrc @@ -0,0 +1,4 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> +</qresource> +</RCC> diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 7dd1a1be01..2f1b56629a 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -290,6 +290,18 @@ void tst_QFlags::testSetFlags() btn.setFlag(Qt::LeftButton, false); QVERIFY(!btn.testFlag(Qt::LeftButton)); QVERIFY(!btn.testFlag(Qt::MidButton)); + + MyStrictFlags flags; + flags.setFlag(MyStrictEnum::StrictOne); + flags.setFlag(MyStrictEnum::StrictTwo, true); + QVERIFY(flags.testFlag(MyStrictEnum::StrictOne)); + QVERIFY(flags.testFlag(MyStrictEnum::StrictTwo)); + QVERIFY(!flags.testFlag(MyStrictEnum::StrictFour)); + + flags.setFlag(MyStrictEnum::StrictTwo, false); + QVERIFY(flags.testFlag(MyStrictEnum::StrictOne)); + QVERIFY(!flags.testFlag(MyStrictEnum::StrictTwo)); + QVERIFY(!flags.testFlag(MyStrictEnum::StrictFour)); } // (statically) check QTypeInfo for QFlags instantiations: diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp index 1643eed3d2..15c63d4acd 100644 --- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp +++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp @@ -197,10 +197,22 @@ private slots: // Check whether QT_LOGGING_CONF is picked up from environment // - qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit()); + Q_ASSERT(!qApp); // Rules should not require an app to resolve - QLoggingRegistry registry; - registry.init(); + qputenv("QT_LOGGING_RULES", "qt.foo.bar=true"); + QLoggingCategory qtEnabledByLoggingRule("qt.foo.bar"); + QCOMPARE(qtEnabledByLoggingRule.isDebugEnabled(), true); + QLoggingCategory qtDisabledByDefault("qt.foo.baz"); + QCOMPARE(qtDisabledByDefault.isDebugEnabled(), false); + + QLoggingRegistry ®istry = *QLoggingRegistry::instance(); + QCOMPARE(registry.ruleSets[QLoggingRegistry::ApiRules].size(), 0); + QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 0); + QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].size(), 1); + + qunsetenv("QT_LOGGING_RULES"); + qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit()); + registry.initalizeRules(); QCOMPARE(registry.ruleSets[QLoggingRegistry::ApiRules].size(), 0); QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 0); @@ -208,7 +220,7 @@ private slots: // check that QT_LOGGING_RULES take precedence qputenv("QT_LOGGING_RULES", "Digia.*=true"); - registry.init(); + registry.initalizeRules(); QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].size(), 2); QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].at(1).enabled, true); } @@ -234,7 +246,7 @@ private slots: file.close(); QLoggingRegistry registry; - registry.init(); + registry.initalizeRules(); QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 1); // remove file again @@ -300,6 +312,6 @@ private slots: } }; -QTEST_MAIN(tst_QLoggingRegistry) +QTEST_APPLESS_MAIN(tst_QLoggingRegistry) #include "tst_qloggingregistry.moc" diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 094c6ed0a5..1092216fb7 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -95,6 +95,7 @@ private slots: void stackSize(); void stressTest(); void takeAllAndIncreaseMaxThreadCount(); + void waitForDoneAfterTake(); private: QMutex m_functionTestMutex; @@ -1267,5 +1268,72 @@ void tst_QThreadPool::takeAllAndIncreaseMaxThreadCount() { delete task3; } +void tst_QThreadPool::waitForDoneAfterTake() +{ + class Task : public QRunnable + { + public: + Task(QSemaphore *mainBarrier, QSemaphore *threadBarrier) + : m_mainBarrier(mainBarrier) + , m_threadBarrier(threadBarrier) + {} + + void run() + { + m_mainBarrier->release(); + m_threadBarrier->acquire(); + } + + private: + QSemaphore *m_mainBarrier = nullptr; + QSemaphore *m_threadBarrier = nullptr; + }; + + int threadCount = 4; + + // Blocks the main thread from releasing the threadBarrier before all run() functions have started + QSemaphore mainBarrier; + // Blocks the tasks from completing their run function + QSemaphore threadBarrier; + + QThreadPool manager; + manager.setMaxThreadCount(threadCount); + + // Fill all the threads with runnables that wait for the threadBarrier + for (int i = 0; i < threadCount; i++) { + auto *task = new Task(&mainBarrier, &threadBarrier); + manager.start(task); + } + + QVERIFY(manager.activeThreadCount() == manager.maxThreadCount()); + + // Add runnables that are immediately removed from the pool queue. + // This sets the queue elements to nullptr in QThreadPool and we want to test that + // the threads keep going through the queue after encountering a nullptr. + for (int i = 0; i < threadCount; i++) { + QRunnable *runnable = createTask(emptyFunct); + manager.start(runnable); + QVERIFY(manager.tryTake(runnable)); + } + + // Add another runnable that will not be removed + manager.start(createTask(emptyFunct)); + + // Wait for the first runnables to start + mainBarrier.acquire(threadCount); + + QVERIFY(mainBarrier.available() == 0); + QVERIFY(threadBarrier.available() == 0); + + // Release runnables that are waiting and expect all runnables to complete + threadBarrier.release(threadCount); + + // Using qFatal instead of QVERIFY to force exit if threads are still running after timeout. + // Otherwise, QCoreApplication will still wait for the stale threads and never exit the test. + if (!manager.waitForDone(5 * 60 * 1000)) + qFatal("waitForDone returned false. Aborting to stop background threads."); + +} + QTEST_MAIN(tst_QThreadPool); #include "tst_qthreadpool.moc" diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 374fec221e..6975452d76 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -245,6 +245,7 @@ private slots: void qhashInt() const { qhash<int>(); } void qhashMovable() const { qhash<Movable>(); } void qhashCustom() const { qhash<Custom>(); } + void removeAllWithAlias() const; void removeInt() const; void removeMovable() const; void removeCustom() const; @@ -1722,6 +1723,13 @@ void tst_QVector::prependCustom() const QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } +void tst_QVector::removeAllWithAlias() const +{ + QVector<QString> strings; + strings << "One" << "Two" << "Three" << "One" /* must be distinct, but equal */; + QCOMPARE(strings.removeAll(strings.front()), 2); // will trigger asan/ubsan +} + template<typename T> void tst_QVector::remove() const { diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index d6fc717e37..1052239797 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -32,6 +32,8 @@ linux windows [putToFtp] windows ci +[putToFtpWithInvalidCredentials] +windows ci [putWithServerClosingConnectionImmediately] windows [qtbug28035browserDoesNotLoadQtProjectOrgCorrectly] diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index fffe853c14..a2e602e4c5 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -622,7 +622,7 @@ protected: Q_ASSERT(!client.isNull()); // we need to emulate the bytesWrittenSlot call if the data is empty. if (dataToTransmit.size() == 0) { - QMetaObject::invokeMethod(this, "bytesWrittenSlot", Qt::QueuedConnection); + emit client->bytesWritten(0); } else { client->write(dataToTransmit); // FIXME: For SSL connections, if we don't flush the socket, the @@ -659,22 +659,26 @@ private slots: #ifndef QT_NO_SSL void slotSslErrors(const QList<QSslError>& errors) { - Q_ASSERT(!client.isNull()); - qDebug() << "slotSslErrors" << client->errorString() << errors; + QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender()); + Q_ASSERT(currentClient); + qDebug() << "slotSslErrors" << currentClient->errorString() << errors; } #endif void slotError(QAbstractSocket::SocketError err) { - if (client.isNull()) - qDebug() << "slotError" << err; - else - qDebug() << "slotError" << err << client->errorString(); + QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender()); + Q_ASSERT(currentClient); + qDebug() << "slotError" << err << currentClient->errorString(); } public slots: void readyReadSlot() { - Q_ASSERT(!client.isNull()); + QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender()); + Q_ASSERT(currentClient); + if (currentClient != client) + client = currentClient; + receivedData += client->readAll(); const int doubleEndlPos = receivedData.indexOf("\r\n\r\n"); @@ -8290,11 +8294,23 @@ void tst_QNetworkReply::ioHttpRedirectErrors() QNetworkReplyPtr reply(manager.get(request)); if (localhost.scheme() == "https") reply.data()->ignoreSslErrors(); - QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError))); - QCOMPARE(waitForFinish(reply), int(Failure)); + QEventLoop eventLoop; + QTimer watchDog; + watchDog.setSingleShot(true); - QCOMPARE(spy.count(), 1); + reply->connect(reply.data(), QOverload<QNetworkReply::NetworkError>().of(&QNetworkReply::error), + [&eventLoop](QNetworkReply::NetworkError){ + eventLoop.exit(Failure); + }); + + watchDog.connect(&watchDog, &QTimer::timeout, [&eventLoop](){ + eventLoop.exit(Timeout); + }); + + watchDog.start(5000); + + QCOMPARE(eventLoop.exec(), int(Failure)); QCOMPARE(reply->error(), error); } diff --git a/tests/auto/network/socket/qtcpsocket/BLACKLIST b/tests/auto/network/socket/qtcpsocket/BLACKLIST index 5fc2589323..96e59e5678 100644 --- a/tests/auto/network/socket/qtcpsocket/BLACKLIST +++ b/tests/auto/network/socket/qtcpsocket/BLACKLIST @@ -6,8 +6,6 @@ windows windows [invalidProxy:socks5-on-http] windows -[disconnectWhileLookingUp] -windows [timeoutConnect:ip] windows ] diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index d7c8c8c378..e45eda2940 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -1445,8 +1445,15 @@ void tst_QTcpSocket::disconnectWhileLookingUp() } // let anything queued happen + QEventLoop loop; - QTimer::singleShot(50, &loop, SLOT(quit())); + // If 'doClose' is false then we called '::waitForDisconnected' earlier, meaning + // we are already 'Unconnected'. So we don't need to wait for any potentially slow host lookups. + QTimer::singleShot(doClose ? 4000 : 50, &loop, SLOT(quit())); + connect(socket, &QTcpSocket::stateChanged, [&loop](QAbstractSocket::SocketState state) { + if (state == QAbstractSocket::UnconnectedState) + loop.exit(); // we don't need to wait for the timer to expire; we're done. + }); loop.exec(); // recheck diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 0f46caa7c2..6dff9f3420 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -47,12 +47,6 @@ #include "../../../network-settings.h" #include "emulationdetector.h" -#ifndef QT_NO_BEARERMANAGEMENT -#include <QtNetwork/qnetworkconfigmanager.h> -#include <QtNetwork/qnetworkconfiguration.h> -#include <QtNetwork/qnetworksession.h> -#endif - #if defined(Q_OS_LINUX) #define SHOULD_CHECK_SYSCALL_SUPPORT #include <netinet/in.h> @@ -130,11 +124,6 @@ private: bool m_skipUnsupportedIPv6Tests; QList<QHostAddress> allAddresses; -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager *netConfMan; - QNetworkConfiguration networkConfiguration; - QSharedPointer<QNetworkSession> networkSession; -#endif QUdpSocket *m_asyncSender; QUdpSocket *m_asyncReceiver; }; @@ -210,16 +199,6 @@ void tst_QUdpSocket::initTestCase_data() if (!newTestServer) QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); #endif - -#ifndef QT_NO_BEARERMANAGEMENT - netConfMan = new QNetworkConfigurationManager(this); - networkConfiguration = netConfMan->defaultConfiguration(); - networkSession = QSharedPointer<QNetworkSession>::create(networkConfiguration); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); - } -#endif } void tst_QUdpSocket::initTestCase() @@ -261,9 +240,6 @@ void tst_QUdpSocket::cleanup() void tst_QUdpSocket::constructing() { QUdpSocket socket; -#ifdef FORCE_SESSION - socket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(socket.isSequential()); QVERIFY(!socket.isOpen()); @@ -281,9 +257,6 @@ void tst_QUdpSocket::constructing() void tst_QUdpSocket::unconnectedServerAndClientTest() { QUdpSocket serverSocket; -#ifdef FORCE_SESSION - serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState"); @@ -296,9 +269,6 @@ void tst_QUdpSocket::unconnectedServerAndClientTest() QHostAddress serverAddress = makeNonAny(serverSocket.localAddress()); for (int i = 0; i < 3; ++i) { QUdpSocket clientSocket; -#ifdef FORCE_SESSION - clientSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QCOMPARE(int(clientSocket.writeDatagram(message[i], strlen(message[i]), serverAddress, serverSocket.localPort())), int(strlen(message[i]))); @@ -352,9 +322,6 @@ void tst_QUdpSocket::broadcasting() QSKIP("No interface can broadcast"); for (int i = 0; i < 4; ++i) { QUdpSocket serverSocket; -#ifdef FORCE_SESSION - serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(serverSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0), serverSocket.errorString().toLatin1().constData()); quint16 serverPort = serverSocket.localPort(); @@ -363,9 +330,6 @@ void tst_QUdpSocket::broadcasting() connect(&serverSocket, SIGNAL(readyRead()), SLOT(empty_readyReadSlot())); QUdpSocket broadcastSocket; -#ifdef FORCE_SESSION - broadcastSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif broadcastSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0); for (int j = 0; j < 10; ++j) { @@ -444,10 +408,6 @@ void tst_QUdpSocket::loop() QUdpSocket peter; QUdpSocket paul; -#ifdef FORCE_SESSION - peter.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - paul.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // make sure we bind to IPv4 QHostAddress localhost = QHostAddress::LocalHost; @@ -518,10 +478,6 @@ void tst_QUdpSocket::ipv6Loop() QUdpSocket peter; QUdpSocket paul; -#ifdef FORCE_SESSION - peter.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - paul.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif int peterPort; int paulPort; @@ -745,10 +701,6 @@ void tst_QUdpSocket::connectToHost() { QUdpSocket socket1; QUdpSocket socket2; -#ifdef FORCE_SESSION - socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(socket1.bind(), socket1.errorString().toLatin1().constData()); @@ -763,11 +715,6 @@ void tst_QUdpSocket::bindAndConnectToHost() QUdpSocket socket1; QUdpSocket socket2; QUdpSocket dummysocket; -#ifdef FORCE_SESSION - socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - dummysocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // we use the dummy socket to use up a file descriptor dummysocket.bind(); @@ -791,16 +738,10 @@ void tst_QUdpSocket::bindAndConnectToHost() void tst_QUdpSocket::pendingDatagramSize() { QUdpSocket server; -#ifdef FORCE_SESSION - server.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; -#ifdef FORCE_SESSION - client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(client.writeDatagram("this is", 7, serverAddress, server.localPort()) == 7); QVERIFY(client.writeDatagram(0, 0, serverAddress, server.localPort()) == 0); QVERIFY(client.writeDatagram("3 messages", 10, serverAddress, server.localPort()) == 10); @@ -839,16 +780,10 @@ void tst_QUdpSocket::pendingDatagramSize() void tst_QUdpSocket::writeDatagram() { QUdpSocket server; -#ifdef FORCE_SESSION - server.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; -#ifdef FORCE_SESSION - client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); @@ -886,16 +821,10 @@ void tst_QUdpSocket::performance() QByteArray arr(8192, '@'); QUdpSocket server; -#ifdef FORCE_SESSION - server.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; -#ifdef FORCE_SESSION - client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif client.connectToHost(serverAddress, server.localPort()); QVERIFY(client.waitForConnected(10000)); @@ -932,14 +861,8 @@ void tst_QUdpSocket::bindMode() } QUdpSocket socket; -#ifdef FORCE_SESSION - socket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData()); QUdpSocket socket2; -#ifdef FORCE_SESSION - socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(!socket2.bind(socket.localPort())); #if defined(Q_OS_UNIX) QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); @@ -991,9 +914,6 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer() quint16 peerPort = 33533 + int(bind); QUdpSocket sUdp; -#ifdef FORCE_SESSION - sUdp.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QSignalSpy sReadyReadSpy(&sUdp, SIGNAL(readyRead())); if (bind) QVERIFY(sUdp.bind()); @@ -1026,9 +946,6 @@ void tst_QUdpSocket::writeToNonExistingPeer() qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); QUdpSocket sConnected; -#ifdef FORCE_SESSION - sConnected.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QSignalSpy sConnectedReadyReadSpy(&sConnected, SIGNAL(readyRead())); QSignalSpy sConnectedErrorSpy(&sConnected, SIGNAL(error(QAbstractSocket::SocketError))); sConnected.connectToHost(peerAddress, peerPort, QIODevice::ReadWrite); @@ -1198,18 +1115,12 @@ void tst_QUdpSocket::zeroLengthDatagram() return; QUdpSocket receiver; -#ifdef FORCE_SESSION - receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(receiver.bind()); QVERIFY(!receiver.waitForReadyRead(100)); QVERIFY(!receiver.hasPendingDatagrams()); QUdpSocket sender; -#ifdef FORCE_SESSION - sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QCOMPARE(sender.writeDatagram(QNetworkDatagram(QByteArray(), QHostAddress::LocalHost, receiver.localPort())), qint64(0)); QVERIFY2(receiver.waitForReadyRead(1000), QtNetworkSettings::msgSocketError(receiver).constData()); @@ -1262,9 +1173,6 @@ void tst_QUdpSocket::multicastTtlOption() } QUdpSocket udpSocket; -#ifdef FORCE_SESSION - udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // bind, but ignore the result, we are only interested in initializing the socket (void) udpSocket.bind(bindAddress, 0); udpSocket.setSocketOption(QUdpSocket::MulticastTtlOption, ttl); @@ -1315,9 +1223,6 @@ void tst_QUdpSocket::multicastLoopbackOption() } QUdpSocket udpSocket; -#ifdef FORCE_SESSION - udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // bind, but ignore the result, we are only interested in initializing the socket (void) udpSocket.bind(bindAddress, 0); udpSocket.setSocketOption(QUdpSocket::MulticastLoopbackOption, loopback); @@ -1341,9 +1246,6 @@ void tst_QUdpSocket::multicastJoinBeforeBind() QFETCH(QHostAddress, groupAddress); QUdpSocket udpSocket; -#ifdef FORCE_SESSION - udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // cannot join group before binding QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::joinMulticastGroup() called on a QUdpSocket when not in QUdpSocket::BoundState"); QVERIFY(!udpSocket.joinMulticastGroup(groupAddress)); @@ -1376,9 +1278,6 @@ void tst_QUdpSocket::multicastLeaveAfterClose() } QUdpSocket udpSocket; -#ifdef FORCE_SESSION - udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QHostAddress bindAddress = QHostAddress::AnyIPv4; if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) bindAddress = QHostAddress::AnyIPv6; @@ -1487,9 +1386,6 @@ void tst_QUdpSocket::multicast() } QUdpSocket receiver; -#ifdef FORCE_SESSION - receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // bind first, then verify that we can join the multicast group QVERIFY2(receiver.bind(bindAddress, 0) == bindResult, @@ -1515,9 +1411,6 @@ void tst_QUdpSocket::multicast() << QByteArray("cdef"); QUdpSocket sender; -#ifdef FORCE_SESSION - sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif sender.bind(); foreach (const QByteArray &datagram, datagrams) { QCOMPARE(int(sender.writeDatagram(datagram, groupAddress, receiver.localPort())), @@ -1563,9 +1456,6 @@ void tst_QUdpSocket::echo() QHostAddress remote = info.addresses().first(); QUdpSocket sock; -#ifdef FORCE_SESSION - sock.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif if (connect) { sock.connectToHost(remote, 7); QVERIFY(sock.waitForConnected(10000)); @@ -1785,10 +1675,6 @@ void tst_QUdpSocket::readyRead() char buf[1]; QUdpSocket sender, receiver; -#ifdef FORCE_SESSION - sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(receiver.bind(QHostAddress(QHostAddress::AnyIPv4), 0)); quint16 port = receiver.localPort(); @@ -1839,10 +1725,6 @@ void tst_QUdpSocket::readyReadForEmptyDatagram() return; QUdpSocket sender, receiver; -#ifdef FORCE_SESSION - sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(receiver.bind(QHostAddress(QHostAddress::AnyIPv4), 0)); quint16 port = receiver.localPort(); @@ -1891,10 +1773,6 @@ void tst_QUdpSocket::asyncReadDatagram() m_asyncSender = new QUdpSocket; m_asyncReceiver = new QUdpSocket; -#ifdef FORCE_SESSION - m_asyncSender->setProperty("_q_networksession", QVariant::fromValue(networkSession)); - m_asyncReceiver->setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(m_asyncReceiver->bind(QHostAddress(QHostAddress::AnyIPv4), 0)); quint16 port = m_asyncReceiver->localPort(); diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST index 52c023b78f..a9ecc69f50 100644 --- a/tests/auto/network/ssl/qsslsocket/BLACKLIST +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -1,6 +1,4 @@ windows -[waitForConnectedEncryptedReadyRead:WithSocks5ProxyAuth] -* [protocolServerSide:ssl3-any] rhel-7.2 [protocolServerSide:tls1.0-any] diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 12588c5e29..4de77a9080 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1601,7 +1601,12 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead() QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); - QVERIFY(socket->waitForReadyRead(10000)); + + // We only do this if we have no bytes available to read already because readyRead will + // not be emitted again. + if (socket->bytesAvailable() == 0) + QVERIFY(socket->waitForReadyRead(10000)); + QVERIFY(!socket->peerCertificate().isNull()); QVERIFY(!socket->peerCertificateChain().isEmpty()); } diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index fa543ae2c3..90019a1798 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -210,6 +210,7 @@ private slots: void QTBUG12268_hiddenMovedSectionSorting(); void QTBUG14242_hideSectionAutoSize(); void QTBUG50171_visualRegionForSwappedItems(); + void QTBUG53221_assertShiftHiddenRow(); void ensureNoIndexAtLength(); void offsetConsistent(); @@ -2384,6 +2385,54 @@ void tst_QHeaderView::QTBUG50171_visualRegionForSwappedItems() headerView.testVisualRegionForSelection(); } +class QTBUG53221_Model : public QAbstractItemModel +{ +public: + void insertRowAtBeginning() + { + Q_EMIT layoutAboutToBeChanged(); + m_displayNames.insert(0, QStringLiteral("Item %1").arg(m_displayNames.count())); + // Rows are always inserted at the beginning, so move all others. + foreach (const QModelIndex &persIndex, persistentIndexList()) + { + // The vertical header view will have a persistent index stored here on the second call to insertRowAtBeginning. + changePersistentIndex(persIndex, index(persIndex.row() + 1, persIndex.column(), persIndex.parent())); + } + Q_EMIT layoutChanged(); + } + + QVariant data(const QModelIndex &index, int role) const override + { + return (role == Qt::DisplayRole) ? m_displayNames.at(index.row()) : QVariant(); + } + + QModelIndex index(int row, int column, const QModelIndex &) const override { return createIndex(row, column); } + QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); } + int rowCount(const QModelIndex &) const override { return m_displayNames.count(); } + int columnCount(const QModelIndex &) const override { return 1; } + +private: + QStringList m_displayNames; +}; + +void tst_QHeaderView::QTBUG53221_assertShiftHiddenRow() +{ + QTableView tableView; + QTBUG53221_Model modelTableView; + tableView.setModel(&modelTableView); + + modelTableView.insertRowAtBeginning(); + tableView.setRowHidden(0, true); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), true); + modelTableView.insertRowAtBeginning(); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), false); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(1), true); + modelTableView.insertRowAtBeginning(); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), false); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(1), false); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(2), true); +} + void protected_QHeaderView::testVisualRegionForSelection() { QRegion r = visualRegionForSelection(QItemSelection(model()->index(1, 0), model()->index(1, 2))); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 929b80ba15..b2e1a2d9b5 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -196,6 +196,7 @@ private slots: void taskQTBUG_37813_crash(); void taskQTBUG_45697_crash(); void taskQTBUG_7232_AllowUserToControlSingleStep(); + void taskQTBUG_8376(); void testInitialFocus(); }; @@ -1086,6 +1087,103 @@ void tst_QTreeView::keyboardSearch() // The item that starts with B is selected. view.keyboardSearch(QLatin1String("B")); QVERIFY(view.selectionModel()->isSelected(model.index(1, 0))); + + // Test that it wraps round + model.appendRow(new QStandardItem("Andy")); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(3, 0))); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(0, 0))); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(3, 0))); + + // Test that it handles the case where the first item is hidden correctly + model.insertRow(0, new QStandardItem("Hidden item")); + view.setRowHidden(0, QModelIndex(), true); + + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 0))); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(4, 0))); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 0))); + + QTest::qWait(QApplication::keyboardInputInterval() * 2); + model.clear(); + view.setCurrentIndex(QModelIndex()); + QList<QStandardItem *> items = { new QStandardItem("Andreas"), new QStandardItem("Alicia") }; + model.appendRow(items); + items = { new QStandardItem("Baldrian"), new QStandardItem("Belinda") }; + model.appendRow(items); + items = { new QStandardItem("Cecilie"), new QStandardItem("Claire") }; + model.appendRow(items); + QVERIFY(!view.selectionModel()->hasSelection()); + QVERIFY(!view.selectionModel()->isSelected(model.index(0, 0))); + + // We want to search on the 2nd column so we have to force it to have + // an index in that column as a starting point + view.setCurrentIndex(QModelIndex(model.index(0, 1))); + // Second item in first row is selected + view.keyboardSearch(QLatin1String("A")); + QTRY_VERIFY(view.selectionModel()->isSelected(model.index(0, 1))); + QVERIFY(view.currentIndex() == model.index(0, 1)); + + // Second item in first row is still selected + view.keyboardSearch(QLatin1String("l")); + QVERIFY(view.selectionModel()->isSelected(model.index(0, 1))); + QCOMPARE(view.currentIndex(), model.index(0, 1)); + + // No "AnB" item - keep the same selection. + view.keyboardSearch(QLatin1String("B")); + QVERIFY(view.selectionModel()->isSelected(model.index(0, 1))); + QCOMPARE(view.currentIndex(), model.index(0, 1)); + + // Wait a bit. + QTest::qWait(QApplication::keyboardInputInterval() * 2); + + // The item that starts with B is selected. + view.keyboardSearch(QLatin1String("B")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 1))); + QCOMPARE(view.currentIndex(), model.index(1, 1)); + + // Test that it wraps round + items = { new QStandardItem("Andy"), new QStandardItem("Adele") }; + model.appendRow(items); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(3, 1))); + QCOMPARE(view.currentIndex(), model.index(3, 1)); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(0, 1))); + QCOMPARE(view.currentIndex(), model.index(0, 1)); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(3, 1))); + QCOMPARE(view.currentIndex(), model.index(3, 1)); + + // Test that it handles the case where the first item is hidden correctly + model.insertRow(0, new QStandardItem("Hidden item")); + view.setRowHidden(0, QModelIndex(), true); + + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 1))); + QCOMPARE(view.currentIndex(), model.index(1, 1)); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(4, 1))); + QCOMPARE(view.currentIndex(), model.index(4, 1)); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 1))); + QCOMPARE(view.currentIndex(), model.index(1, 1)); } void tst_QTreeView::keyboardSearchMultiColumn() @@ -4466,5 +4564,51 @@ void tst_QTreeView::statusTip() QTest::mouseMove(mw.windowHandle(), centerPoint); QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("Header 0 -- Status")); } + +static void fillModeltaskQTBUG_8376(QAbstractItemModel &model) +{ + model.insertRow(0); + model.insertColumn(0); + model.insertColumn(1); + QModelIndex index = model.index(0, 0); + model.setData(index, "Level0"); + { + model.insertRow(0, index); + model.insertRow(1, index); + model.insertColumn(0, index); + model.insertColumn(1, index); + + QModelIndex idx; + idx = model.index(0, 0, index); + model.setData(idx, "Level1"); + + idx = model.index(0, 1, index); + model.setData(idx, "very\nvery\nhigh\ncell"); + } +} + +void tst_QTreeView::taskQTBUG_8376() +{ + QTreeView tv; + QStandardItemModel model; + fillModeltaskQTBUG_8376(model); + tv.setModel(&model); + tv.expandAll(); // init layout + + QModelIndex idxLvl0 = model.index(0, 0); + QModelIndex idxLvl1 = model.index(0, 1, idxLvl0); + const int rowHeightLvl0 = tv.rowHeight(idxLvl0); + const int rowHeightLvl1Visible = tv.rowHeight(idxLvl1); + QVERIFY(rowHeightLvl0 < rowHeightLvl1Visible); + + tv.hideColumn(1); + const int rowHeightLvl1Hidden = tv.rowHeight(idxLvl1); + QCOMPARE(rowHeightLvl0, rowHeightLvl1Hidden); + + tv.showColumn(1); + const int rowHeightLvl1Visible2 = tv.rowHeight(idxLvl1); + QCOMPARE(rowHeightLvl1Visible, rowHeightLvl1Visible2); +} + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp index acd44565eb..4cd741000e 100644 --- a/tests/manual/cocoa/menurama/menuramaapplication.cpp +++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp @@ -28,7 +28,7 @@ #include "menuramaapplication.h" -MenuramaApplication::MenuramaApplication(int argc, char **argv) +MenuramaApplication::MenuramaApplication(int &argc, char **argv) : QApplication (argc, argv) { #if 0 diff --git a/tests/manual/cocoa/menurama/menuramaapplication.h b/tests/manual/cocoa/menurama/menuramaapplication.h index 1a5a55e0ff..2d836832fa 100644 --- a/tests/manual/cocoa/menurama/menuramaapplication.h +++ b/tests/manual/cocoa/menurama/menuramaapplication.h @@ -36,7 +36,7 @@ class MenuramaApplication : public QApplication { public: - MenuramaApplication(int argc, char **argv); + MenuramaApplication(int &argc, char **argv); void addDynMenu(QLatin1String title, QMenu *parentMenu); QAction *findAction(QLatin1String title, QMenu *parentMenu); |